DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::oksconflibs::OksConfiguration Class Reference

#include <OksConfiguration.hpp>

Inheritance diagram for dunedaq::oksconflibs::OksConfiguration:
[legend]
Collaboration diagram for dunedaq::oksconflibs::OksConfiguration:
[legend]

Public Types

typedef std::map< std::string, std::set< std::string > > SMap
Public Types inherited from dunedaq::conffwk::ConfigurationImpl
typedef void(* notify) (std::vector< ConfigurationChange * > &changes, Configuration *)
 Callback to notify database changes.
typedef void(* pre_notify) (Configuration *)
 Callback to pre-notify database changes.

Public Member Functions

 OksConfiguration () noexcept
virtual ~OksConfiguration ()
virtual bool test_object (const std::string &class_name, const std::string &name, unsigned long rlevel, const std::vector< std::string > *rclasses)
 Test object existence (used by Python binding).
virtual void get (const std::string &class_name, const std::string &name, conffwk::ConfigObject &object, unsigned long rlevel, const std::vector< std::string > *rclasses)
 Get object of class by id.
virtual void get (const std::string &class_name, std::vector< conffwk::ConfigObject > &objects, const std::string &query, unsigned long rlevel, const std::vector< std::string > *rclasses)
virtual void get (const conffwk::ConfigObject &obj_from, const std::string &query, std::vector< conffwk::ConfigObject > &objects, unsigned long rlevel, const std::vector< std::string > *rclasses)
virtual conffwk::class_tget (const std::string &class_name, bool direct_only)
 Get description of class in accordance with parameters.
virtual void get_superclasses (conffwk::fmap< conffwk::fset > &schema)
 Get inheritance hierarchy.
virtual void create (const std::string &at, const std::string &class_name, const std::string &id, conffwk::ConfigObject &object)
 Create object of class by id at given file.
virtual void create (const conffwk::ConfigObject &at, const std::string &class_name, const std::string &id, conffwk::ConfigObject &object)
 Create object of class by id at file identified by object 'at'.
virtual void destroy (conffwk::ConfigObject &object)
 Destroy object of class by id.
virtual void open_db (const std::string &db_name)
 Open database implementation in accordance with given name.
virtual void close_db ()
 Close database implementation.
virtual bool loaded () const noexcept
 Check if a database is loaded.
virtual void create (const std::string &db_name, const std::list< std::string > &includes)
 Create database.
virtual bool is_writable (const std::string &db_name)
 Return write access status.
virtual void add_include (const std::string &db_name, const std::string &include)
 Add include file.
virtual void remove_include (const std::string &db_name, const std::string &include)
 Remove include file.
virtual void get_includes (const std::string &db_name, std::list< std::string > &includes) const
 Get included files.
virtual void get_updated_dbs (std::list< std::string > &dbs) const
 Get uncommitted files.
virtual void set_commit_credentials (const std::string &user, const std::string &password)
 Set commit credentials.
virtual void commit (const std::string &why)
 Commit database changes.
virtual void abort ()
 Abort database changes.
virtual void prefetch_all_data ()
 Prefetch all data into client cache.
virtual std::vector< dunedaq::conffwk::Versionget_changes ()
 Get newly available versions.
virtual std::vector< dunedaq::conffwk::Versionget_versions (const std::string &since, const std::string &until, dunedaq::conffwk::Version::QueryType type, bool skip_irrelevant)
 Get archived versions.
virtual void subscribe (const std::set< std::string > &class_names, const SMap &objs, ConfigurationImpl::notify cb, ConfigurationImpl::pre_notify pre_cb)
virtual void unsubscribe ()
 Remove subscription on database changes.
virtual void print_profiling_info () noexcept
 Print implementation specific profiling information.
const oks::OksKernelget_oks_kernel () const
Public Member Functions inherited from dunedaq::conffwk::ConfigurationImpl
 ConfigurationImpl () noexcept
 The constructor.
virtual ~ConfigurationImpl ()
 Virtual destructor.
virtual void get (const std::string &class_name, std::vector< ConfigObject > &objects, const std::string &query, unsigned long rlevel, const std::vector< std::string > *rclasses)=0
 Get objects of class according to query.
virtual void get (const ConfigObject &obj_from, const std::string &query, std::vector< ConfigObject > &objects, unsigned long rlevel, const std::vector< std::string > *rclasses)=0
 Get objects according to path.
virtual void subscribe (const std::set< std::string > &class_names, const std::map< std::string, std::set< std::string > > &objs, notify cb, pre_notify pre_cb)=0
 Subscribe on database changes.
void print_cache_info () noexcept
 Print profiling information about objects in cache.
void set (Configuration *db) noexcept
 set configuration object
void rename_impl_object (const std::string *class_name, const std::string &old_id, const std::string &new_id) noexcept
 rename object in cache

Protected Member Functions

void create (oks::OksFile *at, const std::string &class_name, const std::string &id, conffwk::ConfigObject &object)
void init_env ()
OksConfigObjectnew_object (oks::OksObject *obj) noexcept
void subscribe ()
Protected Member Functions inherited from dunedaq::conffwk::ConfigurationImpl
ConfigObjectImplget_impl_object (const std::string &class_name, const std::string &id) const noexcept
 get object from cache
void put_impl_object (const std::string &class_name, const std::string &id, ConfigObjectImpl *obj) noexcept
 put object to cache
template<class T, class OBJ>
T * insert_object (OBJ &obj, const std::string &id, const std::string &class_name) noexcept
 insert new object (update cache or create-and-insert)
void clean () noexcept
 clean cache (e.g. to be used by destructor)
std::mutex & get_conf_impl_mutex () const
 Is required by reload methods.

Static Protected Member Functions

static void create_notify (oks::OksObject *, void *) noexcept
static void change_notify (oks::OksObject *, void *) noexcept
static void delete_notify (oks::OksObject *, void *) noexcept

Protected Attributes

oks::OksKernelm_kernel
conffwk::ConfigurationImpl::notify m_fn
conffwk::ConfigurationImpl::pre_notify m_pre_fn
std::set< std::string > m_class_names
SMap m_objects
bool m_oks_kernel_silence
bool m_oks_kernel_no_repo
std::list< oks::OksObject * > m_created
std::set< oks::OksObject * > m_modified
std::map< std::string, std::set< std::string > > m_removed
OksConfigurationCheckDBm_check_db_obj
std::thread * m_check_db_thread
std::string m_user
std::string m_password
std::set< oks::OksFile * > m_created_files
unsigned int m_repo_error_count
Protected Attributes inherited from dunedaq::conffwk::ConfigurationImpl
Configurationm_conf
 Configuration pointer is needed for notification on changes, e.g. in case of subscription or an object deletion.

Private Member Functions

virtual void check_db ()
void close_database (bool unsubscribe)

Friends

class OksConfigObject
struct OksConfigurationCheckDB
class ResubscribeGuard

Detailed Description

Definition at line 39 of file OksConfiguration.hpp.

Member Typedef Documentation

◆ SMap

typedef std::map< std::string , std::set<std::string> > dunedaq::oksconflibs::OksConfiguration::SMap

Definition at line 50 of file OksConfiguration.hpp.

Constructor & Destructor Documentation

◆ OksConfiguration()

dunedaq::oksconflibs::OksConfiguration::OksConfiguration ( )
inlinenoexcept

◆ ~OksConfiguration()

virtual dunedaq::oksconflibs::OksConfiguration::~OksConfiguration ( )
inlinevirtual

Definition at line 48 of file OksConfiguration.hpp.

48{ close_db(); }
virtual void close_db()
Close database implementation.

Member Function Documentation

◆ abort()

void dunedaq::oksconflibs::OksConfiguration::abort ( )
virtual

Abort database changes.

Implements dunedaq::conffwk::ConfigurationImpl.

Definition at line 466 of file OksConfiguration.cpp.

467{
468 // unsubscribe changes; if there are any, re-subscribe on return from this method
469
470 ResubscribeGuard __rg__(*this);
471
472
473 // destroy any newly created files
474 for (const auto& i : m_created_files)
475 {
476 const std::string file_name(i->get_full_file_name());
477
478 TLOG_DEBUG(1) << "destroy created file \'" << file_name << "\')" ;
479 m_kernel->close_data(i);
480
481 if (int result = unlink(file_name.c_str()))
482 {
483 std::ostringstream text;
484 text << "abort changes failed since cannot erase created file \'" << file_name << "\'; unlink failed with code " << result << ": " << dunedaq::oks::strerror(errno);
485 throw(dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
486 }
487 }
488
489 m_created_files.clear();
490
491
492
493 // add to "updated" any modified file
494 std::set<OksFile *> updated;
495
496 for (const auto& i : m_kernel->data_files())
497 {
498 if (i.second->is_updated())
499 {
500 updated.insert(i.second);
501 TLOG_DEBUG(2) << "file \'" << i.second->get_full_file_name() << "\' was updated, to be reloaded..." ;
502 }
503 }
504
505 if (!m_kernel->get_user_repository_root().empty())
506 {
507 std::set<OksFile *> mfs, rfs;
508 try
509 {
510 m_kernel->get_modified_files(mfs, rfs, "origin/master");
511 }
512 catch (const oks::exception& ex)
513 {
514 std::ostringstream text;
515 text << "failed to get differences between revisions " << m_kernel->get_repository_version() << " and origin/master: " << ex.what() << '\n';
516 throw(dunedaq::conffwk::Generic(ERS_HERE, text.str().c_str(), ex));
517 }
518 }
519
520 if (!updated.empty())
521 {
522 try
523 {
524 if (!m_kernel->get_user_repository_root().empty())
525 m_kernel->update_repository("origin/master", OksKernel::RepositoryUpdateType::DiscardChanges);
526
527 m_kernel->reload_data(updated);
528 }
529 catch (oks::exception & ex)
530 {
531 throw(dunedaq::conffwk::Generic(ERS_HERE, "cannot reload updated data files", ex));
532 }
533 catch (...)
534 {
535 throw(dunedaq::conffwk::Generic(ERS_HERE, "cannot reload updated data files"));
536 }
537 }
538}
#define ERS_HERE
std::set< oks::OksFile * > m_created_files
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112
const std::string strerror(int error)
Convert C error number to string.
Definition kernel.cpp:119

◆ add_include()

void OksConfiguration::add_include ( const std::string & db_name,
const std::string & include )
virtual

Add include file.

Implements dunedaq::conffwk::ConfigurationImpl.

Definition at line 1157 of file OksConfiguration.cpp.

1158{
1159 if(OksFile * h = m_kernel->find_data_file(db_name)) {
1160 try {
1161 h->add_include_file(include);
1162 }
1163 catch(dunedaq::conffwk::Generic& ex) {
1164 throw ( dunedaq::conffwk::Generic( ERS_HERE, mk_add_include_error_text(db_name, include).c_str() ), ex );
1165 }
1166 catch (oks::exception & ex) {
1167 throw ( dunedaq::conffwk::Generic( ERS_HERE, mk_add_include_error_text(db_name, include, ex.what()).c_str() ) );
1168 }
1169 catch (...) {
1170 throw ( dunedaq::conffwk::Generic( ERS_HERE, mk_add_include_error_text(db_name, include).c_str() ) );
1171 }
1172 }
1173 else {
1174 throw ( dunedaq::conffwk::Generic( ERS_HERE, mk_no_file_error_text(db_name).c_str() ) );
1175 }
1176}
static std::string mk_no_file_error_text(const std::string &db)
static std::string mk_add_include_error_text(const std::string &db, const std::string &include, const char *error=nullptr)

◆ change_notify()

void OksConfiguration::change_notify ( oks::OksObject * o,
void * p )
staticprotectednoexcept

Definition at line 937 of file OksConfiguration.cpp.

938{
939 reinterpret_cast<OksConfiguration *>(p)->m_modified.insert(o);
940}
std::set< oks::OksObject * > m_modified

◆ check_db()

void OksConfiguration::check_db ( )
privatevirtual

Definition at line 1249 of file OksConfiguration.cpp.

1250{
1251 static const std::string version("origin/master");
1252
1253 if (m_fn)
1254 {
1255 std::set<OksFile *> ufs, rfs;
1256
1257 try
1258 {
1259 m_kernel->get_modified_files(ufs, rfs, version);
1261 }
1262 catch(const oks::RepositoryOperationFailed& ex)
1263 {
1264 std::ostringstream text;
1265 text << "cannot get modified repository files (attempt " << ++m_repo_error_count << "): " << ex.what();
1266 ers::error(dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
1267 }
1268 catch(const oks::exception& ex)
1269 {
1270 std::ostringstream text;
1271 text << "cannot get modified files: " << ex.what();
1272 throw(dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
1273 }
1274
1275 for (const auto& x : ufs)
1276 {
1277 if (x->get_oks_format() == "schema")
1278 {
1279 std::ostringstream text;
1280 text << "reload of schema files is not supported (\'" << x->get_well_formed_name() << "\')";
1281 throw(dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
1282 }
1283 }
1284
1285 if (ufs.empty() == false)
1286 {
1287 InheritanceData inheritance(*m_kernel);
1288
1289 m_kernel->subscribe_create_object(create_notify, reinterpret_cast<void *>(this));
1290 m_kernel->subscribe_change_object(change_notify, reinterpret_cast<void *>(this));
1291 m_kernel->subscribe_delete_object(delete_notify, reinterpret_cast<void *>(this));
1292
1293 (*m_pre_fn)(m_conf);
1294
1295 try
1296 {
1297 if(!m_kernel->get_user_repository_root().empty())
1298 m_kernel->update_repository(version, OksKernel::RepositoryUpdateType::DiscardChanges);
1299
1300 m_kernel->reload_data(ufs, false);
1301 }
1302 catch (oks::exception & ex)
1303 {
1304 close_database(false);
1305 m_fn = 0;
1306 std::ostringstream text;
1307 text << "failed to reload updated files:\n" << ex.what();
1308 throw(dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
1309 }
1310 catch (...)
1311 {
1312 close_database(false);
1313 m_fn = 0;
1314 throw ( dunedaq::conffwk::Generic( ERS_HERE, "failed to reload updated files" ) );
1315 }
1316
1317
1318 m_kernel->subscribe_create_object(0, 0);
1319 m_kernel->subscribe_change_object(0, 0);
1320 m_kernel->subscribe_delete_object(0, 0);
1321
1322 std::vector<conffwk::ConfigurationChange *> changes;
1323
1324 {
1325 for (auto& i : m_created)
1326 {
1327 check(changes, inheritance, m_class_names, m_objects, i->GetClass()->get_name(), i->GetId(), '+');
1328
1329 std::set<OksObject *>::iterator j = m_modified.find(i);
1330 if (j != m_modified.end())
1331 {
1332 TLOG_DEBUG(1) << "created object " << i << " appears in \'modified\' set, removing..." ;
1333 m_modified.erase(j);
1334 }
1335 }
1336 }
1337
1338 {
1339 for (auto& i : m_modified)
1340 {
1341 if (m_kernel->is_dangling(i))
1342 {
1343 TLOG_DEBUG(1) << "object " << (void *)(i) << " is dangling, ignore..." ;
1344 }
1345 else
1346 {
1347 check(changes, inheritance, m_class_names, m_objects, i->GetClass()->get_name(), i->GetId(), '~');
1348 }
1349 }
1350 }
1351
1352 {
1353 for (auto& i : m_removed)
1354 {
1355 for (auto& j : i.second)
1356 {
1357 check(changes, inheritance, m_class_names, m_objects, i.first, j, '-');
1358 }
1359 }
1360 }
1361
1362 if (!changes.empty())
1363 {
1364 (*m_fn)(changes, m_conf);
1366 }
1367
1368 m_created.clear();
1369 m_modified.clear();
1370 m_removed.clear();
1371 }
1372 }
1373 else
1374 {
1375 throw(dunedaq::conffwk::Generic( ERS_HERE, "no subscription has been done" ) );
1376 }
1377}
static void check(std::vector< conffwk::ConfigurationChange * > &changes, const InheritanceData &inheritance, const std::set< std::string > &class_names, const OksConfiguration::SMap &objects, const std::string &obj_class, const std::string &obj_id, const char action)
static void clear(std::vector< ConfigurationChange * > &changes)
Helper method to clear vector of changes (pointers).
Configuration * m_conf
Configuration pointer is needed for notification on changes, e.g. in case of subscription or an objec...
static void change_notify(oks::OksObject *, void *) noexcept
static void delete_notify(oks::OksObject *, void *) noexcept
static void create_notify(oks::OksObject *, void *) noexcept
std::list< oks::OksObject * > m_created
std::map< std::string, std::set< std::string > > m_removed
void error(const Issue &issue)
Definition ers.hpp:92

◆ close_database()

void OksConfiguration::close_database ( bool unsubscribe)
private

Definition at line 234 of file OksConfiguration.cpp.

235{
236 clean(); // clean implementation cache
237
238 if(m_kernel) try {
239 if(m_check_db_obj) {
240 if(call_unsubscribe)
241 unsubscribe();
242 else
243 m_check_db_obj->m_run = false;
244 }
245
246 m_kernel->subscribe_create_object(0, 0);
247 m_kernel->subscribe_change_object(0, 0);
248 m_kernel->subscribe_delete_object(0, 0);
249
250 m_kernel->close_all_data();
251 m_kernel->close_all_schema();
252
253 delete m_kernel;
254 m_kernel = 0;
255 }
256 catch(oksconflibs::Exception& ex) {
257 throw ( dunedaq::conffwk::Generic( ERS_HERE, "failed to close database", ex ) );
258 }
259 catch(std::exception& ex) {
260 throw ( dunedaq::conffwk::Generic( ERS_HERE, "failed to close database", ex ) );
261 }
262}
void clean() noexcept
clean cache (e.g. to be used by destructor)
virtual void unsubscribe()
Remove subscription on database changes.

◆ close_db()

virtual void dunedaq::oksconflibs::OksConfiguration::close_db ( )
inlinevirtual

Close database implementation.

Implements dunedaq::conffwk::ConfigurationImpl.

Definition at line 66 of file OksConfiguration.hpp.

66{ close_database(true); }

◆ commit()

void OksConfiguration::commit ( const std::string & log_message)
virtual

Commit database changes.

Implements dunedaq::conffwk::ConfigurationImpl.

Definition at line 372 of file OksConfiguration.cpp.

373{
374 try
375 {
376 m_kernel->set_active_data(nullptr);
377 }
378 catch (oks::exception &ex)
379 {
380 throw(dunedaq::conffwk::Generic( ERS_HERE, ex.what()));
381 }
382
383 const bool commit2repo(!m_kernel->get_user_repository_root().empty() && m_kernel->is_user_repository_created());
384 unsigned int count(0);
385
386 for (const auto &i : m_kernel->data_files())
387 {
388 OksFile *file_h = i.second;
389
390 if (file_h->is_updated())
391 {
392 const OksFile::FileStatus file_status = file_h->get_status_of_file();
393
394 if (file_status == OksFile::FileModified)
395 throw_update_exception(file_h, "save", "it was externally modified");
396 else if (file_status == OksFile::FileRemoved)
397 throw_update_exception(file_h, "save", "it was externally removed");
398
399 try
400 {
401 if (!commit2repo && !log_message.empty())
402 file_h->add_comment(log_message, m_kernel->get_user_name());
403
404 m_kernel->save_data(file_h);
405
406 count++;
407 }
408 catch (oks::exception &ex)
409 {
410 std::ostringstream text;
411 text << "cannot save updated data file \'" << *(i.first) << "\':\n" << ex.what();
412 throw(dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str()));
413 }
414 }
415 }
416
417 if (commit2repo && count)
418 {
419 try
420 {
421 m_kernel->commit_repository(log_message);
422 }
423 catch (oks::exception &ex)
424 {
425 throw(dunedaq::conffwk::Generic( ERS_HERE, ex.what()));
426 }
427 }
428
429 m_created_files.clear();
430}
static void throw_update_exception(const OksFile *file_h, const char *action, const char *reason)
void add_comment(const std::string &text, const std::string &author)
Add new comment to file.
Definition file.cpp:674
bool is_updated() const
Return update status of OKS file.
Definition file.hpp:629
FileStatus get_status_of_file() const
Return update status of file.
Definition file.cpp:1418

◆ create() [1/4]

void OksConfiguration::create ( const conffwk::ConfigObject & at,
const std::string & class_name,
const std::string & id,
conffwk::ConfigObject & object )
virtual

Create object of class by id at file identified by object 'at'.

Implements dunedaq::conffwk::ConfigurationImpl.

Definition at line 925 of file OksConfiguration.cpp.

926{
927 create((static_cast<const OksConfigObject *>(at.implementation()))->m_obj->get_file(), class_name, id, object);
928}
virtual void create(const std::string &at, const std::string &class_name, const std::string &id, conffwk::ConfigObject &object)
Create object of class by id at given file.

◆ create() [2/4]

void OksConfiguration::create ( const std::string & at,
const std::string & class_name,
const std::string & id,
conffwk::ConfigObject & object )
virtual

Create object of class by id at given file.

Implements dunedaq::conffwk::ConfigurationImpl.

Definition at line 908 of file OksConfiguration.cpp.

909{
910 if(at.empty() == true) {
911 throw ( dunedaq::conffwk::Generic( ERS_HERE, "parameter \'at\' (i.e. filename) cannot be empty" ) );
912 }
913
914 if(OksFile * h = m_kernel->find_data_file(at)) {
915 return create(h, class_name, id, object);
916 }
917 else {
918 std::ostringstream text;
919 text << "file \"" << at << "\" is not loaded";
920 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
921 }
922}

◆ create() [3/4]

void OksConfiguration::create ( const std::string & db_name,
const std::list< std::string > & includes )
virtual

Create database.

Implements dunedaq::conffwk::ConfigurationImpl.

Definition at line 266 of file OksConfiguration.cpp.

267{
268 // create OKS kernel if it was not created
269
270 if (m_kernel == nullptr)
271 {
272 if (is_repo_name(db_name) == false)
274
275 m_kernel = new OksKernel(m_oks_kernel_silence, false, false, !m_oks_kernel_no_repo);
276 }
277
278
279 // create new data file
280
281 try {
282 OksFile * h = m_kernel->new_data(db_name);
283 m_created_files.insert(h);
284
285 // add includes
286
287 for(std::list<std::string>::const_iterator i = includes.begin(); i != includes.end(); ++i) {
288 try {
289 h->add_include_file(*i);
290 }
291 catch (oks::exception & e) {
292 std::ostringstream text;
293 text << "cannot add and load include file \'" << *i << "\' to \'" << db_name << "\':\n" << e.what();
294 close_db();
295 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
296 }
297 catch (...) {
298 std::ostringstream text;
299 text << "cannot add and load include file \'" << *i << "\' to \'" << db_name << '\'';
300 close_db();
301 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
302 }
303 }
304
305 m_kernel->bind_objects();
306 }
307 catch (oks::exception & ex) {
308 close_db();
309 std::ostringstream text;
310 text << "cannot create new data file \'" << db_name << "\': " << ex.what();
311 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
312 }
313 catch (dunedaq::conffwk::Generic & ex) {
314 close_db();
315 std::ostringstream text;
316 text << "cannot create new data file \'" << db_name << "\'";
317 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str(), ex ) );
318 }
319 catch (...) {
320 close_db();
321 std::ostringstream text;
322 text << "cannot create new data file \'" << db_name << '\'';
323 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
324 }
325}
bool is_repo_name(const std::string &name)
void add_include_file(const std::string &name)
Add include file.
Definition file.cpp:1199

◆ create() [4/4]

void OksConfiguration::create ( oks::OksFile * at,
const std::string & class_name,
const std::string & id,
conffwk::ConfigObject & object )
protected

Definition at line 868 of file OksConfiguration.cpp.

869{
870 try {
871 m_kernel->set_active_data(at);
872 }
873 catch(oks::exception& ex) {
874 throw ( dunedaq::conffwk::Generic( ERS_HERE, ex.what()) );
875 }
876
877 OksClass * c = m_kernel->find_class(class_name);
878
879 if(c == nullptr) {
880 std::ostringstream text;
881 text << "cannot find class \"" << class_name << '\"';
882 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
883 }
884 else if(id.empty() == false) {
885 if(OksObject * obj = c->get_object(id)) {
886 std::ostringstream text;
887 text << "object \"" << id << '@' << class_name << "\" already exists in file \"" << obj->get_file()->get_full_file_name() << '\"';
888 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
889 }
890 }
891
892 if(m_kernel->get_test_duplicated_objects_via_inheritance_mode() == false)
893 {
894 m_kernel->set_test_duplicated_objects_via_inheritance_mode(true);
895 m_kernel->registrate_all_classes();
896 }
897
898 try {
899 object = new_object(new OksObject(c, id.c_str()));
900 }
901 catch(oks::exception& ex)
902 {
903 throw ( dunedaq::conffwk::Generic( ERS_HERE, "cannot create configuration object", ex ) );
904 }
905}
OksConfigObject * new_object(oks::OksObject *obj) noexcept
msgpack::object obj

◆ create_notify()

void OksConfiguration::create_notify ( oks::OksObject * o,
void * p )
staticprotectednoexcept

Definition at line 931 of file OksConfiguration.cpp.

932{
933 reinterpret_cast<OksConfiguration *>(p)->m_created.push_back(o);
934}

◆ delete_notify()

void OksConfiguration::delete_notify ( oks::OksObject * o,
void * p )
staticprotectednoexcept

Definition at line 943 of file OksConfiguration.cpp.

944{
945 reinterpret_cast<OksConfiguration *>(p)->m_removed[o->GetClass()->get_name()].insert(o->GetId());
946}

◆ destroy()

void OksConfiguration::destroy ( conffwk::ConfigObject & object)
virtual

Destroy object of class by id.

Implements dunedaq::conffwk::ConfigurationImpl.

Definition at line 1084 of file OksConfiguration.cpp.

1085{
1086 OksObject * o((static_cast<const OksConfigObject *>(obj.implementation()))->m_obj);
1087
1088 DestroyGuard2 dg2(m_removed); // => on exit from method, call m_removed.clear();
1089
1090 InheritanceData inheritance(*m_kernel);
1091
1092 try {
1093 m_kernel->subscribe_delete_object(delete_notify, reinterpret_cast<void *>(this));
1094 DestroyGuard1 dg1(*m_kernel); // => on exit from try block, call m_kernel->subscribe_delete_object(0, 0);
1096 }
1097 catch(oks::exception& ex) {
1098 throw ( dunedaq::conffwk::Generic( ERS_HERE, ex.what()) );
1099 }
1100
1101 if(m_conf) {
1102 std::vector<conffwk::ConfigurationChange *> changes;
1103
1104 for(SMap::iterator i = m_removed.begin(); i != m_removed.end(); ++i) {
1105 for(std::set<std::string>::const_iterator j = i->second.begin(); j != i->second.end(); ++j) {
1106 check(changes, inheritance, m_class_names, m_objects, i->first, *j, '-');
1107 }
1108 }
1109
1110 if(!changes.empty()) {
1111 m_conf->update_cache(changes);
1113 }
1114 }
1115}
static void destroy(OksObject *obj, bool fast=false)
Destroy OKS object.
Definition object.cpp:1306

◆ get() [1/4]

void OksConfiguration::get ( const conffwk::ConfigObject & obj_from,
const std::string & query,
std::vector< conffwk::ConfigObject > & objects,
unsigned long rlevel,
const std::vector< std::string > * rclasses )
virtual

Definition at line 717 of file OksConfiguration.cpp.

718{
719 if(obj_from.is_null()) {
720 throw ( dunedaq::conffwk::Generic( ERS_HERE, "parameter \'obj_from\' is (null)" ) );
721 }
722
723 OksObject * o = (static_cast<const OksConfigObject *>(obj_from.implementation()))->m_obj;
724
725 try {
726 oks::QueryPath q(query, *m_kernel);
727 if(OksObject::List * objs = o->find_path(q)) {
728 for(OksObject::List::iterator i = objs->begin(); i != objs->end(); ++i) {
729 objects.push_back(new_object(*i));
730 }
731 delete objs;
732 }
733 }
734 catch ( oks::bad_query_syntax& e ) {
735 std::ostringstream text;
736 text << "bad path-query \"" << query << "\" to object " << o;
737 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
738 }
739}
std::list< OksObject * > List
Definition object.hpp:880
OksObject::List * find_path(const oks::QueryPath &query) const
Definition query.cpp:941

◆ get() [2/4]

dunedaq::conffwk::class_t * OksConfiguration::get ( const std::string & class_name,
bool direct_only )
virtual

Get description of class in accordance with parameters.

Implements dunedaq::conffwk::ConfigurationImpl.

Definition at line 743 of file OksConfiguration.cpp.

744{
745 OksClass * c = m_kernel->find_class(class_name);
746
747 if(c == 0) {
748 throw dunedaq::conffwk::NotFound(ERS_HERE, "class", class_name.c_str());
749 }
750
751 dunedaq::conffwk::class_t * d = new dunedaq::conffwk::class_t(c->get_name(), c->get_description(), c->get_file()->get_full_file_name(), c->get_is_abstract());
752
753 if(direct_only) {
754 if(const std::list<std::string *> * classes = c->direct_super_classes()) {
755 for(const auto& i : *classes) {
756 const_cast< std::vector<std::string>& >(d->p_superclasses).push_back(*i);
757 }
758 }
759 }
760 else {
761 if(const OksClass::FList * classes = c->all_super_classes()) {
762 for(const auto& i : *classes) {
763 const_cast< std::vector<std::string>& >(d->p_superclasses).push_back(i->get_name());
764 }
765 }
766 }
767
768 if(const OksClass::FList * subclasses = c->all_sub_classes()) {
769 for(const auto& i : *subclasses) {
770 if(direct_only == false || i->has_direct_super_class(c->get_name()) == true) {
771 const_cast< std::vector<std::string>& >(d->p_subclasses).push_back(i->get_name());
772 }
773 }
774 }
775
776 if(const std::list<OksAttribute *> * attrs = (direct_only ? c->direct_attributes() : c->all_attributes())) {
777 for(const auto& i : *attrs) {
778 OksAttribute::Format format = i->get_format();
779 OksData::Type type = i->get_data_type();
780
781 const_cast< std::vector<dunedaq::conffwk::attribute_t>& >(d->p_attributes).push_back(
782 dunedaq::conffwk::attribute_t(
783 i->get_name(),
784 (
801 ),
802 i->get_range(),
803 (
804 i->is_integer() == false ? dunedaq::conffwk::na_int_format :
805 (
809 )
810 ),
811 i->get_is_no_null(),
812 i->get_is_multi_values(),
813 i->get_init_value(),
814 i->get_description()
815 )
816 );
817
818 }
819 }
820
821 if(const std::list<OksRelationship *> * rels = (direct_only ? c->direct_relationships() : c->all_relationships())) {
822 for(const auto& i : *rels) {
823 const_cast< std::vector<dunedaq::conffwk::relationship_t>& >(d->p_relationships).push_back(
824 dunedaq::conffwk::relationship_t(
825 i->get_name(),
826 i->get_type(),
827 (i->get_low_cardinality_constraint() == OksRelationship::Zero),
828 (i->get_high_cardinality_constraint() == OksRelationship::Many),
829 i->get_is_composite(),
830 i->get_description()
831 )
832 );
833 }
834 }
835
836 return d;
837}
std::list< OksClass *, boost::fast_pool_allocator< OksClass * > > FList
Definition class.hpp:240

◆ get() [3/4]

void dunedaq::oksconflibs::OksConfiguration::get ( const std::string & class_name,
const std::string & id,
conffwk::ConfigObject & object,
unsigned long rlevel,
const std::vector< std::string > * rclasses )
virtual

Get object of class by id.

Implements dunedaq::conffwk::ConfigurationImpl.

Definition at line 643 of file OksConfiguration.cpp.

645{
646 if (OksClass * cl = m_kernel->find_class(class_name))
647 {
648 OksObject * obj = cl->get_object(name);
649 if (obj == nullptr)
650 {
651 // try all subclasses
652 if (const OksClass::FList *subclasses = cl->all_sub_classes())
653 {
654 for (const auto& it : *subclasses)
655 {
656 obj = it->get_object(name);
657 if (obj != nullptr)
658 break;
659 }
660 }
661 if (obj == nullptr)
662 {
663 const std::string id(name + '@' + class_name);
664 throw dunedaq::conffwk::NotFound(ERS_HERE, "object", id.c_str());
665 }
666 }
667
668 object = new_object(obj);
669 }
670 else
671 {
672 throw dunedaq::conffwk::NotFound(ERS_HERE, "class", class_name.c_str());
673 }
674}

◆ get() [4/4]

void OksConfiguration::get ( const std::string & class_name,
std::vector< conffwk::ConfigObject > & objects,
const std::string & query,
unsigned long rlevel,
const std::vector< std::string > * rclasses )
virtual

Definition at line 677 of file OksConfiguration.cpp.

678{
679 if(OksClass * cl = m_kernel->find_class(class_name)) {
680 objects.clear();
681
682 OksObject::List * objs = 0;
683
684 if(query.empty()) {
685 objs = cl->create_list_of_all_objects();
686 }
687 else {
688 try {
689 std::unique_ptr<OksQuery> qe(new OksQuery(cl, query.c_str()));
690 if(qe->good() == false) {
691 std::ostringstream text;
692 text << "bad query syntax \"" << query << "\" in scope of class \"" << class_name << '\"';
693 throw dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str());
694 }
695 objs = cl->execute_query(qe.get()); // FIXME: check .get()
696 }
697 catch(oks::exception& ex) {
698 std::ostringstream text;
699 text << "failed to execute query:\n" << ex.what();
700 throw dunedaq::conffwk::Generic(ERS_HERE, text.str().c_str());
701 }
702 }
703
704 if(objs) {
705 for(OksObject::List::iterator i = objs->begin(); i != objs->end(); ++i) {
706 objects.push_back(new_object(*i));
707 }
708 delete objs;
709 }
710 }
711 else {
712 throw dunedaq::conffwk::NotFound(ERS_HERE, "class", class_name.c_str());
713 }
714}

◆ get_changes()

std::vector< dunedaq::conffwk::Version > dunedaq::oksconflibs::OksConfiguration::get_changes ( )
virtual

Get newly available versions.

Implements dunedaq::conffwk::ConfigurationImpl.

Definition at line 554 of file OksConfiguration.cpp.

555{
556 if (!m_kernel->get_repository_root().empty())
557 {
558 try
559 {
560 return oks2config(m_kernel->get_repository_versions_by_hash(true, m_kernel->get_repository_version()));
561 }
562 catch (const oks::exception& ex)
563 {
564 throw(dunedaq::conffwk::Generic(ERS_HERE, "cannot get new versions", ex));
565 }
566 }
567 else
568 {
569 std::vector<dunedaq::conffwk::Version> out;
570
571 std::set<OksFile *> oks_files;
572 m_kernel->get_modified_files(oks_files, oks_files, "");
573
574 if (!oks_files.empty())
575 {
576 std::vector<std::string> files;
577
578 for(const auto& x : oks_files)
579 files.push_back(x->get_well_formed_name());
580
581 out.emplace_back("", "", 0, "", files);
582 }
583
584 return out;
585 }
586}
static std::vector< dunedaq::conffwk::Version > oks2config(const std::vector< OksRepositoryVersion > &in)
FELIX Initialization std::string initerror FELIX queue timed out

◆ get_includes()

void OksConfiguration::get_includes ( const std::string & db_name,
std::list< std::string > & includes ) const
virtual

Get included files.

Implements dunedaq::conffwk::ConfigurationImpl.

Definition at line 1221 of file OksConfiguration.cpp.

1222{
1223 if (db_name.empty())
1224 {
1225 for (auto& i : m_kernel->data_files())
1226 {
1227 if(i.second->get_parent() == nullptr)
1228 includes.push_back(*i.first);
1229 }
1230 }
1231 else
1232 {
1233 if (OksFile * h = m_kernel->find_data_file(db_name))
1234 {
1235 for (auto& i : h->get_include_files())
1236 {
1237 includes.push_back(i);
1238 }
1239 }
1240 else
1241 {
1242 throw(dunedaq::conffwk::Generic( ERS_HERE, mk_no_file_error_text(db_name).c_str() ) );
1243 }
1244 }
1245}

◆ get_oks_kernel()

const oks::OksKernel & dunedaq::oksconflibs::OksConfiguration::get_oks_kernel ( ) const
inline

Definition at line 100 of file OksConfiguration.hpp.

100{ return *m_kernel; } // required by Java oksconflibs

◆ get_superclasses()

void OksConfiguration::get_superclasses ( conffwk::fmap< conffwk::fset > & schema)
virtual

Get inheritance hierarchy.

Implements dunedaq::conffwk::ConfigurationImpl.

Definition at line 840 of file OksConfiguration.cpp.

841{
842 schema.clear();
843
844 if(!m_kernel) {
845 return; // throw ( dunedaq::conffwk::Generic( ERS_HERE, "database is not loaded" ) );
846 }
847
848 schema.reserve(m_kernel->classes().size() * 3);
849
850 for(OksClass::Map::const_iterator i = m_kernel->classes().begin(); i != m_kernel->classes().end(); ++i) {
851 if(const OksClass::FList * scl = i->second->all_super_classes()) {
852 const std::string* name = &conffwk::DalFactory::instance().get_known_class_name_ref(i->second->get_name());
853
854 auto& subclasses = schema[name];
855
856 if(!scl->empty()) {
857 subclasses.reserve(scl->size() * 3);
858 for(OksClass::FList::const_iterator j = scl->begin(); j != scl->end(); ++j) {
859 subclasses.insert(&conffwk::DalFactory::instance().get_known_class_name_ref((*j)->get_name()));
860 }
861 }
862 }
863 }
864}

◆ get_updated_dbs()

void OksConfiguration::get_updated_dbs ( std::list< std::string > & dbs) const
virtual

Get uncommitted files.

Implements dunedaq::conffwk::ConfigurationImpl.

Definition at line 347 of file OksConfiguration.cpp.

348{
349 for (const auto& i : m_kernel->data_files())
350 {
351 if (i.second->is_updated())
352 dbs.push_back(i.second->get_full_file_name());
353 }
354}

◆ get_versions()

std::vector< dunedaq::conffwk::Version > dunedaq::oksconflibs::OksConfiguration::get_versions ( const std::string & since,
const std::string & until,
dunedaq::conffwk::Version::QueryType type,
bool skip_irrelevant )
virtual

Get archived versions.

Implements dunedaq::conffwk::ConfigurationImpl.

Definition at line 590 of file OksConfiguration.cpp.

591{
592 if (!m_kernel->get_repository_root().empty())
593 {
594 try
595 {
596 return oks2config(type == dunedaq::conffwk::Version::query_by_date ? m_kernel->get_repository_versions_by_date(skip_irrelevant, since, until) : m_kernel->get_repository_versions_by_hash(skip_irrelevant, since, until));
597 }
598 catch (const oks::exception& ex)
599 {
600 throw(dunedaq::conffwk::Generic(ERS_HERE, "cannot get repository versions", ex));
601 }
602 }
603 else
604 {
605 throw(dunedaq::conffwk::Generic(ERS_HERE, "cannot get versions, repository is not set"));
606 }
607}

◆ init_env()

void OksConfiguration::init_env ( )
protected

Definition at line 1445 of file OksConfiguration.cpp.

1446{
1447 m_oks_kernel_silence = (getenv("OKSCONFLIBS_NO_KERNEL_SILENCE") == nullptr);
1448}

◆ is_writable()

bool OksConfiguration::is_writable ( const std::string & db_name)
virtual

Return write access status.

Implements dunedaq::conffwk::ConfigurationImpl.

Definition at line 1118 of file OksConfiguration.cpp.

1119{
1120 if (OksFile * h = m_kernel->find_data_file(db_name))
1121 {
1122 try
1123 {
1124 if (!m_kernel->get_user_repository_root().empty())
1125 {
1127 }
1128 else
1129 {
1130 return !OksKernel::check_read_only(h);
1131 }
1132 }
1133 catch (const std::exception& ex)
1134 {
1135 std::ostringstream text;
1136 text << "cannot check access status of file \'" << db_name << "\': " << ex.what();
1137 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
1138 }
1139 }
1140 else
1141 {
1142 throw ( dunedaq::conffwk::Generic( ERS_HERE, mk_no_file_error_text(db_name).c_str() ) );
1143 }
1144}
static std::string & get_user_name()
Get username of given process.
Definition kernel.cpp:473
static bool check_read_only(OksFile *f)
Check if the OKS file is read-only.
Definition kernel.cpp:1537
bool is_writable(const oks::OksFile &file, const std::string &user=oks::OksKernel::get_user_name())

◆ loaded()

virtual bool dunedaq::oksconflibs::OksConfiguration::loaded ( ) const
inlinevirtualnoexcept

Check if a database is loaded.

Implements dunedaq::conffwk::ConfigurationImpl.

Definition at line 67 of file OksConfiguration.hpp.

67{ return (m_kernel != 0); }

◆ new_object()

dunedaq::oksconflibs::OksConfigObject * dunedaq::oksconflibs::OksConfiguration::new_object ( oks::OksObject * obj)
protectednoexcept

Definition at line 612 of file OksConfiguration.cpp.

613{
614 return insert_object<dunedaq::oksconflibs::OksConfigObject>(obj, obj->GetId(), obj->GetClass()->get_name());
615}
T * insert_object(OBJ &obj, const std::string &id, const std::string &class_name) noexcept
insert new object (update cache or create-and-insert)

◆ open_db()

void OksConfiguration::open_db ( const std::string & db_name)
virtual

Open database implementation in accordance with given name.

Implements dunedaq::conffwk::ConfigurationImpl.

Definition at line 162 of file OksConfiguration.cpp.

163{
164 // separate parameters first
165
166 std::string::size_type idx = spec_params.find_first_of('&');
167
168 std::string data, params;
169
170 if (idx == std::string::npos)
171 {
172 data = spec_params;
173 }
174 else
175 {
176 data = spec_params.substr(0, idx);
177 params = spec_params.substr(idx + 1);
178 }
179
180 std::string token;
181
182 // guess about oks kernel mode based on the file names
183
184 {
185 Oks::Tokenizer t(data, ":");
186
187 while (!(token = t.next()).empty())
188 {
189 if (is_repo_name(token) == false)
191 }
192 }
193
194 // create OKS kernel if it was not created
195
196 if (m_kernel == nullptr)
197 {
198 if (!params.empty())
199 {
200 Oks::Tokenizer t(params, ";");
201
202 while (!(token = t.next()).empty())
203 {
204 if(token == "norepo")
206 }
207 }
208
209 m_kernel = new OksKernel(m_oks_kernel_silence, false, false, !m_oks_kernel_no_repo);
210 }
211
212 Oks::Tokenizer t(data, ":");
213
214 while(!(token = t.next()).empty()) {
215 try {
216 m_kernel->load_file(token);
217 }
218 catch (oks::exception & e) {
219 std::ostringstream text;
220 text << "cannot load file \'" << token << "\':\n" << e.what();
221 close_db();
222 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
223 }
224 catch (...) {
225 std::ostringstream text;
226 text << "cannot load file \'" << token << '\'';
227 close_db();
228 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
229 }
230 }
231}

◆ prefetch_all_data()

virtual void dunedaq::oksconflibs::OksConfiguration::prefetch_all_data ( )
inlinevirtual

Prefetch all data into client cache.

Implements dunedaq::conffwk::ConfigurationImpl.

Definition at line 77 of file OksConfiguration.hpp.

77{ ; } // nothing to do with OKS data already in-memory

◆ print_profiling_info()

void OksConfiguration::print_profiling_info ( )
virtualnoexcept

Print implementation specific profiling information.

Implements dunedaq::conffwk::ConfigurationImpl.

Definition at line 1431 of file OksConfiguration.cpp.

1432{
1433 std::cout <<
1434 "OksConfiguration profiler report:\n"
1435 " number of loaded schema files: " << (m_kernel ? m_kernel->schema_files().size() : 0) << "\n"
1436 " number of loaded data files: " << (m_kernel ? m_kernel->data_files().size() : 0) << "\n"
1437 " number of loaded classes: " << (m_kernel ? m_kernel->classes().size() : 0) << "\n"
1438 " number of loaded objects: " << (m_kernel ? m_kernel->objects().size() : 0) << std::endl;
1439}
FELIX Initialization std::string initerror FELIX queue timed std::string queuename Unexpected chunk size

◆ remove_include()

void OksConfiguration::remove_include ( const std::string & db_name,
const std::string & include )
virtual

Remove include file.

Implements dunedaq::conffwk::ConfigurationImpl.

Definition at line 1179 of file OksConfiguration.cpp.

1180{
1181 InheritanceData inheritance(*m_kernel);
1182
1183 DestroyGuard2 dg2(m_removed); // => on exit from method, call m_removed.clear();
1184
1185 if(OksFile * h = m_kernel->find_data_file(db_name)) {
1186 try {
1187 m_kernel->subscribe_delete_object(delete_notify, reinterpret_cast<void *>(this));
1188 DestroyGuard1 dg1(*m_kernel); // => on exit from try block, call m_kernel->subscribe_delete_object(0, 0);
1189 h->remove_include_file(include);
1190 }
1191 catch(dunedaq::conffwk::Generic& ex) {
1192 throw ( dunedaq::conffwk::Generic( ERS_HERE, mk_rm_include_error_text(db_name, include).c_str() ), ex );
1193 }
1194 catch (oks::exception & ex) {
1195 throw ( dunedaq::conffwk::Generic( ERS_HERE, mk_rm_include_error_text(db_name, include, ex.what()).c_str() ) );
1196 }
1197 catch (...) {
1198 throw ( dunedaq::conffwk::Generic( ERS_HERE, mk_rm_include_error_text(db_name, include).c_str() ) );
1199 }
1200 }
1201 else {
1202 throw ( dunedaq::conffwk::Generic( ERS_HERE, mk_no_file_error_text(db_name).c_str() ) );
1203 }
1204
1205 std::vector<conffwk::ConfigurationChange *> changes;
1206
1207 for(SMap::iterator i = m_removed.begin(); i != m_removed.end(); ++i) {
1208 for(std::set<std::string>::const_iterator j = i->second.begin(); j != i->second.end(); ++j) {
1209 check(changes, inheritance, m_class_names, m_objects, i->first, *j, '-');
1210 }
1211 }
1212
1213 if(!changes.empty()) {
1214 m_conf->update_cache(changes);
1216 }
1217}
static std::string mk_rm_include_error_text(const std::string &db, const std::string &include, const char *error=0)

◆ set_commit_credentials()

void OksConfiguration::set_commit_credentials ( const std::string & user,
const std::string & password )
virtual

Set commit credentials.

Implements dunedaq::conffwk::ConfigurationImpl.

Definition at line 358 of file OksConfiguration.cpp.

◆ subscribe() [1/2]

void OksConfiguration::subscribe ( )
protected

Definition at line 1401 of file OksConfiguration.cpp.

1402{
1403 if(m_check_db_obj == 0) {
1404 TLOG_DEBUG( 2) << "starting CheckDB thread ..." ;
1406 m_check_db_thread = new std::thread(std::ref(*m_check_db_obj));
1407 }
1408}

◆ subscribe() [2/2]

void OksConfiguration::subscribe ( const std::set< std::string > & class_names,
const SMap & objs,
ConfigurationImpl::notify cb,
ConfigurationImpl::pre_notify pre_cb )
virtual

Definition at line 1385 of file OksConfiguration.cpp.

1389{
1390 m_fn = cb;
1391 m_pre_fn = pre_cb;
1392 m_class_names = class_names;
1393 m_objects = objs;
1394
1395 subscribe();
1396}
conffwk::ConfigurationImpl::pre_notify m_pre_fn

◆ test_object()

bool OksConfiguration::test_object ( const std::string & class_name,
const std::string & id,
unsigned long rlevel,
const std::vector< std::string > * rclasses )
virtual

Test object existence (used by Python binding).

Implements dunedaq::conffwk::ConfigurationImpl.

Definition at line 618 of file OksConfiguration.cpp.

619{
620 // Looking for the class. If it does not exist, we return false.
621 OksClass * cl = m_kernel->find_class(class_name);
622 if (!cl)
623 return false;
624
625 // The object exist for this class?
626 if (cl->get_object(name))
627 return true;
628
629 // Trying all subclasses
630 if (const OksClass::FList * subclasses = cl->all_sub_classes())
631 {
632 for (OksClass::FList::const_iterator it = subclasses->begin(); it != subclasses->end(); ++it)
633 {
634 if ((*it)->get_object(name))
635 return true;
636 }
637 }
638 // If we get here, we found the class, but not the object.
639 return false;
640}
const FList * all_sub_classes() const noexcept
Definition class.hpp:471
OksObject * get_object(const std::string &id) const noexcept
Get object by ID.
Definition class.cpp:1526

◆ unsubscribe()

void OksConfiguration::unsubscribe ( )
virtual

Remove subscription on database changes.

Implements dunedaq::conffwk::ConfigurationImpl.

Definition at line 1416 of file OksConfiguration.cpp.

1417{
1418 if(m_check_db_obj) {
1419 TLOG_DEBUG( 2) << "stopping CheckDB thread ..." ;
1420 m_check_db_obj->m_run = false;
1421 m_check_db_thread->join(); // wait thread termination
1422 delete m_check_db_thread;
1424 m_check_db_obj = 0;
1425 TLOG_DEBUG( 2) << "the CheckDB thread has been terminated" ;
1426 }
1427}

◆ OksConfigObject

friend class OksConfigObject
friend

Definition at line 41 of file OksConfiguration.hpp.

◆ OksConfigurationCheckDB

friend struct OksConfigurationCheckDB
friend

Definition at line 42 of file OksConfiguration.hpp.

◆ ResubscribeGuard

friend class ResubscribeGuard
friend

Definition at line 43 of file OksConfiguration.hpp.

Member Data Documentation

◆ m_check_db_obj

OksConfigurationCheckDB* dunedaq::oksconflibs::OksConfiguration::m_check_db_obj
protected

Definition at line 134 of file OksConfiguration.hpp.

◆ m_check_db_thread

std::thread* dunedaq::oksconflibs::OksConfiguration::m_check_db_thread
protected

Definition at line 135 of file OksConfiguration.hpp.

◆ m_class_names

std::set<std::string> dunedaq::oksconflibs::OksConfiguration::m_class_names
protected

Definition at line 108 of file OksConfiguration.hpp.

◆ m_created

std::list<oks::OksObject *> dunedaq::oksconflibs::OksConfiguration::m_created
protected

Definition at line 124 of file OksConfiguration.hpp.

◆ m_created_files

std::set<oks::OksFile *> dunedaq::oksconflibs::OksConfiguration::m_created_files
protected

Definition at line 143 of file OksConfiguration.hpp.

◆ m_fn

conffwk::ConfigurationImpl::notify dunedaq::oksconflibs::OksConfiguration::m_fn
protected

Definition at line 106 of file OksConfiguration.hpp.

◆ m_kernel

oks::OksKernel* dunedaq::oksconflibs::OksConfiguration::m_kernel
protected

Definition at line 105 of file OksConfiguration.hpp.

◆ m_modified

std::set<oks::OksObject *> dunedaq::oksconflibs::OksConfiguration::m_modified
protected

Definition at line 125 of file OksConfiguration.hpp.

◆ m_objects

SMap dunedaq::oksconflibs::OksConfiguration::m_objects
protected

Definition at line 109 of file OksConfiguration.hpp.

◆ m_oks_kernel_no_repo

bool dunedaq::oksconflibs::OksConfiguration::m_oks_kernel_no_repo
protected

Definition at line 111 of file OksConfiguration.hpp.

◆ m_oks_kernel_silence

bool dunedaq::oksconflibs::OksConfiguration::m_oks_kernel_silence
protected

Definition at line 110 of file OksConfiguration.hpp.

◆ m_password

std::string dunedaq::oksconflibs::OksConfiguration::m_password
protected

Definition at line 138 of file OksConfiguration.hpp.

◆ m_pre_fn

conffwk::ConfigurationImpl::pre_notify dunedaq::oksconflibs::OksConfiguration::m_pre_fn
protected

Definition at line 107 of file OksConfiguration.hpp.

◆ m_removed

std::map<std::string, std::set<std::string> > dunedaq::oksconflibs::OksConfiguration::m_removed
protected

Definition at line 126 of file OksConfiguration.hpp.

◆ m_repo_error_count

unsigned int dunedaq::oksconflibs::OksConfiguration::m_repo_error_count
protected

Definition at line 148 of file OksConfiguration.hpp.

◆ m_user

std::string dunedaq::oksconflibs::OksConfiguration::m_user
protected

Definition at line 137 of file OksConfiguration.hpp.


The documentation for this class was generated from the following files: