00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00043 #ifndef CLMSG_DISCOVERY_H
00044 #define CLMSG_DISCOVERY_H
00045
00046 #include <clmessage.h>
00047 #include <map>
00048 #include <list>
00049 #include <set>
00050 #include <vector>
00051 #include <packet.h>
00052 #include <string>
00053
00054 #define CLMSG_DISCOVERY_VERBOSITY 3
00055
00056 extern ClMessage_t CLMSG_DISCOVERY;
00057
00058 class DiscoveryData;
00059 class ClSAP;
00060 class PlugIn;
00061
00062
00063 typedef map<int, DiscoveryData> DBId;
00064
00065
00066 typedef map< const PlugIn* , int > DBPointer2Id;
00067
00068 typedef map< int , set<int> > DBLayer2Id;
00069
00070 typedef map< string , set<int> > DBTag2Id;
00071
00072 typedef map< string , set<int> > DBName2Id;
00073
00074 typedef set<int>::iterator SetIt;
00075 typedef set<int>::reverse_iterator setRit;
00076 typedef DBPointer2Id::iterator DBPointer2IdIt;
00077 typedef DBPointer2Id::reverse_iterator DBPointer2IdRit;
00078 typedef DBLayer2Id::iterator DBLayer2IdIt;
00079 typedef DBLayer2Id::reverse_iterator DBLayer2IdRit;
00080 typedef DBTag2Id::iterator DBTag2IdIt;
00081 typedef DBTag2Id::reverse_iterator DBTag2IdRit;
00082 typedef DBName2Id::iterator DBName2IdIt;
00083 typedef DBName2Id::reverse_iterator DBName2IdRit;
00084 typedef DBId::iterator DBIt;
00085 typedef DBId::reverse_iterator DBRit;
00086
00087 typedef vector<DiscoveryData>::iterator VDDIt;
00088 typedef vector<DiscoveryData>::reverse_iterator VDDRit;
00089
00090 class DiscoveryData {
00091
00092 public:
00093
00094 DiscoveryData(const PlugIn* pointer, int layer_id, int id, const char* tcl_name, const char* miracle_tag);
00095 DiscoveryData();
00096 DiscoveryData(const DiscoveryData& DData2copy);
00097 void reset();
00098
00099 void setPointer(const PlugIn* pointer) { module_pointer = pointer; }
00100 const PlugIn* getPointer() { return module_pointer; }
00101
00102 void setLayer(int layer_id) { layer_id = module_layer_id; }
00103 int getLayer() { return module_layer_id; }
00104
00105 void setId(int id) { module_id = id; }
00106 int getId() { return module_id; }
00107
00108 void setTclName(const char* tcl_name) { module_tcl_name.clear(); module_tcl_name = tcl_name; }
00109 const char* getTclName() { return module_tcl_name.c_str(); }
00110
00111 void setMiracleTag(const char* miracle_tag) { module_miracle_tag.clear(); module_miracle_tag = miracle_tag;}
00112 const char* getMiracleTag() { return module_miracle_tag.c_str(); }
00113
00114 void setValid() { is_valid = true;}
00115 void setNotValid() {is_valid = false;}
00116
00117 private:
00118
00119 const PlugIn* module_pointer;
00120 int module_layer_id;
00121 int module_id;
00122 string module_tcl_name;
00123 string module_miracle_tag;
00124
00125 bool is_valid;
00126 };
00127
00128
00129 class DiscoveryStorage
00130 {
00131
00132 public:
00133
00134 DiscoveryStorage();
00135
00136
00137 int getDataSize();
00138 void addEntry(const PlugIn* pointer, int layer_id, int id, const char* tcl_name, const char* miracle_tag);
00139 void addEntry(DiscoveryData data);
00140 void removeEntry(int id);
00141
00142 void printData();
00143 int getSize() {return db_id.size();}
00144
00145 DiscoveryStorage findLayer(int layer_id);
00146 DiscoveryStorage findTag(const char* tag);
00147 DiscoveryStorage findTclName(const char* tcl_name);
00148 DiscoveryData findPointer(const PlugIn* pointer);
00149 DBIt begin() {return db_id.begin(); }
00150 DBIt end() {return db_id.end(); }
00151
00152 private:
00153
00154 DBId db_id;
00155 DBLayer2Id db_layer;
00156 DBTag2Id db_tag;
00157 DBName2Id db_name;
00158 DBPointer2Id db_pointer;
00159
00160 void reset();
00161 };
00162
00163
00164 class ClMsgDiscovery : public ClMessage
00165 {
00166
00167 public:
00168
00169 ClMsgDiscovery();
00170 ClMessage* copy();
00171
00172 DiscoveryStorage copyStorage();
00173 void addData(const PlugIn* pointer, int layer_id, int id, const char* tcl_name, const char* miracle_tag);
00174 void addSenderData(const PlugIn* pointer, int layer_id, int id, const char* tcl_name, const char* miracle_tag);
00175 void removeData(int id);
00176 void removeSenderData();
00177 void printReplyData();
00178
00179 int getDBSize();
00180
00181 DiscoveryData getSenderData();
00182
00183 DiscoveryStorage findLayer(int layer_id );
00184 DiscoveryStorage findTag(const char* tag);
00185 DiscoveryStorage findTclName(const char* tcl_name);
00186 DiscoveryData findPointer(const PlugIn* pointer);
00187
00188
00189 private:
00190
00191 DiscoveryStorage reply_storage;
00192 DiscoveryData sender_data;
00193 };
00194
00195
00196 #endif
00197
00198