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

Revision 188, 7.5 KB (checked in by bhilburn, 15 years ago)

Finished migration to functions using private socketFD field rather than
passing around the socketFD by value.

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() = 0;
38
39
40        /* Wait for a command signal containing task instructions.
41         */
42        virtual void WaitForSignal() = 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() = 0;
60        virtual void DeregisterComponent() = 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() = 0;
79        virtual void DeregisterServices() = 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();
94        void WaitForSignal();
95        void Shutdown();
96        void Reset();
97        void RegisterComponent();
98        void DeregisterComponent();
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        /* The socket file descriptor information for the shell which this SML
136         * is connected to.
137         */
138        int32_t socketFD;
139};
140
141
142/* Policy Engine class declaration.  All public functions are inherited from
143 * parent classes.
144 */
145class PolicyEngine : public Engine
146{
147    public:
148        PolicyEngine();
149        ~PolicyEngine();
150
151
152        /* Overloaded constructor that creates a policy engine object and
153         * connects it to either the shell or an SML, depening on the SML bool.
154         */
155        PolicyEngine(const char* serverName, const char* portNumber, \
156                const bool SML);
157
158        void GetRemoteComponentType();
159        void WaitForSignal();
160        void Shutdown();
161        void Reset();
162        void RegisterComponent();
163        void DeregisterComponent();
164
165        void RegisterServices();
166        void DeregisterServices();
167
168    private:
169        /* Parse and load/reload policies into the policy engine.
170         */
171        void LoadPolicies();
172        void ReloadPolicies();
173
174       
175        /* Return a decision made by the policy engine regarding a certain set
176         * of transmission parameters.
177         */
178        void SendPEDecision(struct Parameter pList[], struct CE_Info *ce_info, \
179                int32_t decision_array[]);
180
181
182        /* Validate a set of transmission parameters received from the radio.
183         */
184        void ValidateParameters(struct Parameter pList[], \
185                struct CE_Info *ce_info, int decision_array[]);
186
187
188        /* The SML_present bool reflects whether or not the remote component
189         * this object is connected to is an SML.  If it isn't, then it must be
190         * a shell.  The socketFD stores the socket file descriptor for this
191         * connection.
192         */
193        bool SML_present;
194        int32_t socketFD;
195};
196
197
198/* Cognitive Engine class declaration.  All public functions are inherited from
199 * parent classes.
200 */
201class CognitiveEngine : public Engine
202{
203    public:
204        CognitiveEngine();
205        ~CognitiveEngine();
206
207        void GetRemoteComponentType();
208        void WaitForSignal();
209        void Shutdown();
210        void Reset();
211        void RegisterComponent();
212        void DeregisterComponent();
213
214        void RegisterServices();
215        void DeregisterServices();
216
217    private:
218        /* Receive the transmitted radio configuration from the radio itself
219         * (the CE will not always be local to the radio).
220         */
221        void ReceiveRadioConfiguration();
222
223
224        /* Receive an 'experience' report from the radio.
225         */
226        void ReceiveExperience();
227
228
229        /* Find the most optimal set of transmission parameters given certain
230         * observables and possibly a service if the SML component is present
231         * and active.
232         */
233        void GetSolution(Observable *observables);
234        void GetSolution(Observable *observables, std::string service);
235
236
237        /* Receive a feedback from the radio regarding the performance of a
238         * certain set of parameters, possibly associated with a service.
239         *
240         * TODO what is the difference between experiences and feedback,
241         * exactly? we should explain that explicitly here.
242         */
243        void ReceiveFeedback(Observable *observables,\
244                Parameter *parameters, Utility *utilities);
245        void ReceiveFeedback(Observable *observables, \
246                Parameter *parameters, std::string service);
247
248        /* The SML_present bool reflects whether or not the remote component
249         * this object is connected to is an SML.  If it isn't, then it must be
250         * a shell.  The socketFD stores the socket file descriptor for this
251         * connection.
252         */
253        bool SML_present;
254        int32_t socketFD;
255};
256
257#endif
Note: See TracBrowser for help on using the browser.