ClockWork DB CoreAPI 1.0.48
Abstract Time Series and Storage/Management Library
Loading...
Searching...
No Matches
engine.hpp
1#ifndef HAVE_TOM_TSDB_ENGINE_HPP
2#define HAVE_TOM_TSDB_ENGINE_HPP
3
4#include <exception>
5#include <map>
6#include <vector>
7#include <memory>
8#include <tom-util/scalar.hpp>
9#include <tom-util/module_loader.hpp>
10#include <tom-util/logger.hpp>
11#include <tom-tsdb/smart_pointers.hpp>
12#include <boost/shared_ptr.hpp>
13
14
15namespace tom {
16 class xml_doc;
17}
18
19namespace tom {
20
21 namespace tsdb {
22
23 class session;
24 class provider;
25 class screening_manager;
26
33 {
34 public:
37 const tom::String & module,
38 const tom::String & descr ) :
39 m_name( name.value() ), m_module( module.value() ), m_descr( descr ) { }
40 virtual ~repository_meta_data( ) { }
41
45 const tom::string &
46 name() const { return m_name; }
47
51 const tom::string &
52 module() const { return m_module; }
53
57 const tom::string &
58 description() const { return m_descr; }
59
60 protected:
61 tom::string m_name;
62 tom::string m_module;
63 tom::string m_descr;
64
65 };
66 typedef std::vector< repository_meta_data > repository_meta_data_vec;
67
74 class engine
75 {
76 public:
77
87 static
88 engine &
89 Instance();
90
91 static
92 void
93 use_screening_dbs( bool use ){ s_use_screening_dbs = use; }
94
95 void
96 update_screening_dbs();
97
98 static
99 bool
100 use_screening_dbs() { return s_use_screening_dbs; }
101
107 const repository_meta_data_vec &
109
114 // get the session for the default provider as spec'd in the env config file
115 session_sptr
116 get_session( );
117
121 session_sptr
122 get_session( const tom::observation &name );
123
127 session_sptr
128 get_session( const char *name )
129 {
130 return get_session( tom::String( name ) );
131 }
132
137 provider &
138 get_provider( );
139
144 provider &
145 get_provider( const tom::observation &name );
146
151 provider &
152 get_provider( const char *name )
153 {
154 return get_provider( tom::String(name) );
155 }
159 static
160 const char *
161 version( );
162
163 public: // leave this class public...it is helpful
164 // customized module_loader for loading on demand req'd providers...
166 {
167 public:
168 // load modules searching dir for modules
169 module_loader( const tom::String dir );
171
172 // load module if necc, init, and return provider
173 provider &
174 get_provider( const tom::observation &name );
175
176 private:
177 // retrieve provider dynamic_library
179 get_provider_module( const tom::observation &name );
180
181 typedef std::map< tom::string, boost::shared_ptr<provider> > provider_map_t;
182 typedef provider_map_t::const_iterator const_iterator;
183 typedef provider_map_t::iterator iterator;
184
185 provider_map_t m_providers;
186 };
187
188 protected:
189
190 // get module name for provider
192 get_module_name( const tom::observation &name );
193
194 repository_meta_data_vec m_repository_names; // list of repositories
195 tom::String m_default_provider; // default backend if none chosen
196 tom::String m_module_dir; // directory to find provider modules
197 tom::xml_doc * m_config; // ptr to tom::env config file
198 tom::logger * m_logger;
199 module_loader * m_module_loader; // module loader to load provider modules...
200 screening_manager * m_screening_mgr { nullptr };
201 static bool s_use_screening_dbs;
202 private:
203 engine( );
204 public: // for pybind11 until i find a fix
205 ~engine( );
206 };
207
208 class NoTimeSeriesDbDefinedException : public std::runtime_error
209 {
210 public:
212 std::runtime_error( "No Time-Series Db Defined Exception" ){ };
213 };
214
215 class NoTimeSeriesDbDefaultProviderException : public std::runtime_error
216 {
217 public:
219 std::runtime_error( "No Time-Series Db Default Provider Exception" ) { };
220 };
221
222 class ProviderModuleDirectoryUndefinedException : public std::runtime_error
223 {
224 public:
226 std::runtime_error( "Provider Module Directory Undefined Exception" ) { };
227 };
228 class ProviderModuleUndefinedException : public std::runtime_error
229 {
230 public:
232 std::runtime_error( "Provider Module Undefined Exception" ) { };
233 };
234 class ProviderModuleInvalidException : public std::runtime_error
235 {
236 public:
238 std::runtime_error( "Provider Module Invalid Exception" ) { };
239 };
240 class ProviderModuleVersionException : public std::runtime_error
241 {
242 public:
244 std::runtime_error( "Provider Module Version Exception" ) { };
245 };
246
247 } // end tsdb namespace
248
249} // end tom namespace
250
251#endif
Definition string.hpp:15
Definition module_loader.hpp:16
Definition logger.hpp:59
Definition module_loader.hpp:44
Definition observation.hpp:13
Definition engine.hpp:166
Definition engine.hpp:75
static engine & Instance()
Definition engine.cpp:42
provider & get_provider(const char *name)
Definition engine.hpp:152
provider & get_provider()
Definition engine.cpp:131
const repository_meta_data_vec & get_repositories_meta_data() const
Definition engine.cpp:92
static const char * version()
Definition engine.cpp:97
session_sptr get_session()
Definition engine.cpp:119
session_sptr get_session(const char *name)
Definition engine.hpp:128
Definition provider.hpp:58
Definition engine.hpp:33
const tom::string & description() const
Definition engine.hpp:58
const tom::string & module() const
Definition engine.hpp:52
const tom::string & name() const
Definition engine.hpp:46
Definition screening-manager.hpp:140
Definition value_types.hpp:96
Definition xml_config.hpp:36