root/vtcross/trunk/src/include/vtcross/components.h @ 518

Revision 518, 4.6 KB (checked in by bhilburn, 14 years ago)

Added Doxygen documentation to headers in the include/vtcross directory.

Line 
1/*
2 Copyright 2009 Virginia Polytechnic Institute and State University 
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7 
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/*! This header exports the base declarations for all CROSS radio components.
18 *
19 * It contains two pure abstract base classes, Component and Engine; Engine
20 * derives from Component.  All functions contained within the abstract base
21 * classes are dynamically linked and pure, and all child non-abstract classes
22 * derive using private inheritence.  Class functions of the abstract base
23 * classes are public for two reasons: (1) To allow for public/protected
24 * inheritence in other implementations, (2) So that symbolic debuggers can
25 * navigate the call tree for typecasted objects of derivative classes.
26 *
27 * Note that any new component type declaration MUST include this header and
28 * extend a parent component type.
29 */
30
31#ifndef COMPONENTS_H
32#define COMPONENTS_H
33
34
35#include <cstring>
36#include <stdint.h>
37#include <string>
38
39#include "containers.h"
40#include "socketcomm.h"
41
42
43/*! \brief The Component class is the top-level abstract base class in CROSS.
44 *
45 * Component abstract base class that all component classes should inherit from,
46 * including cognitive and policy engines, and the service management layer.
47 * Defines only functions required by all component types.
48 */
49class Component
50{
51    public:
52        /*! \brief Asks a component to identify itself.
53         *
54         * Asks the component at the passed socket FD for its component type
55         * string.  Note that this implementation is global for all component
56         * types, so is implemented here.  Should a component need to override
57         * it, that is possible via dynamic binding or overloading.
58         */
59        virtual std::string GetRemoteComponentType(int32_t componentSocketFD)
60        {
61            SendMessage(componentSocketFD, "request_component_type");
62
63            char buffer[256];
64            memset(buffer, 0, 256);
65            ReadMessage(componentSocketFD, buffer);
66
67            return std::string(buffer);
68        }
69
70        /*! \brief Responds to a request for identification.
71         *
72         * Send an indentfying string for this object's component type in
73         * response to a GetRemoteComponentType query.
74         */
75        virtual void SendComponentType() = 0;
76
77        /*! \brief Shutdown the component. */
78        virtual void Shutdown() = 0;
79
80        /*! \brief Reset the component and reload configurations. */
81        virtual void Reset() = 0;
82
83        /*! \brief Compenent registration procedures. */
84        virtual void RegisterComponent() = 0;
85        virtual void DeregisterComponent() = 0;
86};
87
88
89/*! \brief Engine abstract base class declaration.
90 *
91 * Engine abstract base class from which all engine component types should
92 * inherit (e.g. cognitive and policy engines). Inherits all functions from the
93 * ABC Component publically.
94 */
95class Engine : public Component
96{
97    public:
98        /*! \brief Connect to a remote controlling component.
99         *
100         * Connect to the remote control component, which will always be either
101         * the CROSS shell or SML.  Based on the status of the SML_present
102         * bool, this function will also register the component or services.
103         *
104         * TODO I feel like the name of this function could be changed to be a
105         * little more descriptive? */
106        virtual void ConnectToRemoteComponent(const char* serverName, \
107                const char* serverPort, const bool SML) = 0;
108       
109        /*! \brief Wait for a command signal containing task instructions.
110         *
111         * This is the general run-time loop from which all radio operation
112         * occurs.  Once the Engine has started up and initialized, it will
113         * remain in this function until it receives a command to perform some
114         * action. */
115        virtual void WaitForSignal() = 0;
116
117        /*! \brief Functions for interacting with the service management layer.
118         *
119         * Register or deregister services that this engine provides with the
120         * service management layer. */
121        virtual void RegisterServices() = 0;
122        virtual void DeregisterServices() = 0;
123};
124
125#endif
Note: See TracBrowser for help on using the browser.