Bridge++  Ver. 1.2.x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
parameters_factory.h
Go to the documentation of this file.
1 
13 #ifndef PARAMETERS_FACTORY_INCLUDED
14 #define PARAMETERS_FACTORY_INCLUDED
15 
16 #include <map>
17 #include <list>
18 #include <vector>
19 #include <string>
20 #include "defs.h"
21 #include "parameters.h"
22 #include "bridgeIO.h"
23 
25 
51 class Parameters;
52 
54  private:
55  typedef void (*creator_callback)(Parameters&);
56  typedef std::list<creator_callback> creator_callback_list;
57  typedef std::map<std::string, creator_callback_list> database_type;
58 
59  public:
60  Parameters *create_parameters(const std::string& realm);
61 
62  bool register_callback(const std::string& realm, const creator_callback& cb);
63 
64  static ParametersFactory& Instance();
65 
66  static Parameters *New(const std::string& realm)
67  {
68  return Instance().create_parameters(realm);
69  }
70 
71  static bool Register(const std::string& realm, const creator_callback& cb)
72  {
73  return Instance().register_callback(realm, cb);
74  }
75 
76  private:
77  // singleton
79  ParametersFactory(const ParametersFactory&); // left unimplemented.
80  ParametersFactory& operator=(const ParametersFactory&); // left unimplemented.
81 
83 
84  static void CreateInstance();
85 
87 
88  std::vector<std::string> string_tokenize(const std::string& src, const char delim = '.');
89  std::string string_concat(const std::vector<std::string>& src, const char delim = '.');
90 
92 };
93 #endif
std::string string_concat(const std::vector< std::string > &src, const char delim= '.')
Parameters * create_parameters(const std::string &realm)
bool register_callback(const std::string &realm, const creator_callback &cb)
void(* creator_callback)(Parameters &)
Class for parameters.
Definition: parameters.h:40
static Parameters * New(const std::string &realm)
std::map< std::string, creator_callback_list > database_type
static ParametersFactory & Instance()
ParametersFactory & operator=(const ParametersFactory &)
static ParametersFactory * s_instance
static bool Register(const std::string &realm, const creator_callback &cb)
std::list< creator_callback > creator_callback_list
std::vector< std::string > string_tokenize(const std::string &src, const char delim= '.')
static void CreateInstance()