1 #ifndef MHO_IndexLabelInterface_HH__
2 #define MHO_IndexLabelInterface_HH__
56 fIndexLabelObjectPtr->clear();
67 template<
typename XValueType >
70 if(fIndexLabelObjectPtr !=
nullptr)
72 std::string ikey = index2key(index);
73 if(!(fIndexLabelObjectPtr->contains(ikey)))
76 (*fIndexLabelObjectPtr).emplace(ikey, fDummy);
77 (*fIndexLabelObjectPtr)[ikey][
"index"] = index;
82 (*fIndexLabelObjectPtr)[ikey].update(obj);
86 msg_error(
"utilities",
"cannot insert key:value pair, index label interface is missing object!" << eom);
99 template<
typename XValueType >
102 if(fIndexLabelObjectPtr !=
nullptr)
104 std::string ikey = index2key(index);
105 if((*fIndexLabelObjectPtr)[ikey].contains(key))
107 value = (*fIndexLabelObjectPtr)[ikey][key].get< XValueType >();
113 msg_error(
"utilities",
"cannot retrieve key:value pair, index label interface is missing object!" << eom);
126 if(fIndexLabelObjectPtr !=
nullptr)
132 if(!(fIndexLabelObjectPtr->is_object()))
134 (*fIndexLabelObjectPtr) =
mho_json();
136 std::string ikey = index2key(index);
137 if(!(fIndexLabelObjectPtr->contains(ikey)))
141 (*fIndexLabelObjectPtr)[ikey] = fDummy;
142 (*fIndexLabelObjectPtr)[ikey][
"index"] = index;
146 obj[
"index"] = index;
147 (*fIndexLabelObjectPtr)[ikey].update(obj);
151 msg_error(
"utilities",
"cannot insert label object, index label interface is missing object!" << eom);
163 if(fIndexLabelObjectPtr !=
nullptr)
165 std::string ikey = index2key(index);
166 return (*fIndexLabelObjectPtr)[ikey];
170 msg_error(
"utilities",
"cannot retrieve label object, index label interface is missing object!" << eom);
183 if(fIndexLabelObjectPtr !=
nullptr)
185 std::string ikey = index2key(index);
186 return (*fIndexLabelObjectPtr)[ikey];
190 msg_error(
"utilities",
"cannot retrieve label object, index label interface is missing object!" << eom);
203 std::vector< std::size_t > idx;
204 if(fIndexLabelObjectPtr !=
nullptr)
206 for(std::size_t i = 0; i < fIndexLabelObjectPtr->size(); i++)
208 std::string ikey = index2key(i);
209 if((*fIndexLabelObjectPtr)[ikey].contains(key))
217 msg_error(
"utilities",
"cannot determine matching indexes, index label interface is missing object!" << eom);
230 template<
typename XValueType >
233 std::vector< std::size_t > idx;
234 if(fIndexLabelObjectPtr !=
nullptr)
236 for(std::size_t i = 0; i < fIndexLabelObjectPtr->size(); i++)
238 std::string ikey = index2key(i);
239 if((*fIndexLabelObjectPtr)[ikey].contains(key))
241 XValueType v = (*fIndexLabelObjectPtr)[ikey][key].get< XValueType >();
251 msg_error(
"utilities",
"cannot determine matching indexes, index label interface is missing object!" << eom);
265 static std::string index2key(
const std::size_t& idx) {
return std::to_string(idx); }
#define msg_error(xKEY, xCONTENT)
Definition: MHO_Message.hh:244
Class MHO_IndexLabelInterface - adds indexes associated with key:value pairs (used by MHO_Axis) const...
Definition: MHO_IndexLabelInterface.hh:23
std::size_t GetIndexLabelSize() const
Getter for index label size.
Definition: MHO_IndexLabelInterface.hh:48
std::vector< std::size_t > GetMatchingIndexes(std::string &key, const XValueType &value) const
Get a vector of indexes which contain a key with a value which matches the passed value.
Definition: MHO_IndexLabelInterface.hh:231
bool RetrieveIndexLabelKeyValue(std::size_t index, const std::string &key, XValueType &value) const
Retrieves value associated with given key and index from IndexLabelObjectPtr if it exists.
Definition: MHO_IndexLabelInterface.hh:100
mho_json & GetLabelObject(std::size_t index)
get a reference to the dictionary object associated with this index
Definition: MHO_IndexLabelInterface.hh:161
virtual ~MHO_IndexLabelInterface()
Definition: MHO_IndexLabelInterface.hh:41
void SetLabelObject(mho_json &obj, std::size_t index)
get a reference to the dictionary object associated with this index
Definition: MHO_IndexLabelInterface.hh:124
void SetIndexLabelObject(mho_json *obj)
Setter for index label object.
Definition: MHO_IndexLabelInterface.hh:38
void InsertIndexLabelKeyValue(std::size_t index, const std::string &key, const XValueType &value)
Function InsertIndexLabelKeyValue.
Definition: MHO_IndexLabelInterface.hh:68
std::vector< std::size_t > GetMatchingIndexes(std::string &key) const
get a vector of indexes which contain a key with the same name
Definition: MHO_IndexLabelInterface.hh:201
MHO_IndexLabelInterface(const MHO_IndexLabelInterface ©)
Definition: MHO_IndexLabelInterface.hh:31
mho_json GetLabelObject(std::size_t index) const
Getter for label object.
Definition: MHO_IndexLabelInterface.hh:181
void ClearIndexLabels()
Clears all index labels.
Definition: MHO_IndexLabelInterface.hh:53
MHO_IndexLabelInterface()
Definition: MHO_IndexLabelInterface.hh:26
Definition: MHO_ChannelLabeler.hh:17