DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
OksConfiguration.cpp
Go to the documentation of this file.
1#include <stdlib.h>
2#include <unistd.h>
3#include <sys/stat.h>
4#include <errno.h>
5
6#include <algorithm>
7#include <memory>
8
9#include "ers/ers.hpp"
10
11#include "oks/file.hpp"
12#include "oks/kernel.hpp"
13#include "oks/object.hpp"
14#include "oks/query.hpp"
15#include "oks/relationship.hpp"
17
20#include "conffwk/Change.hpp"
21#include "conffwk/Schema.hpp"
22
25
26namespace dunedaq{
27 ERS_DECLARE_ISSUE( oksconflibs, Exception, , )
28}
29using namespace dunedaq;
30using namespace dunedaq::oks;
31using namespace dunedaq::oksconflibs;
32 // to be used as plug-in
33
34extern "C" conffwk::ConfigurationImpl * _oksconflibs_creator_ (const std::string& spec) {
35 try {
36 std::unique_ptr<OksConfiguration> impl(new OksConfiguration());
37 if(!spec.empty()) { impl->open_db(spec); }
38 return impl.release();
39 }
40 catch(dunedaq::conffwk::Exception & ex) {
41 throw dunedaq::conffwk::Generic(ERS_HERE, "oksconflibs initialization error", ex);
42 }
43 catch(...) {
44 throw dunedaq::conffwk::Generic(ERS_HERE, "oksconflibs initialization error:\n***** caught unknown exception *****");
45 }
46}
47
48
50
52 bool m_run;
53
55
57 TLOG_DEBUG( 3 ) << "Call destructor of OksConfigurationCheckDB object" ;
58 m_db = nullptr;
59 }
60
61 void
63 {
64 TLOG_DEBUG(2) << "Call user notification" ;
65
66 while (m_run)
67 {
68 sleep(1);
69 try
70 {
71 m_db->check_db();
72 }
74 {
75 m_db->m_check_db_thread = nullptr;
76 m_db->m_check_db_obj = nullptr;
77
78 if (getenv("OKSCONFLIBS_NO_RELOAD_ABORT") != nullptr)
79 {
80 ers::fatal(dunedaq::conffwk::Generic( ERS_HERE, "database reload has failed, unsubscribing...", ex ) );
81 return;
82 }
83 else
84 {
85 ers::fatal ( dunedaq::conffwk::Generic( ERS_HERE, "database reload has failed, aborting...", ex ) );
86 abort();
87 }
88 }
89 }
90
91 TLOG_DEBUG( 4 ) << "Destroy OksConfigurationCheckDB object = " << (void *)this ;
92
93 delete this;
94
95 TLOG_DEBUG( 2 ) << "Exit user notification" ;
96 }
97
98};
99
100
101bool
102is_repo_name(const std::string& name)
103{
104 if (!OksKernel::get_repository_root().empty())
105 {
106 std::string s(name);
107
109
110 bool is_absolute_path = (s[0] == '/');
111
112 if (!is_absolute_path)
113 s = std::string(OksKernel::get_cwd()) + '/' + s;
114
115 // if file system path exists
116 if (Oks::real_path(s, true))
117 {
119 return true;
120
121 static std::string user_repo_dir;
122 static std::once_flag flag;
123
124 std::call_once(flag, []()
125 {
126 if (const char * s = getenv("TDAQ_DB_USER_REPOSITORY"))
127 {
128 user_repo_dir = s;
129
130 try
131 {
132 Oks::real_path(user_repo_dir, false);
133 }
134 catch(oks::exception& ex)
135 {
136 TLOG_DEBUG( 0) << "Failed to read TDAQ_DB_USER_REPOSITORY = \'" << s << "\':\n\tcaused by: " << ex.what() ;
137 }
138 }
139 }
140 );
141
142 if (!user_repo_dir.empty() && s.find(user_repo_dir) == 0)
143 return true;
144
145 return false;
146 }
147 else
148 return true;
149 }
150
151 return false;
152}
153
154void
155OksConfiguration::open_db(const std::string& spec_params)
156{
157 // separate parameters first
158
159 std::string::size_type idx = spec_params.find_first_of('&');
160
161 std::string data, params;
162
163 if (idx == std::string::npos)
164 {
165 data = spec_params;
166 }
167 else
168 {
169 data = spec_params.substr(0, idx);
170 params = spec_params.substr(idx + 1);
171 }
172
173 std::string token;
174
175 // guess about oks kernel mode based on the file names
176
177 {
178 Oks::Tokenizer t(data, ":");
179
180 while (!(token = t.next()).empty())
181 {
182 if (is_repo_name(token) == false)
184 }
185 }
186
187 // create OKS kernel if it was not created
188
189 if (m_kernel == nullptr)
190 {
191 if (!params.empty())
192 {
193 Oks::Tokenizer t(params, ";");
194
195 while (!(token = t.next()).empty())
196 {
197 if(token == "norepo")
199 }
200 }
201
203 }
204
205 Oks::Tokenizer t(data, ":");
206
207 while(!(token = t.next()).empty()) {
208 try {
209 m_kernel->load_file(token);
210 }
211 catch (oks::exception & e) {
212 std::ostringstream text;
213 text << "cannot load file \'" << token << "\':\n" << e.what();
214 close_db();
215 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
216 }
217 catch (...) {
218 std::ostringstream text;
219 text << "cannot load file \'" << token << '\'';
220 close_db();
221 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
222 }
223 }
224}
225
226void
228{
229 clean(); // clean implementation cache
230
231 if(m_kernel) try {
232 if(m_check_db_obj) {
233 if(call_unsubscribe)
234 unsubscribe();
235 else
236 m_check_db_obj->m_run = false;
237 }
238
242
245
246 delete m_kernel;
247 m_kernel = 0;
248 }
249 catch(oksconflibs::Exception& ex) {
250 throw ( dunedaq::conffwk::Generic( ERS_HERE, "failed to close database", ex ) );
251 }
252 catch(std::exception& ex) {
253 throw ( dunedaq::conffwk::Generic( ERS_HERE, "failed to close database", ex ) );
254 }
255}
256
257
258void
259OksConfiguration::create(const std::string& db_name, const std::list<std::string>& includes)
260{
261 // create OKS kernel if it was not created
262
263 if (m_kernel == nullptr)
264 {
265 if (is_repo_name(db_name) == false)
267
269 }
270
271
272 // create new data file
273
274 try {
275 OksFile * h = m_kernel->new_data(db_name);
276 m_created_files.insert(h);
277
278 // add includes
279
280 for(std::list<std::string>::const_iterator i = includes.begin(); i != includes.end(); ++i) {
281 try {
282 h->add_include_file(*i);
283 }
284 catch (oks::exception & e) {
285 std::ostringstream text;
286 text << "cannot add and load include file \'" << *i << "\' to \'" << db_name << "\':\n" << e.what();
287 close_db();
288 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
289 }
290 catch (...) {
291 std::ostringstream text;
292 text << "cannot add and load include file \'" << *i << "\' to \'" << db_name << '\'';
293 close_db();
294 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
295 }
296 }
297
299 }
300 catch (oks::exception & ex) {
301 close_db();
302 std::ostringstream text;
303 text << "cannot create new data file \'" << db_name << "\': " << ex.what();
304 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
305 }
306 catch (dunedaq::conffwk::Generic & ex) {
307 close_db();
308 std::ostringstream text;
309 text << "cannot create new data file \'" << db_name << "\'";
310 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str(), ex ) );
311 }
312 catch (...) {
313 close_db();
314 std::ostringstream text;
315 text << "cannot create new data file \'" << db_name << '\'';
316 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
317 }
318}
319
320static std::string
321mk_no_file_error_text(const std::string &db)
322{
323 std::ostringstream text;
324 text << "cannot find file \'" << db << '\'';
325 return text.str();
326}
327
328static std::string
329mk_add_include_error_text(const std::string &db, const std::string &include, const char *error = nullptr)
330{
331 std::ostringstream text;
332 text << "cannot add and load include file \'" << include << "\' to \'" << db << '\'';
333 if (error)
334 text << ":\n" << error;
335 return text.str();
336}
337
338
339void
340OksConfiguration::get_updated_dbs(std::list<std::string>& dbs) const
341{
342 for (const auto& i : m_kernel->data_files())
343 {
344 if (i.second->is_updated())
345 dbs.push_back(i.second->get_full_file_name());
346 }
347}
348
349
350void
351OksConfiguration::set_commit_credentials(const std::string& user, const std::string& password)
352{
353 m_user = user;
354 m_password = password;
355}
356
357static void throw_update_exception(const OksFile * file_h, const char * action, const char * reason)
358{
359 std::ostringstream text;
360 text << "cannot " << action << " file \'" << file_h->get_full_file_name() << "\' since " << reason;
361 throw dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() );
362}
363
364void
365OksConfiguration::commit(const std::string& log_message)
366{
367 try
368 {
369 m_kernel->set_active_data(nullptr);
370 }
371 catch (oks::exception &ex)
372 {
374 }
375
376 const bool commit2repo(!m_kernel->get_user_repository_root().empty() && m_kernel->is_user_repository_created());
377 unsigned int count(0);
378
379 for (const auto &i : m_kernel->data_files())
380 {
381 OksFile *file_h = i.second;
382
383 if (file_h->is_updated())
384 {
385 const OksFile::FileStatus file_status = file_h->get_status_of_file();
386
387 if (file_status == OksFile::FileModified)
388 throw_update_exception(file_h, "save", "it was externally modified");
389 else if (file_status == OksFile::FileRemoved)
390 throw_update_exception(file_h, "save", "it was externally removed");
391
392 try
393 {
394 if (!commit2repo && !log_message.empty())
395 file_h->add_comment(log_message, m_kernel->get_user_name());
396
397 m_kernel->save_data(file_h);
398
399 count++;
400 }
401 catch (oks::exception &ex)
402 {
403 std::ostringstream text;
404 text << "cannot save updated data file \'" << *(i.first) << "\':\n" << ex.what();
405 throw(dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str()));
406 }
407 }
408 }
409
410 if (commit2repo && count)
411 {
412 try
413 {
414 m_kernel->commit_repository(log_message);
415 }
416 catch (oks::exception &ex)
417 {
419 }
420 }
421
422 m_created_files.clear();
423}
424
425namespace dunedaq{
426 namespace oksconflibs{
428
429 public:
430
432 if(m_db.m_check_db_obj) {
433 m_db.unsubscribe();
434 m_restart = true;
435 }
436 else {
437 m_restart = false;
438 }
439
440 m_db.m_created.clear();
441 m_db.m_modified.clear();
442 m_db.m_removed.clear();
443 }
444
446 if(m_restart) {
447 m_db.subscribe();
448 }
449 }
450
451 private:
452
455
456};
457
458void
460{
461 // unsubscribe changes; if there are any, re-subscribe on return from this method
462
463 ResubscribeGuard __rg__(*this);
464
465
466 // destroy any newly created files
467 for (const auto& i : m_created_files)
468 {
469 const std::string file_name(i->get_full_file_name());
470
471 TLOG_DEBUG(1) << "destroy created file \'" << file_name << "\')" ;
473
474 if (int result = unlink(file_name.c_str()))
475 {
476 std::ostringstream text;
477 text << "abort changes failed since cannot erase created file \'" << file_name << "\'; unlink failed with code " << result << ": " << dunedaq::oks::strerror(errno);
478 throw(dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
479 }
480 }
481
482 m_created_files.clear();
483
484
485
486 // add to "updated" any modified file
487 std::set<OksFile *> updated;
488
489 for (const auto& i : m_kernel->data_files())
490 {
491 if (i.second->is_updated())
492 {
493 updated.insert(i.second);
494 TLOG_DEBUG(2) << "file \'" << i.second->get_full_file_name() << "\' was updated, to be reloaded..." ;
495 }
496 }
497
498 if (!m_kernel->get_user_repository_root().empty())
499 {
500 std::set<OksFile *> mfs, rfs;
501 try
502 {
503 m_kernel->get_modified_files(mfs, rfs, "origin/master");
504 }
505 catch (const oks::exception& ex)
506 {
507 std::ostringstream text;
508 text << "failed to get differences between revisions " << m_kernel->get_repository_version() << " and origin/master: " << ex.what() << '\n';
509 throw(dunedaq::conffwk::Generic(ERS_HERE, text.str().c_str(), ex));
510 }
511 }
512
513 if (!updated.empty())
514 {
515 try
516 {
517 if (!m_kernel->get_user_repository_root().empty())
518 m_kernel->update_repository("origin/master", OksKernel::RepositoryUpdateType::DiscardChanges);
519
520 m_kernel->reload_data(updated);
521 }
522 catch (oks::exception & ex)
523 {
524 throw(dunedaq::conffwk::Generic(ERS_HERE, "cannot reload updated data files", ex));
525 }
526 catch (...)
527 {
528 throw(dunedaq::conffwk::Generic(ERS_HERE, "cannot reload updated data files"));
529 }
530 }
531}
532
533
534static std::vector<dunedaq::conffwk::Version>
535oks2config(const std::vector<OksRepositoryVersion>& in)
536{
537 std::vector<dunedaq::conffwk::Version> out;
538 out.reserve(in.size());
539
540 for (auto& x : in)
541 out.emplace_back(x.m_commit_hash, x.m_user, x.m_date, x.m_comment, x.m_files);
542
543 return out;
544}
545
546std::vector<dunedaq::conffwk::Version>
548{
549 if (!m_kernel->get_repository_root().empty())
550 {
551 try
552 {
554 }
555 catch (const oks::exception& ex)
556 {
557 throw(dunedaq::conffwk::Generic(ERS_HERE, "cannot get new versions", ex));
558 }
559 }
560 else
561 {
562 std::vector<dunedaq::conffwk::Version> out;
563
564 std::set<OksFile *> oks_files;
565 m_kernel->get_modified_files(oks_files, oks_files, "");
566
567 if (!oks_files.empty())
568 {
569 std::vector<std::string> files;
570
571 for(const auto& x : oks_files)
572 files.push_back(x->get_well_formed_name());
573
574 out.emplace_back("", "", 0, "", files);
575 }
576
577 return out;
578 }
579}
580
581
582std::vector<dunedaq::conffwk::Version>
583OksConfiguration::get_versions(const std::string& since, const std::string& until, dunedaq::conffwk::Version::QueryType type, bool skip_irrelevant)
584{
585 if (!m_kernel->get_repository_root().empty())
586 {
587 try
588 {
589 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));
590 }
591 catch (const oks::exception& ex)
592 {
593 throw(dunedaq::conffwk::Generic(ERS_HERE, "cannot get repository versions", ex));
594 }
595 }
596 else
597 {
598 throw(dunedaq::conffwk::Generic(ERS_HERE, "cannot get versions, repository is not set"));
599 }
600}
601
602}}
603
606{
607 return insert_object<dunedaq::oksconflibs::OksConfigObject>(obj, obj->GetId(), obj->GetClass()->get_name());
608}
609
610bool
611OksConfiguration::test_object(const std::string& class_name, const std::string& name, unsigned long /*rlevel*/, const std::vector<std::string> * /*rclasses*/)
612{
613 // Looking for the class. If it does not exist, we return false.
614 OksClass * cl = m_kernel->find_class(class_name);
615 if (!cl)
616 return false;
617
618 // The object exist for this class?
619 if (cl->get_object(name))
620 return true;
621
622 // Trying all subclasses
623 if (const OksClass::FList * subclasses = cl->all_sub_classes())
624 {
625 for (OksClass::FList::const_iterator it = subclasses->begin(); it != subclasses->end(); ++it)
626 {
627 if ((*it)->get_object(name))
628 return true;
629 }
630 }
631 // If we get here, we found the class, but not the object.
632 return false;
633}
634
635void
636dunedaq::oksconflibs::OksConfiguration::get(const std::string &class_name, const std::string &name,
637 dunedaq::conffwk::ConfigObject &object, unsigned long /*rlevel*/, const std::vector<std::string>* /* rclasses */)
638{
639 if (OksClass * cl = m_kernel->find_class(class_name))
640 {
641 OksObject * obj = cl->get_object(name);
642 if (obj == nullptr)
643 {
644 // try all subclasses
645 if (const OksClass::FList *subclasses = cl->all_sub_classes())
646 {
647 for (const auto& it : *subclasses)
648 {
649 obj = it->get_object(name);
650 if (obj != nullptr)
651 break;
652 }
653 }
654 if (obj == nullptr)
655 {
656 const std::string id(name + '@' + class_name);
657 throw dunedaq::conffwk::NotFound(ERS_HERE, "object", id.c_str());
658 }
659 }
660
661 object = new_object(obj);
662 }
663 else
664 {
665 throw dunedaq::conffwk::NotFound(ERS_HERE, "class", class_name.c_str());
666 }
667}
668
669void
670OksConfiguration::get(const std::string& class_name, std::vector<conffwk::ConfigObject>& objects, const std::string& query, unsigned long /*rlevel*/, const std::vector<std::string> * /* rclasses */)
671{
672 if(OksClass * cl = m_kernel->find_class(class_name)) {
673 objects.clear();
674
675 OksObject::List * objs = 0;
676
677 if(query.empty()) {
678 objs = cl->create_list_of_all_objects();
679 }
680 else {
681 try {
682 std::unique_ptr<OksQuery> qe(new OksQuery(cl, query.c_str()));
683 if(qe->good() == false) {
684 std::ostringstream text;
685 text << "bad query syntax \"" << query << "\" in scope of class \"" << class_name << '\"';
686 throw dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str());
687 }
688 objs = cl->execute_query(qe.get()); // FIXME: check .get()
689 }
690 catch(oks::exception& ex) {
691 std::ostringstream text;
692 text << "failed to execute query:\n" << ex.what();
693 throw dunedaq::conffwk::Generic(ERS_HERE, text.str().c_str());
694 }
695 }
696
697 if(objs) {
698 for(OksObject::List::iterator i = objs->begin(); i != objs->end(); ++i) {
699 objects.push_back(new_object(*i));
700 }
701 delete objs;
702 }
703 }
704 else {
705 throw dunedaq::conffwk::NotFound(ERS_HERE, "class", class_name.c_str());
706 }
707}
708
709void
710OksConfiguration::get(const conffwk::ConfigObject& obj_from, const std::string& query, std::vector<conffwk::ConfigObject>& objects, unsigned long /*rlevel*/, const std::vector<std::string> * /* rclasses */)
711{
712 if(obj_from.is_null()) {
713 throw ( dunedaq::conffwk::Generic( ERS_HERE, "parameter \'obj_from\' is (null)" ) );
714 }
715
716 OksObject * o = (static_cast<const OksConfigObject *>(obj_from.implementation()))->m_obj;
717
718 try {
719 oks::QueryPath q(query, *m_kernel);
720 if(OksObject::List * objs = o->find_path(q)) {
721 for(OksObject::List::iterator i = objs->begin(); i != objs->end(); ++i) {
722 objects.push_back(new_object(*i));
723 }
724 delete objs;
725 }
726 }
727 catch ( oks::bad_query_syntax& e ) {
728 std::ostringstream text;
729 text << "bad path-query \"" << query << "\" to object " << o;
730 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
731 }
732}
733
734
736OksConfiguration::get(const std::string& class_name, bool direct_only)
737{
738 OksClass * c = m_kernel->find_class(class_name);
739
740 if(c == 0) {
741 throw dunedaq::conffwk::NotFound(ERS_HERE, "class", class_name.c_str());
742 }
743
744 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());
745
746 if(direct_only) {
747 if(const std::list<std::string *> * classes = c->direct_super_classes()) {
748 for(const auto& i : *classes) {
749 const_cast< std::vector<std::string>& >(d->p_superclasses).push_back(*i);
750 }
751 }
752 }
753 else {
754 if(const OksClass::FList * classes = c->all_super_classes()) {
755 for(const auto& i : *classes) {
756 const_cast< std::vector<std::string>& >(d->p_superclasses).push_back(i->get_name());
757 }
758 }
759 }
760
761 if(const OksClass::FList * subclasses = c->all_sub_classes()) {
762 for(const auto& i : *subclasses) {
763 if(direct_only == false || i->has_direct_super_class(c->get_name()) == true) {
764 const_cast< std::vector<std::string>& >(d->p_subclasses).push_back(i->get_name());
765 }
766 }
767 }
768
769 if(const std::list<OksAttribute *> * attrs = (direct_only ? c->direct_attributes() : c->all_attributes())) {
770 for(const auto& i : *attrs) {
771 OksAttribute::Format format = i->get_format();
772 OksData::Type type = i->get_data_type();
773
774 const_cast< std::vector<dunedaq::conffwk::attribute_t>& >(d->p_attributes).push_back(
776 i->get_name(),
777 (
794 ),
795 i->get_range(),
796 (
797 i->is_integer() == false ? dunedaq::conffwk::na_int_format :
798 (
802 )
803 ),
804 i->get_is_no_null(),
805 i->get_is_multi_values(),
806 i->get_init_value(),
807 i->get_description()
808 )
809 );
810
811 }
812 }
813
814 if(const std::list<OksRelationship *> * rels = (direct_only ? c->direct_relationships() : c->all_relationships())) {
815 for(const auto& i : *rels) {
816 const_cast< std::vector<dunedaq::conffwk::relationship_t>& >(d->p_relationships).push_back(
818 i->get_name(),
819 i->get_type(),
820 (i->get_low_cardinality_constraint() == OksRelationship::Zero),
821 (i->get_high_cardinality_constraint() == OksRelationship::Many),
822 i->get_is_composite(),
823 i->get_description()
824 )
825 );
826 }
827 }
828
829 return d;
830}
831
832void
834{
835 schema.clear();
836
837 if(!m_kernel) {
838 return; // throw ( dunedaq::conffwk::Generic( ERS_HERE, "database is not loaded" ) );
839 }
840
841 schema.reserve(m_kernel->classes().size() * 3);
842
843 for(OksClass::Map::const_iterator i = m_kernel->classes().begin(); i != m_kernel->classes().end(); ++i) {
844 if(const OksClass::FList * scl = i->second->all_super_classes()) {
845 const std::string* name = &conffwk::DalFactory::instance().get_known_class_name_ref(i->second->get_name());
846
847 auto& subclasses = schema[name];
848
849 if(!scl->empty()) {
850 subclasses.reserve(scl->size() * 3);
851 for(OksClass::FList::const_iterator j = scl->begin(); j != scl->end(); ++j) {
852 subclasses.insert(&conffwk::DalFactory::instance().get_known_class_name_ref((*j)->get_name()));
853 }
854 }
855 }
856 }
857}
858
859
860void
861OksConfiguration::create(OksFile * at, const std::string& class_name, const std::string& id, conffwk::ConfigObject& object)
862{
863 try {
865 }
866 catch(oks::exception& ex) {
867 throw ( dunedaq::conffwk::Generic( ERS_HERE, ex.what()) );
868 }
869
870 OksClass * c = m_kernel->find_class(class_name);
871
872 if(c == nullptr) {
873 std::ostringstream text;
874 text << "cannot find class \"" << class_name << '\"';
875 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
876 }
877 else if(id.empty() == false) {
878 if(OksObject * obj = c->get_object(id)) {
879 std::ostringstream text;
880 text << "object \"" << id << '@' << class_name << "\" already exists in file \"" << obj->get_file()->get_full_file_name() << '\"';
881 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
882 }
883 }
884
886 {
889 }
890
891 try {
892 object = new_object(new OksObject(c, id.c_str()));
893 }
894 catch(oks::exception& ex)
895 {
896 throw ( dunedaq::conffwk::Generic( ERS_HERE, "cannot create configuration object", ex ) );
897 }
898}
899
900void
901OksConfiguration::create(const std::string& at, const std::string& class_name, const std::string& id, conffwk::ConfigObject& object)
902{
903 if(at.empty() == true) {
904 throw ( dunedaq::conffwk::Generic( ERS_HERE, "parameter \'at\' (i.e. filename) cannot be empty" ) );
905 }
906
907 if(OksFile * h = m_kernel->find_data_file(at)) {
908 return create(h, class_name, id, object);
909 }
910 else {
911 std::ostringstream text;
912 text << "file \"" << at << "\" is not loaded";
913 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
914 }
915}
916
917void
918OksConfiguration::create(const conffwk::ConfigObject& at, const std::string& class_name, const std::string& id, conffwk::ConfigObject& object)
919{
920 create((static_cast<const OksConfigObject *>(at.implementation()))->m_obj->get_file(), class_name, id, object);
921}
922
923void
925{
926 reinterpret_cast<OksConfiguration *>(p)->m_created.push_back(o);
927}
928
929void
931{
932 reinterpret_cast<OksConfiguration *>(p)->m_modified.insert(o);
933}
934
935void
937{
938 reinterpret_cast<OksConfiguration *>(p)->m_removed[o->GetClass()->get_name()].insert(o->GetId());
939}
940
941
943
945
946 const OksConfiguration::SMap& data() const { return m_data; }
947
949
950};
951
953{
954 for (OksClass::Map::const_iterator i = kernel.classes().begin(); i != kernel.classes().end(); ++i)
955 if (const OksClass::FList *slist = i->second->all_super_classes())
956 {
957 std::set<std::string> &data(m_data[i->second->get_name()]);
958 for (const auto &j : *slist)
959 data.insert(j->get_name());
960 }
961}
962
963
973static void
974check(std::vector<conffwk::ConfigurationChange *>& changes,
975 const InheritanceData & inheritance,
976 const std::set<std::string>& class_names,
977 const OksConfiguration::SMap & objects,
978 const std::string& obj_class,
979 const std::string& obj_id,
980 const char action
981) {
982
983 bool any = (class_names.empty() && objects.empty());
984
985
986 // check subscription on objects
987 //
988 // omi iterator in non-null, if on an object of class 'obj_class'
989 // there is explicit subscription
990
991 OksConfiguration::SMap::const_iterator omi = objects.end();
992
993 if(action != '+') {
994 omi = objects.find(obj_class);
995 if(omi != objects.end()) {
996 std::set<std::string>::const_iterator i = omi->second.find(obj_id);
997
998 if(i != omi->second.end()) {
999 conffwk::ConfigurationChange::add(changes, obj_class, obj_id, action);
1000 }
1001 }
1002 }
1003
1004
1005 // process the class
1006
1007 if(action == '+' || omi == objects.end()) {
1008 if(any || class_names.find(obj_class) != class_names.end()) {
1009 conffwk::ConfigurationChange::add(changes, obj_class, obj_id, action);
1010 }
1011 }
1012
1013
1014 // process subclasses
1015
1016 OksConfiguration::SMap::const_iterator it = inheritance.data().find(obj_class);
1017 if(it != inheritance.data().end()) {
1018 for(std::set<std::string>::const_iterator j = it->second.begin(); j != it->second.end(); ++j) {
1019 omi = (action != '+' ? objects.find(*j) : objects.end());
1020
1021 // 1. add objects if criteria is 'any'
1022 // 2. add object of class which has subscription and has no explicit object subscription
1023 // 3. add explicitly subscribed object
1024
1025 if(
1026 any ||
1027 (
1028 omi == objects.end() &&
1029 class_names.find(*j) != class_names.end()
1030 ) ||
1031 (
1032 omi != objects.end() &&
1033 omi->second.find(obj_id) != omi->second.end()
1034 )
1035 ) {
1036 conffwk::ConfigurationChange::add(changes, *j, obj_id, action);
1037 }
1038 }
1039 }
1040}
1041
1042
1044
1045 public:
1046
1047 DestroyGuard1(OksKernel & kernel) : m_kernel(kernel) { ; }
1048
1050 m_kernel.subscribe_delete_object(0, 0);
1051 }
1052
1053 private:
1054
1056
1057};
1058
1060
1061 public:
1062
1063 DestroyGuard2(OksConfiguration::SMap& removed) : m_removed(removed) { ; }
1064
1066 m_removed.clear();
1067 }
1068
1069 private:
1070
1072
1073};
1074
1075
1076void
1078{
1079 OksObject * o((static_cast<const OksConfigObject *>(obj.implementation()))->m_obj);
1080
1081 DestroyGuard2 dg2(m_removed); // => on exit from method, call m_removed.clear();
1082
1083 InheritanceData inheritance(*m_kernel);
1084
1085 try {
1086 m_kernel->subscribe_delete_object(delete_notify, reinterpret_cast<void *>(this));
1087 DestroyGuard1 dg1(*m_kernel); // => on exit from try block, call m_kernel->subscribe_delete_object(0, 0);
1089 }
1090 catch(oks::exception& ex) {
1091 throw ( dunedaq::conffwk::Generic( ERS_HERE, ex.what()) );
1092 }
1093
1094 if(m_conf) {
1095 std::vector<conffwk::ConfigurationChange *> changes;
1096
1097 for(SMap::iterator i = m_removed.begin(); i != m_removed.end(); ++i) {
1098 for(std::set<std::string>::const_iterator j = i->second.begin(); j != i->second.end(); ++j) {
1099 check(changes, inheritance, m_class_names, m_objects, i->first, *j, '-');
1100 }
1101 }
1102
1103 if(!changes.empty()) {
1104 m_conf->update_cache(changes);
1106 }
1107 }
1108}
1109
1110bool
1111OksConfiguration::is_writable(const std::string& db_name)
1112{
1113 if (OksFile * h = m_kernel->find_data_file(db_name))
1114 {
1115 try
1116 {
1117 if (!m_kernel->get_user_repository_root().empty())
1118 {
1120 }
1121 else
1122 {
1123 return !OksKernel::check_read_only(h);
1124 }
1125 }
1126 catch (const std::exception& ex)
1127 {
1128 std::ostringstream text;
1129 text << "cannot check access status of file \'" << db_name << "\': " << ex.what();
1130 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
1131 }
1132 }
1133 else
1134 {
1135 throw ( dunedaq::conffwk::Generic( ERS_HERE, mk_no_file_error_text(db_name).c_str() ) );
1136 }
1137}
1138
1139static std::string
1140mk_rm_include_error_text(const std::string &db, const std::string &include, const char *error = 0)
1141{
1142 std::ostringstream text;
1143 text << "cannot remove include file \'" << include << "\' from \'" << db << '\'';
1144 if (error)
1145 text << ":\n" << error;
1146 return text.str();
1147}
1148
1149void
1150OksConfiguration::add_include(const std::string& db_name, const std::string& include)
1151{
1152 if(OksFile * h = m_kernel->find_data_file(db_name)) {
1153 try {
1154 h->add_include_file(include);
1155 }
1156 catch(dunedaq::conffwk::Generic& ex) {
1157 throw ( dunedaq::conffwk::Generic( ERS_HERE, mk_add_include_error_text(db_name, include).c_str() ), ex );
1158 }
1159 catch (oks::exception & ex) {
1160 throw ( dunedaq::conffwk::Generic( ERS_HERE, mk_add_include_error_text(db_name, include, ex.what()).c_str() ) );
1161 }
1162 catch (...) {
1163 throw ( dunedaq::conffwk::Generic( ERS_HERE, mk_add_include_error_text(db_name, include).c_str() ) );
1164 }
1165 }
1166 else {
1167 throw ( dunedaq::conffwk::Generic( ERS_HERE, mk_no_file_error_text(db_name).c_str() ) );
1168 }
1169}
1170
1171void
1172OksConfiguration::remove_include(const std::string& db_name, const std::string& include)
1173{
1174 InheritanceData inheritance(*m_kernel);
1175
1176 DestroyGuard2 dg2(m_removed); // => on exit from method, call m_removed.clear();
1177
1178 if(OksFile * h = m_kernel->find_data_file(db_name)) {
1179 try {
1180 m_kernel->subscribe_delete_object(delete_notify, reinterpret_cast<void *>(this));
1181 DestroyGuard1 dg1(*m_kernel); // => on exit from try block, call m_kernel->subscribe_delete_object(0, 0);
1182 h->remove_include_file(include);
1183 }
1184 catch(dunedaq::conffwk::Generic& ex) {
1185 throw ( dunedaq::conffwk::Generic( ERS_HERE, mk_rm_include_error_text(db_name, include).c_str() ), ex );
1186 }
1187 catch (oks::exception & ex) {
1188 throw ( dunedaq::conffwk::Generic( ERS_HERE, mk_rm_include_error_text(db_name, include, ex.what()).c_str() ) );
1189 }
1190 catch (...) {
1191 throw ( dunedaq::conffwk::Generic( ERS_HERE, mk_rm_include_error_text(db_name, include).c_str() ) );
1192 }
1193 }
1194 else {
1195 throw ( dunedaq::conffwk::Generic( ERS_HERE, mk_no_file_error_text(db_name).c_str() ) );
1196 }
1197
1198 std::vector<conffwk::ConfigurationChange *> changes;
1199
1200 for(SMap::iterator i = m_removed.begin(); i != m_removed.end(); ++i) {
1201 for(std::set<std::string>::const_iterator j = i->second.begin(); j != i->second.end(); ++j) {
1202 check(changes, inheritance, m_class_names, m_objects, i->first, *j, '-');
1203 }
1204 }
1205
1206 if(!changes.empty()) {
1207 m_conf->update_cache(changes);
1209 }
1210}
1211
1212
1213void
1214OksConfiguration::get_includes(const std::string& db_name, std::list<std::string>& includes) const
1215{
1216 if (db_name.empty())
1217 {
1218 for (auto& i : m_kernel->data_files())
1219 {
1220 if(i.second->get_parent() == nullptr)
1221 includes.push_back(*i.first);
1222 }
1223 }
1224 else
1225 {
1226 if (OksFile * h = m_kernel->find_data_file(db_name))
1227 {
1228 for (auto& i : h->get_include_files())
1229 {
1230 includes.push_back(i);
1231 }
1232 }
1233 else
1234 {
1235 throw(dunedaq::conffwk::Generic( ERS_HERE, mk_no_file_error_text(db_name).c_str() ) );
1236 }
1237 }
1238}
1239
1240
1241void
1243{
1244 static const std::string version("origin/master");
1245
1246 if (m_fn)
1247 {
1248 std::set<OksFile *> ufs, rfs;
1249
1250 try
1251 {
1254 }
1255 catch(const oks::RepositoryOperationFailed& ex)
1256 {
1257 std::ostringstream text;
1258 text << "cannot get modified repository files (attempt " << ++m_repo_error_count << "): " << ex.what();
1259 ers::error(dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
1260 }
1261 catch(const oks::exception& ex)
1262 {
1263 std::ostringstream text;
1264 text << "cannot get modified files: " << ex.what();
1265 throw(dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
1266 }
1267
1268 for (const auto& x : ufs)
1269 {
1270 if (x->get_oks_format() == "schema")
1271 {
1272 std::ostringstream text;
1273 text << "reload of schema files is not supported (\'" << x->get_well_formed_name() << "\')";
1274 throw(dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
1275 }
1276 }
1277
1278 if (ufs.empty() == false)
1279 {
1280 InheritanceData inheritance(*m_kernel);
1281
1282 m_kernel->subscribe_create_object(create_notify, reinterpret_cast<void *>(this));
1283 m_kernel->subscribe_change_object(change_notify, reinterpret_cast<void *>(this));
1284 m_kernel->subscribe_delete_object(delete_notify, reinterpret_cast<void *>(this));
1285
1286 (*m_pre_fn)(m_conf);
1287
1288 try
1289 {
1290 if(!m_kernel->get_user_repository_root().empty())
1291 m_kernel->update_repository(version, OksKernel::RepositoryUpdateType::DiscardChanges);
1292
1293 m_kernel->reload_data(ufs, false);
1294 }
1295 catch (oks::exception & ex)
1296 {
1297 close_database(false);
1298 m_fn = 0;
1299 std::ostringstream text;
1300 text << "failed to reload updated files:\n" << ex.what();
1301 throw(dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
1302 }
1303 catch (...)
1304 {
1305 close_database(false);
1306 m_fn = 0;
1307 throw ( dunedaq::conffwk::Generic( ERS_HERE, "failed to reload updated files" ) );
1308 }
1309
1310
1314
1315 std::vector<conffwk::ConfigurationChange *> changes;
1316
1317 {
1318 for (auto& i : m_created)
1319 {
1320 check(changes, inheritance, m_class_names, m_objects, i->GetClass()->get_name(), i->GetId(), '+');
1321
1322 std::set<OksObject *>::iterator j = m_modified.find(i);
1323 if (j != m_modified.end())
1324 {
1325 TLOG_DEBUG(1) << "created object " << i << " appears in \'modified\' set, removing..." ;
1326 m_modified.erase(j);
1327 }
1328 }
1329 }
1330
1331 {
1332 for (auto& i : m_modified)
1333 {
1334 if (m_kernel->is_dangling(i))
1335 {
1336 TLOG_DEBUG(1) << "object " << (void *)(i) << " is dangling, ignore..." ;
1337 }
1338 else
1339 {
1340 check(changes, inheritance, m_class_names, m_objects, i->GetClass()->get_name(), i->GetId(), '~');
1341 }
1342 }
1343 }
1344
1345 {
1346 for (auto& i : m_removed)
1347 {
1348 for (auto& j : i.second)
1349 {
1350 check(changes, inheritance, m_class_names, m_objects, i.first, j, '-');
1351 }
1352 }
1353 }
1354
1355 if (!changes.empty())
1356 {
1357 (*m_fn)(changes, m_conf);
1359 }
1360
1361 m_created.clear();
1362 m_modified.clear();
1363 m_removed.clear();
1364 }
1365 }
1366 else
1367 {
1368 throw(dunedaq::conffwk::Generic( ERS_HERE, "no subscription has been done" ) );
1369 }
1370}
1371
1372
1373 //
1374 // Subscribe on changes by class name
1375 //
1376
1377void
1378OksConfiguration::subscribe(const std::set<std::string>& class_names,
1379 const SMap& objs,
1380 ConfigurationImpl::notify cb,
1381 ConfigurationImpl::pre_notify pre_cb)
1382{
1383 m_fn = cb;
1384 m_pre_fn = pre_cb;
1385 m_class_names = class_names;
1386 m_objects = objs;
1387
1388 subscribe();
1389}
1390
1391 // Start subscription thread
1392
1393void
1395{
1396 if(m_check_db_obj == 0) {
1397 TLOG_DEBUG( 2) << "starting CheckDB thread ..." ;
1399 m_check_db_thread = new std::thread(std::ref(*m_check_db_obj));
1400 }
1401}
1402
1403
1404 //
1405 // Unsubscribe
1406 //
1407
1408void
1410{
1411 if(m_check_db_obj) {
1412 TLOG_DEBUG( 2) << "stopping CheckDB thread ..." ;
1413 m_check_db_obj->m_run = false;
1414 m_check_db_thread->join(); // wait thread termination
1415 delete m_check_db_thread;
1417 m_check_db_obj = 0;
1418 TLOG_DEBUG( 2) << "the CheckDB thread has been terminated" ;
1419 }
1420}
1421
1422
1423void
1425{
1426 std::cout <<
1427 "OksConfiguration profiler report:\n"
1428 " number of loaded schema files: " << (m_kernel ? m_kernel->schema_files().size() : 0) << "\n"
1429 " number of loaded data files: " << (m_kernel ? m_kernel->data_files().size() : 0) << "\n"
1430 " number of loaded classes: " << (m_kernel ? m_kernel->classes().size() : 0) << "\n"
1431 " number of loaded objects: " << (m_kernel ? m_kernel->objects().size() : 0) << std::endl;
1432}
1433
1434
1435 // read OksKernel parameters from environment (silence mode)
1436
1437void
1439{
1440 m_oks_kernel_silence = (getenv("OKSCONFLIBS_NO_KERNEL_SILENCE") == nullptr);
1441}
#define ERS_DECLARE_ISSUE(namespace_name, class_name, message, attributes)
#define ERS_HERE
static void throw_update_exception(const OksFile *file_h, const char *action, const char *reason)
conffwk::ConfigurationImpl * _oksconflibs_creator_(const std::string &spec)
static std::string mk_no_file_error_text(const std::string &db)
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)
bool is_repo_name(const std::string &name)
static std::string mk_add_include_error_text(const std::string &db, const std::string &include, const char *error=nullptr)
static std::string mk_rm_include_error_text(const std::string &db, const std::string &include, const char *error=0)
#define sleep(x)
Definition WIB_FEMB.cpp:12
DestroyGuard1(OksKernel &kernel)
DestroyGuard2(OksConfiguration::SMap &removed)
OksConfiguration::SMap & m_removed
Represents database objects.
bool is_null() const noexcept
Check if object's implementation points to null.
const ConfigObjectImpl * implementation() const noexcept
Returns pointer on implementation.
static void clear(std::vector< ConfigurationChange * > &changes)
Helper method to clear vector of changes (pointers).
static void add(std::vector< ConfigurationChange * > &changes, const std::string &class_name, const std::string &obj_id, const char action)
Helper method to add object to the vector of existing changes.
Provides pure virtual interface used by the Configuration class.
void clean() noexcept
clean cache (e.g. to be used by destructor)
Configuration * m_conf
Configuration pointer is needed for notification on changes, e.g. in case of subscription or an objec...
void update_cache(std::vector< ConfigurationChange * > &changes) noexcept
System function invoked in case of modifications.
Generic configuration exception.
Try to access non-existent object or class.
Definition Errors.hpp:47
The OKS class.
Definition class.hpp:200
const FList * all_sub_classes() const noexcept
Definition class.hpp:466
OksObject * get_object(const std::string &id) const noexcept
Get object by ID.
Definition class.cpp:1521
std::list< OksClass *, boost::fast_pool_allocator< OksClass * > > FList
Definition class.hpp:235
Provides interface to the OKS XML schema and data files.
Definition file.hpp:340
void add_include_file(const std::string &name)
Add include file.
Definition file.cpp:1194
void add_comment(const std::string &text, const std::string &author)
Add new comment to file.
Definition file.cpp:669
bool is_updated() const
Return update status of OKS file.
Definition file.hpp:624
const std::string & get_full_file_name() const
Definition file.hpp:523
FileStatus get_status_of_file() const
Return update status of file.
Definition file.cpp:1413
Provides interface to the OKS kernel.
Definition kernel.hpp:577
static const std::string & get_repository_mapping_dir()
Get OKS repository name.
Definition kernel.cpp:350
void subscribe_change_object(OksObject::notify_obj, void *)
Subscribe on object changing.
Definition kernel.hpp:2183
const std::string & get_user_repository_root() const
Get user OKS repository root.
Definition kernel.cpp:370
void subscribe_delete_object(OksObject::notify_obj, void *)
Subscribe on object deleting.
Definition kernel.hpp:2191
OksFile * load_file(const std::string &name, bool bind=true)
Load OKS database file.
Definition kernel.cpp:1788
static std::string & get_user_name()
Get username of given process.
Definition kernel.cpp:468
bool is_dangling(OksClass *class_ptr) const
Check pointer on oks class.
Definition kernel.cpp:4638
static bool check_read_only(OksFile *f)
Check if the OKS file is read-only.
Definition kernel.cpp:1532
void update_repository(const std::string &hash_val, RepositoryUpdateType update_type)
Update user repository files from origin by hash.
Definition kernel.hpp:1608
void get_modified_files(std::set< OksFile * > &mfs, std::set< OksFile * > &rfs, const std::string &version)
Get modified data files.
Definition kernel.cpp:3017
const OksFile::Map & data_files() const
Get all data files.
Definition kernel.hpp:1493
OksFile * new_data(const std::string &name, const std::string &logical_name="", const std::string &type="")
Create OKS data file.
Definition kernel.cpp:3718
OksFile * find_data_file(const std::string &s) const
Finds OKS data file.
Definition kernel.cpp:2287
bool is_user_repository_created() const
Definition kernel.hpp:942
void registrate_all_classes(bool skip_registered=false)
The method rebuilds all classes taking into account inheritance.
Definition kernel.cpp:4499
const OksObject::Set & objects() const
Get objects.
Definition kernel.hpp:1790
bool get_test_duplicated_objects_via_inheritance_mode() const
Get status of test inherited duplicated objects mode. The method returns true, if the mode is switche...
Definition kernel.hpp:765
void reload_data(std::set< OksFile * > &files, bool allow_schema_extension=true)
Reload OKS data files.
Definition kernel.cpp:3211
const OksClass::Map & classes() const
Get classes.
Definition kernel.hpp:1767
std::vector< OksRepositoryVersion > get_repository_versions_by_date(bool skip_irrelevant=true, const std::string &since="", const std::string &until="")
Return repository versions between timestamps.
Definition kernel.cpp:5486
void subscribe_create_object(OksObject::notify_obj cb_f, void *parameter)
Subscribe on object creation.
Definition kernel.hpp:2175
void close_all_data()
Close all OKS data files.
Definition kernel.cpp:4243
void save_data(OksFile *file_h, bool ignore_bad_objects=false, OksFile *true_file_h=nullptr, bool force_defaults=false)
Save OKS data file.
Definition kernel.cpp:3794
void set_test_duplicated_objects_via_inheritance_mode(const bool b)
Set status of test inherited duplicated objects mode. To switch 'On'/'Off' use the method's parameter...
Definition kernel.hpp:756
void bind_objects()
Bind oks objects.
Definition kernel.cpp:4361
static const std::string & get_repository_root()
Get OKS repository root.
Definition kernel.cpp:304
void commit_repository(const std::string &comments, const std::string &credentials="")
Commit user modifications into repository.
Definition kernel.cpp:5057
const std::string & get_repository_version()
Definition kernel.hpp:936
void close_data(OksFile *file_h, bool unbind_objects=true)
Close OKS data file.
Definition kernel.cpp:4183
static const char * get_cwd()
Definition kernel.cpp:689
std::vector< OksRepositoryVersion > get_repository_versions_by_hash(bool skip_irrelevant=true, const std::string &sha1="", const std::string &sha2="")
Return repository versions between hash keys.
Definition kernel.cpp:5450
OksClass * find_class(const std::string &class_name) const
Find class by name (C++ string).
Definition kernel.hpp:1814
void close_all_schema()
Close all OKS schema files.
Definition kernel.cpp:2883
void set_active_data(OksFile *file_h)
Set active OKS data file.
Definition kernel.cpp:4278
const OksFile::Map & schema_files() const
Get all schema files.
Definition kernel.hpp:1223
OksObject describes instance of OksClass.
Definition object.hpp:836
static void destroy(OksObject *obj, bool fast=false)
Destroy OKS object.
Definition object.cpp:1301
std::list< OksObject * > List
Definition object.hpp:875
OksObject::List * find_path(const oks::QueryPath &query) const
Definition query.cpp:936
OKS query class.
Definition query.hpp:36
String tokenizer.
Definition defs.hpp:58
const std::string next()
Definition time.cpp:189
static void substitute_variables(std::string &)
Definition kernel.cpp:570
static bool real_path(std::string &, bool ignore_errors)
Definition kernel.cpp:594
Cannot commit, checkout or release files.
Definition kernel.hpp:108
virtual const char * what() const noexcept
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)
conffwk::ConfigurationImpl::pre_notify m_pre_fn
static void change_notify(oks::OksObject *, void *) noexcept
virtual void open_db(const std::string &db_name)
Open database implementation in accordance with given name.
static void delete_notify(oks::OksObject *, void *) noexcept
virtual void subscribe(const std::set< std::string > &class_names, const SMap &objs, ConfigurationImpl::notify cb, ConfigurationImpl::pre_notify pre_cb)
virtual void print_profiling_info() noexcept
Print implementation specific profiling information.
virtual void get_includes(const std::string &db_name, std::list< std::string > &includes) const
Get included files.
virtual void destroy(conffwk::ConfigObject &object)
Destroy object of class by id.
static void create_notify(oks::OksObject *, void *) noexcept
std::list< oks::OksObject * > m_created
virtual void remove_include(const std::string &db_name, const std::string &include)
Remove include file.
std::set< oks::OksFile * > m_created_files
OksConfigObject * new_object(oks::OksObject *obj) noexcept
virtual void get_updated_dbs(std::list< std::string > &dbs) const
Get uncommitted files.
virtual void close_db()
Close database implementation.
std::map< std::string, std::set< std::string > > m_removed
std::map< std::string, std::set< std::string > > SMap
virtual void set_commit_credentials(const std::string &user, const std::string &password)
Set commit credentials.
virtual std::vector< dunedaq::conffwk::Version > get_versions(const std::string &since, const std::string &until, dunedaq::conffwk::Version::QueryType type, bool skip_irrelevant)
Get archived versions.
virtual void unsubscribe()
Remove subscription on database changes.
virtual void add_include(const std::string &db_name, const std::string &include)
Add include file.
virtual std::vector< dunedaq::conffwk::Version > get_changes()
Get newly available versions.
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 abort()
Abort database changes.
virtual void get_superclasses(conffwk::fmap< conffwk::fset > &schema)
Get inheritance hierarchy.
std::set< oks::OksObject * > m_modified
virtual bool is_writable(const std::string &db_name)
Return write access status.
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 commit(const std::string &why)
Commit database changes.
conffwk::ConfigurationImpl::notify m_fn
conffwk entry point
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112
const std::string strerror(int error)
Convert C error number to string.
Definition kernel.cpp:114
static std::vector< dunedaq::conffwk::Version > oks2config(const std::vector< OksRepositoryVersion > &in)
bool is_writable(const oks::OksFile &file, const std::string &user=oks::OksKernel::get_user_name())
Definition oks_access.cpp:8
Including Qt Headers.
FELIX Initialization std::string initerror FELIX queue timed out
FELIX Initialization std::string initerror FELIX queue timed std::string queuename Unexpected chunk size
void fatal(const Issue &issue)
Definition ers.hpp:88
void error(const Issue &issue)
Definition ers.hpp:81
InheritanceData(const OksKernel &)
const OksConfiguration::SMap & data() const
OksConfiguration::SMap m_data
Factory couldn t std::string alg_name Invalid configuration error
Definition Issues.hpp:34