00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef Y2ComponentBroker_h
00022 #define Y2ComponentBroker_h
00023
00024 #include <string.h>
00025 #include <map>
00026 #include <vector>
00027 #include <string>
00028
00029 using std::vector;
00030 using std::map;
00031 using std::string;
00032
00033 class Y2ComponentCreator;
00034 class Y2Component;
00035
00091 class Y2ComponentBroker
00092 {
00093 public:
00098 enum order_t { BUILTIN = 0,
00099 PLUGIN = 1,
00100 SCRIPT = 2,
00101 EXTERNAL_PROGRAM = 3,
00102 NETWORK = 4,
00103 MAX_ORDER = 5 };
00104
00105 private:
00106
00107 struct ltstr
00108 {
00109 bool operator()(const char* s1, const char* s2) const
00110 {
00111 return strcmp(s1, s2) < 0;
00112 }
00113 };
00114
00115 static map<const char *, const Y2Component *, ltstr> namespaces;
00116
00120 static vector<const Y2ComponentCreator *> *creators[MAX_ORDER];
00121
00127 static bool stop_register;
00128
00134 static map<string, string> namespace_exceptions;
00135
00136 public:
00149 static void registerComponentCreator(const Y2ComponentCreator *creator, order_t order, bool force=false);
00150
00151 private:
00160 static Y2Component *createComponent(const char *name, bool look_for_clients);
00161
00162 public:
00166 static Y2Component *createClient(const char *name);
00167
00171 static Y2Component *createServer(const char *name);
00172
00179 static Y2Component *getNamespaceComponent(const char *name);
00180
00188 static bool registerNamespaceException(const char* name_space, const char* component_name);
00189
00190 private:
00194 static void initializeLists();
00195 };
00196
00197
00198 #endif //Y2ComponentBroker_h