forked from coderdj/redax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOptions.hh
76 lines (62 loc) · 1.77 KB
/
Options.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef _OPTIONS_HH_
#define _OPTIONS_HH_
#include <string>
#include <vector>
#include <fstream>
#include <streambuf>
#include <iostream>
#include <stdexcept>
#include <bsoncxx/array/view.hpp>
#include <bsoncxx/types.hpp>
#include <bsoncxx/json.hpp>
#include <bsoncxx/document/view.hpp>
#include <bsoncxx/document/value.hpp>
#include <bsoncxx/builder/stream/document.hpp>
#include <bsoncxx/exception/exception.hpp>
#include "DAXHelpers.hh"
#include "MongoLog.hh"
struct BoardType{
int link;
int crate;
int board;
std::string type;
std::string device;
unsigned int vme_address;
};
struct RegisterType{
int board;
std::string reg;
std::string val;
};
struct CrateOptions{
int pulser_freq;
int neutron_veto;
int muon_veto;
int led_trigger;
int s_in;
};
class Options{
public:
Options(MongoLog *log, std::string name, mongocxx::collection opts_collection,
std::string override_opts);
~Options();
int Load(std::string name, mongocxx::collection opts_collection,
std::string override_opts);
int Override(bsoncxx::document::view override_opts);
std::string ExportToString();
int GetInt(std::string key, int default_value=-1);
long int GetLongInt(std::string key, long int default_value=-1);
std::string GetString(std::string key, std::string default_value="");
std::vector<BoardType> GetBoards(std::string type="", std::string hostname="DEFAULT");
std::vector<RegisterType> GetRegisters(int board=-1);
int GetCrateOpt(CrateOptions &ret, std::string device="");
int GetChannel(int bid, int cid);
int GetNestedInt(std::string path, int default_value);
private:
std::string defaultPath = "defaults/daxOptions.json";
DAXHelpers *fHelper;
bsoncxx::document::view bson_options;
bsoncxx::document::value *bson_value;
MongoLog *fLog;
};
#endif