otsdaq  v2_05_02_indev
DatabaseConfigurationInterface_Impl.cc
1 #include "otsdaq/ConfigurationInterface/DatabaseConfigurationInterface.h"
2 
3 #include <algorithm>
4 #include <iterator>
5 
6 #include "otsdaq/ConfigurationInterface/ConfigurationInterface.h"
7 
8 //#include "ConfigurationInterface.h"
9 #include "artdaq-database/ConfigurationDB/configurationdbifc.h"
10 
11 #include "artdaq-database/BasicTypes/basictypes.h"
12 using artdaq::database::basictypes::FhiclData;
13 using artdaq::database::basictypes::JsonData;
14 
15 namespace artdaq
16 {
17 namespace database
18 {
19 namespace configuration
20 {
21 using ots::TableBase;
22 
23 template<>
24 template<>
25 bool MakeSerializable<TableBase const*>::writeDocumentImpl<JsonData>(JsonData& data) const
26 {
27  std::stringstream ss;
28 
29  _conf->getView().printJSON(ss);
30  // std::cout << "!!!!!\n" << ss.str() << std::endl; //for debugging
31  data.json_buffer = ss.str();
32 
33  return true;
34 }
35 
36 template<>
37 std::string MakeSerializable<TableBase const*>::configurationNameImpl() const
38 {
39  return _conf->getTableName();
40 }
41 
42 template<>
43 template<>
44 bool MakeSerializable<TableBase*>::readDocumentImpl<JsonData>(JsonData const& data)
45 {
46  int retVal = _conf->getViewP()->fillFromJSON(data.json_buffer);
47 
48  return (retVal >= 0);
49 }
50 
51 template<>
52 std::string MakeSerializable<TableBase*>::configurationNameImpl() const
53 {
54  return _conf->getTableName();
55 }
56 
57 } // namespace configuration
58 } // namespace database
59 } // namespace artdaq