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 <map>
00025 #include <vector>
00026 #include <string>
00027
00028 using std::vector;
00029 using std::map;
00030 using std::string;
00031
00032 class Y2ComponentCreator;
00033 class Y2Component;
00034
00053 class Y2ComponentBroker
00054 {
00055 public:
00060 enum order_t { BUILTIN = 0,
00061 PLUGIN = 1,
00062 SCRIPT = 2,
00063 EXTERNAL_PROGRAM = 3,
00064 NETWORK = 4,
00065 MAX_ORDER = 5 };
00066
00067 private:
00068
00069 struct ltstr
00070 {
00071 bool operator()(const char* s1, const char* s2) const
00072 {
00073 return strcmp(s1, s2) < 0;
00074 }
00075 };
00076
00077 static map<const char *, const Y2Component *, ltstr> namespaces;
00078
00082 static vector<const Y2ComponentCreator *> *creators[MAX_ORDER];
00083
00089 static bool stop_register;
00090
00096 static map<string, string> namespace_exceptions;
00097
00098 public:
00110 static void registerComponentCreator(const Y2ComponentCreator *creator, order_t order);
00111
00112 private:
00121 static Y2Component *createComponent(const char *name, bool look_for_clients);
00122
00123 public:
00127 static Y2Component *createClient(const char *name);
00128
00132 static Y2Component *createServer(const char *name);
00133
00140 static Y2Component *getNamespaceComponent(const char *name);
00141
00149 static bool registerNamespaceException(const char* name_space, const char* component_name);
00150
00151 private:
00155 static void initializeLists();
00156 };
00157
00158
00159 #endif //Y2ComponentBroker_h