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
00054 class Y2ComponentBroker
00055 {
00056 public:
00061 enum order_t { BUILTIN = 0,
00062 PLUGIN = 1,
00063 SCRIPT = 2,
00064 EXTERNAL_PROGRAM = 3,
00065 NETWORK = 4,
00066 MAX_ORDER = 5 };
00067
00068 private:
00069
00070 struct ltstr
00071 {
00072 bool operator()(const char* s1, const char* s2) const
00073 {
00074 return strcmp(s1, s2) < 0;
00075 }
00076 };
00077
00078 static map<const char *, const Y2Component *, ltstr> namespaces;
00079
00083 static vector<const Y2ComponentCreator *> *creators[MAX_ORDER];
00084
00090 static bool stop_register;
00091
00097 static map<string, string> namespace_exceptions;
00098
00099 public:
00112 static void registerComponentCreator(const Y2ComponentCreator *creator, order_t order, bool force=false);
00113
00114 private:
00123 static Y2Component *createComponent(const char *name, bool look_for_clients);
00124
00125 public:
00129 static Y2Component *createClient(const char *name);
00130
00134 static Y2Component *createServer(const char *name);
00135
00142 static Y2Component *getNamespaceComponent(const char *name);
00143
00151 static bool registerNamespaceException(const char* name_space, const char* component_name);
00152
00153 private:
00157 static void initializeLists();
00158 };
00159
00160
00161 #endif //Y2ComponentBroker_h