Loading...
Searching...
No Matches
CommandSections.h
1/*
2
3MIT License
4
5Copyright (c) 2017 FMI Open Development / Markus Peura, first.last@fmi.fi
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26/*
27Part of Rack development has been done in the BALTRAD projects part-financed
28by the European Union (European Regional Development Fund and European
29Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30*/
31
32#ifndef DRAIN_CMD_SECTIONS_H_
33#define DRAIN_CMD_SECTIONS_H_
34
35#include <drain/Log.h>
36#include <map>
37#include <set>
38//#include "drain/util/Debug.h"
39//#include "drain/util/ReferenceMap.h"
40
41#include "drain/util/ReferenceMap.h"
42
43//#include "Command.h"
44//#include "CommandRegistry.h"
45
46#include "CommandBank.h"
47
48
49namespace drain {
50
51
52
53
55
56
57public:
58
59 CommandSection(const std::string & title) : title(title), index(drain::getCommandBank().addSection(title)){
60 Logger mout(__FILE__, __FUNCTION__);
61 //std::cerr << __FUNCTION__ << ':' << title << '(' << index << ')' << std::endl;
62 mout.debug(__FUNCTION__ , ':' , title , '(' , index , ')' );
63 }
64
65 // Consider trying static?
66
67 const std::string title;
68
69 //const drain::Flagger::ivalue_t index;
70 const bank_section_t index;
71
72 operator const std::string & () const {
73 return title;
74 }
75
76 operator bank_section_t () const { // drain::Flagger::ivalue_t
77 return index;
78 }
79
80
81 /*
82 void hello(const std::string & title){
83 std::cerr << "installing " << title << '(' << index << ')' << ' ' << '"'<< title << '"' << std::endl;
84 }
85 */
86
87
88protected:
89
// drain::Flagger::ivalue_t
94 CommandSection(const std::string & title, bank_section_t index) : title(title), index(index){
95 if (index > 0){
96 drain::getCommandBank().sections.add(title, index);
97 //bank_section_t i = FlagResolver::getFreeBit(drain::getCommandBank().sections);
98
99 }
100 }
101
102
103};
104
106
107 inline
108 HiddenSection(): CommandSection("hidden", 0){
109 };
110
111};
112
114
115 inline
116 DeprecatingSection(): CommandSection("deprecating"){ // , 1){ // consider fixed number?
117 };
118
119};
120
121
123
124 inline
125 GeneralSection(): CommandSection("general"){ // , 2){
126 };
127
128};
129
130
132
133 inline
134 TriggerSection(): CommandSection("trigger"){ // , 4){
135 };
136
137};
138
139
140
141
142
143
144}
145
146
147/* namespace drain */
148
149#endif /* DRAINLET_H_ */
150
151// Rack
Definition CommandSections.h:54
CommandSection(const std::string &title, bank_section_t index)
Definition CommandSections.h:94
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition Log.h:312
Logger & debug(const TT &... args)
Debug information.
Definition Log.h:666
Definition DataSelector.cpp:1277
CommandBank & getCommandBank()
Global program command registry. Optional utility.
Definition CommandBank.cpp:51
Definition CommandSections.h:113
Definition CommandSections.h:122
Definition CommandSections.h:105
Definition CommandSections.h:131