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

Revision 182, 7.9 KB (checked in by bhilburn, 15 years ago)

Need to get the components using standard TCP/IP structs to store information
regarding remote hosts (like where the SML or shell is). This is absolutely the
next step.

Line 
1/* Virginia Tech Cognitive Radio Open Source Systems
2 * Virginia Tech, 2009
3 *
4 * LICENSE INFORMATION GOES HERE
5 */
6
7/* This header exports the declarations for all VT-CROSS radio components.  It
8 * contains two pure abstract base classes, Component and Engine; Engine derives
9 * from Component.  All functions contained within the abstract base classes are
10 * dynamically linked and pure, and all child non-abstract classes derive using
11 * private inheritence.  Class functions of the abstract base classes are public
12 * for two reasons: (1) To allow for public/protected inheritence in other
13 * implementations, (2) So that symbolic debuggers can navigate the call tree
14 * for typecasted objects of derivative classes.
15 */
16
17#ifndef COMPONENTS_H
18#define COMPONENTS_H
19
20
21#include <stdint.h>
22#include <string>
23
24#include "containers.h"
25
26
27/* Component abstract base class that all component classes should inherit from,
28 * including cognitive and policy engines, and the service management layer.
29 * Defines only functions required by all component types.
30 */
31class Component
32{
33    public:
34        /* Asks the component at the passed socket FD for its component type
35         * string.
36         */
37        virtual void GetRemoteComponentType(int32_t socketFD) = 0;
38
39
40        /* Wait for a command signal containing task instructions.
41         */
42        virtual void WaitForSignal(int32_t socketFD) = 0;
43
44
45        /* Completely shutdown the radio and all operations.
46         */
47        virtual void Shutdown() = 0;
48
49
50        /* Reset the radio and reload all configuration files.
51         *
52         * TODO are we remembering experiences in CEs?
53         */
54        virtual void Reset() = 0;
55
56
57        /* Register or deregister a component with the primary radio shell.
58         */
59        virtual void RegisterComponent(int32_t socketFD) = 0;
60        virtual void DeregisterComponent(int32_t socketFD) = 0;
61};
62
63
64/* Engine abstract base class from which all engine component types should
65 * inherit (e.g. cognitive and policy engines). Inherits all functions from the
66 * ABC Component publically.
67 *
68 * TODO perhaps this shouldn't be an abstract base class? Some functions, like
69 * GetRemoteComponentType, are going to be the same for all child classes
70 * anyways...
71 */
72class Engine : public Component
73{
74    public:
75        /* Register or deregister services that this engine provides with the
76         * service management layer.
77         */
78        virtual void RegisterServices(int32_t socketFD) = 0;
79        virtual void DeregisterServices(int32_t socketFD) = 0;
80};
81
82
83/* Service Management Layer (SML) class declaration.  The functions listed here
84 * are required by the VTCROSS API for service-oriented VTCROSS radio
85 * architectures.
86 */
87class ServiceManagementLayer : public Component
88{
89    public:
90        ServiceManagementLayer();
91        ~ServiceManagementLayer();
92
93        void GetRemoteComponentType(int32_t socketFD);
94        void WaitForSignal(int32_t socketFD);
95        void Shutdown();
96        void Reset();
97        void RegisterComponent(int32_t socketFD);
98        void DeregisterComponent(int32_t socketFD);
99
100    private:
101        /* Receive the radio configuration settings from the shell and pass them
102         * on to another component.
103         */
104        void TransferRadioConfiguration();
105
106       
107        /* Receive information regarding a completed 'experience' and pass it on
108         * to the appropriate cognitive engine.
109         */
110        void TransferExperience();
111
112       
113        /* Listen for other components registering their available services with
114         * the SML. */
115        void ReceiveServices();
116
117
118        /* Change the active mission of the radio to a new one and adjust radio
119         * behavoir appropriately.
120         */
121        void SetActiveMission();
122
123
124        /* List all services provided to the radio by registered components.
125         */
126        void ListServices();
127
128
129        /* Load/Relead the XML configuration file.
130         */
131        void ReloadConfiguration();
132        void LoadConfiguration();
133};
134
135
136/* Contains information regarding the SML in a VTCROSS system.  Note that if
137 * there is no SML present, the engine should have no instantiation of this
138 * struct.
139 *
140 * TODO pretty sure this guy is wholly unnecessary... should be using standard
141 * TCP/IP structs like hostent....
142 */
143struct SML_Info {
144    std::string hostname;
145    std::string port;
146    int32_t socketFD;
147};
148
149
150/* Policy Engine class declaration.  All public functions are inherited from
151 * parent classes.
152 */
153class PolicyEngine : public Engine
154{
155    public:
156        PolicyEngine();
157        ~PolicyEngine();
158
159
160        /* Overloaded constructor that creates a policy engine object with SML
161         * information pre-defined.
162         */
163        PolicyEngine(const char* serverName, const char* portNumber);
164
165        void GetRemoteComponentType(int32_t socketFD);
166        void WaitForSignal(int32_t socketFD);
167        void Shutdown();
168        void Reset();
169        void RegisterComponent(int32_t socketFD);
170        void DeregisterComponent(int32_t socketFD);
171
172        void RegisterServices(int32_t socketFD);
173        void DeregisterServices(int32_t socketFD);
174
175    private:
176        /* Parse and load/reload policies into the policy engine.
177         */
178        void LoadPolicies();
179        void ReloadPolicies();
180
181       
182        /* Return a decision made by the policy engine regarding a certain set
183         * of transmission parameters.
184         */
185        void SendPEDecision(int32_t socketFD, struct Parameter pList[], \
186                struct CE_Info *ce_info, int32_t decision_array[]);
187
188
189        /* Validate a set of transmission parameters received from the radio.
190         */
191        void ValidateParameters(struct Parameter pList[], \
192                struct CE_Info *ce_info, int decision_array[]);
193
194
195        /* Contains information regarding the presence of a service management
196         * layer.  If this pointer is NULL, then there is no SML present in the
197         * radio system.
198         */
199        struct SML_Info *SML;
200};
201
202
203/* Cognitive Engine class declaration.  All public functions are inherited from
204 * parent classes.
205 */
206class CognitiveEngine : public Engine
207{
208    public:
209        CognitiveEngine();
210        ~CognitiveEngine();
211
212        void GetRemoteComponentType(int32_t socketFD);
213        void WaitForSignal(int32_t socketFD);
214        void Shutdown();
215        void Reset();
216        void RegisterComponent(int32_t socketFD);
217        void DeregisterComponent(int32_t socketFD);
218
219        void RegisterServices(int32_t socketFD);
220        void DeregisterServices(int32_t socketFD);
221
222    private:
223        /* Receive the transmitted radio configuration from the radio itself
224         * (the CE will not always be local to the radio).
225         */
226        void ReceiveRadioConfiguration(int32_t socketFD);
227
228
229        /* Receive an 'experience' report from the radio.
230         */
231        void ReceiveExperience(int32_t socketFD);
232
233
234        /* Find the most optimal set of transmission parameters given certain
235         * observables and possibly a service if the SML component is present
236         * and active.
237         */
238        void GetSolution(Observable *observables);
239        void GetSolution(Observable *observables, std::string service);
240
241
242        /* Receive a feedback from the radio regarding the performance of a
243         * certain set of parameters, possibly associated with a service.
244         *
245         * TODO what is the difference between experiences and feedback,
246         * exactly? we should explain that explicitly here.
247         */
248        void ReceiveFeedback(Observable *observables,\
249                Parameter *parameters, Utility *utilities);
250        void ReceiveFeedback(Observable *observables, \
251                Parameter *parameters, std::string service);
252
253
254        /* Contains information regarding the presence of a service management
255         * layer.  If this pointer is NULL, then there is no SML present in the
256         * radio system.
257         */
258        struct SML_Info *SML;
259
260};
261
262#endif
Note: See TracBrowser for help on using the browser.