00001
00014 #ifndef __RtcModuleProfile_h__
00015 #define __RtcModuleProfile_h__
00016
00017
00018 #include "rtm/RTC.h"
00019
00020
00021 #include <map>
00022 #include <string>
00023
00024
00025 #include "rtm/idl/RTCProfileSkel.h"
00026 #include "rtm/idl/RTCProfileStub.h"
00027 #include "rtm/idl/RTCBaseSkel.h"
00028 #include "rtm/idl/RTCBaseStub.h"
00029
00030
00031 namespace RTM {
00032 using namespace std;
00033
00039 typedef enum RtcModuleProfileType {
00040 RTC_MODULE_NAME,
00041 RTC_MODULE_DESC,
00042 RTC_MODULE_VERSION,
00043 RTC_MODULE_AUTHOR,
00044 RTC_MODULE_COMPANY,
00045 RTC_MODULE_CATEGORY,
00046 RTC_MODULE_COMP_TYPE,
00047 RTC_MODULE_ACT_TYPE,
00048 RTC_MODULE_MAX_INST,
00049 RTC_MODULE_LANG,
00050 RTC_MODULE_LANG_TYPE,
00051 RTC_MODULE_SPEC_END
00052 };
00053
00054
00060 typedef struct RtcModuleProfSpec {
00061 RtcModuleProfileType type;
00062 char* value;
00063 };
00064
00065
00066 typedef map<string, int>::value_type TypeMapValue;
00067
00071 static TypeMapValue CompTypes[] = {
00072 TypeMapValue("STATIC", STATIC),
00073 TypeMapValue("UNIQUE", UNIQUE),
00074 TypeMapValue("COMMUTATIVE", COMMUTATIVE)
00075 };
00076
00080 static TypeMapValue ActTypes[] = {
00081 TypeMapValue("PERIODIC", PERIODIC),
00082 TypeMapValue("SPORADIC", SPORADIC),
00083 TypeMapValue("EVENT_DRIVEN", EVENT_DRIVEN),
00084 };
00085
00089 static TypeMapValue LangTypes[] = {
00090 TypeMapValue("COMPILE", COMPILE),
00091 TypeMapValue("SCRIPT", SCRIPT),
00092 };
00093
00094
00095
00101 class RtcModuleProfile
00102 {
00103 public:
00104
00108 RtcModuleProfile();
00109
00115 RtcModuleProfile(RtcModuleProfSpec *spec);
00116
00117
00118 RTCProfile getProfile();
00119
00125 bool initSpec(RtcModuleProfSpec *spec);
00126
00127
00128
00134 bool setImplementationId(const char* implementation_id);
00135 const char* getImplementationId(){return m_Profile.implementation_id;};
00136
00142 bool setInstanceId(const char* instance_id);
00143 const char* getInstanceId(){return m_Profile.instance_id;};
00144
00152 bool setDescription(const char* desc);
00153 const char* getDescription() {return m_Profile.description;};
00154
00155
00161 bool setVersion(const char* version);
00162 const char* getVersion() {return m_Profile.version;};
00163
00164
00170 bool setAuthorName(const char* author_name);
00171 const char* getAuthorName() {return m_Profile.maker;};
00172 bool setAuthorCompany(const char* author_company);
00173 const char* getAuthorCompany() {return m_Profile.maker;};
00174
00175
00176
00177
00178
00179
00180
00181
00182 bool setCategory(const char* category);
00183 const char* getCategory() {return m_Profile.category;};
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199 bool setComponentType(RTComponentType type);
00200 bool setComponentType(const char *type_str);
00201 RTComponentType getComponentType() {return m_Profile.component_type;};
00202
00203
00218 bool setActivityType(RTCActivityType type);
00219 bool setActivityType(const char *type_str);
00220 RTCActivityType getActivityType() {return m_Profile.activity_type;};
00221
00222
00229 bool setMaxInstance(int max);
00230 bool setMaxInstance(const char *max_str);
00231 int getMaxInstance() {return m_Profile.max_instance;};
00232
00233
00239 bool setLanguage(const char* langugae);
00240 const char* getLanguage() {return m_Profile.language;};
00241
00242
00251 bool setLanguageType(RTCLangType type);
00252 bool setLanguageType(const char *type_str);
00253 RTCLangType getLanguageType() {return m_Profile.language_type;};
00254
00255
00261 bool setIconImage(const char* image);
00262 const char* getIconImage() {return NULL;};
00263
00264 bool appendInPortProfile(const PortProfile port_profile);
00265 PortProfile getInPortProfile(const char* name);
00266 PortProfileList getInPortProfileList();
00267
00268 bool appendOutPortProfile(const PortProfile port_profile);
00269 PortProfile getOutPortProfile(const char* name);
00270 PortProfileList getOutPortProfileList();
00271
00272
00273
00274 private:
00275 void RtcModuleProfile::initTable();
00276
00277
00278 RTCProfile m_Profile;
00279
00280 map<string, int> m_CompTypeMap;
00281 map<string, int> m_ActTypeMap;
00282 map<string, int> m_LangTypeMap;
00283 int m_CompTypeSize;
00284 int m_ActTypeSize;
00285 int m_LangTypeSize;
00286
00287 typedef bool (RtcModuleProfile::*SpecInitFunc)(const char* );
00288 SpecInitFunc _init_func[RTC_MODULE_SPEC_END];
00289
00290 };
00291
00292
00293 };
00294
00295
00296 #endif // end of __RtcModuleProfile_h__