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
00033
00034
00035
00036
00037
00038
00039 #ifndef __BOOTSTRAP_MANAGER_H
00040 #define __BOOTSTRAP_MANAGER_H
00041
00042 #include <map>
00043 #include <algorithm>
00044 #include <vector>
00045 #include <string>
00046 #include <boost/thread/mutex.hpp>
00047 #include <boost/thread/thread.hpp>
00048 #include <boost/thread/condition_variable.hpp>
00049 #include <boost/utility.hpp>
00050 #include <boost/bind.hpp>
00051 #include <boost/foreach.hpp>
00052 #include "ariba/utility/logging/Logging.h"
00053 #include "ariba/utility/bootstrap/modules/BootstrapModule.h"
00054 #include "ariba/utility/bootstrap/BootstrapInformationCallback.h"
00055
00056 using std::string;
00057 using std::map;
00058 using std::find;
00059 using std::vector;
00060
00061 namespace ariba {
00062 namespace utility {
00063
00064 class BootstrapManager : private boost::noncopyable, private BootstrapInformationCallback {
00065 use_logging_h(BootstrapManager);
00066 friend class BootstrapModule;
00067 public:
00068
00069 static BootstrapManager& instance() {
00070 static BootstrapManager _inst;
00071 return _inst;
00072 }
00073
00074 enum BootstrapType {
00075 BootstrapTypeMulticastDns,
00076 BootstrapTypePeriodicBroadcast,
00077 BootstrapTypeBluetoothSdp,
00078 };
00079
00080 enum RegistrationResult {
00081 RegistrationSucceeded,
00082 RegistrationNotSupported,
00083 RegistrationFailed,
00084 };
00085
00086 RegistrationResult registerAllModules();
00087 RegistrationResult registerModule(BootstrapType type);
00088 RegistrationResult unregisterAllModules();
00089 RegistrationResult unregisterModule(BootstrapType type);
00090 bool isModuleRegistered(BootstrapType type);
00091
00092 void registerCallback(BootstrapInformationCallback* _callback);
00093 void unregisterCallback(BootstrapInformationCallback* _callback);
00094
00095 void publish(string name, string info1, string info2, string info3);
00096 void revoke(string name);
00097
00098 protected:
00099 virtual void onBootstrapServiceFound(string name, string info1, string info2, string info3);
00100
00101 private:
00102 BootstrapManager();
00103 ~BootstrapManager();
00104
00105 typedef map<BootstrapType, BootstrapModule*> ModuleMap;
00106 ModuleMap modules;
00107 boost::mutex modulesMutex;
00108
00109 typedef vector<BootstrapInformationCallback*> Callbacks;
00110 Callbacks callbacks;
00111 };
00112
00113 }}
00114
00115 #endif // __BOOTSTRAP_MANAGER_H