StateUtilFunctions.h
Go to the documentation of this file.
1/*
2* This file is part of ArmarX.
3*
4* Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5*
6* ArmarX is free software; you can redistribute it and/or modify
7* it under the terms of the GNU General Public License version 2 as
8* published by the Free Software Foundation.
9*
10* ArmarX is distributed in the hope that it will be useful, but
11* WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17*
18* @package ArmarX::
19* @author Mirko Waechter ( mirko.waechter at kit dot edu)
20* @date 2012
21* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22* GNU General Public License
23*/
24
25#pragma once
26
27
28#include <string>
29
30#include <ArmarXCore/interface/statechart/StatechartIce.h>
33
34
35//! this macro declares a new event-class derived vom Event, to have a compiletime check for typos in events
36#define DEFINEEVENT(NEWEVENT) \
37 struct NEWEVENT : Event \
38 { \
39 NEWEVENT(std::string eventReceiverName) : Event(eventReceiverName, #NEWEVENT) \
40 { \
41 } \
42 };
43
44namespace armarx
45{
46
47 class SingleTypeVariantList;
49
57
59 {
61 //! vector to store info data in
62 std::vector<std::string> infos;
63 };
64} // namespace armarx
65
67{
69 StringVariantContainerBaseMap getSetValues(const StateParameterMap& paramMap);
70 StringVariantContainerBaseMap getValues(const StateParameterMap& paramMap);
71
72
73 /*! \brief Sets all entries of the given dictionary to the stored default values
74
75 */
76 void unsetParameters(StateParameterMap& paramMap);
77 bool checkForCompleteParameters(const StateParameterMap& paramMap,
78 std::string* logOutput = nullptr);
79
80
81 /**
82 * @brief Waits for all ChannelRefs to be initialized in the given Map.
83 *
84 * Times out after some delay.
85 * @param paramMap parameter map, that is to be checked for initialized ChannelRefs
86 * @return true if all ChannelRef are initialized
87 */
88 bool waitForChannelRefs(const StateParameterMap& paramMap);
89
90 //! \brief Adds the (key,defaulfValue) pair to the event-dictionary. The type of the entry is determined with defaultValue.
91 //! \deprecated
92 bool addToDictionary(EventPtr event, const std::string key, const Variant& value);
93 bool addToDictionary(EventPtr event,
94 const std::string key,
95 const SingleTypeVariantListPtr& valueList);
96 //! \brief Checks whether the maps have equal keys and equal Types.
97 bool equalKeys(const StringVariantContainerBaseMap& dict1,
98 const StringVariantContainerBaseMap& dict2);
99 //! \brief Checks whether the maps have equal keys and equal Types.
100 bool equalKeys(const StateParameterMap& dict1, const StateParameterMap& dict2);
101 //! \brief Clears the destination map and copies the parameters of the source in it.
102 //! The copies have their own memory.
103 void copyDictionary(const StringVariantContainerBaseMap& source,
104 StringVariantContainerBaseMap& destination);
105 //! \brief Clears the destination map and copies the parameters of the source in it.
106 //! The copies have their own memory.
107 void copyDictionary(const StateParameterMap& source, StateParameterMap& destination);
108 //! \brief Clears the destination map and copies the parameters of the source in it.
109 //! The copies have their own memory.
110 void copyDictionary(const StateParameterMap& source,
111 StringVariantContainerBaseMap& destination);
112 //! \brief Clears the destination map and copies the parameters of the source in it.
113 //! The copies have their own memory.
114 void copyDictionary(const StringVariantContainerBaseMap& source,
115 StateParameterMap& destination);
116 //! \brief Tries to fill the destination map with matching entries of the source map. Entries that could not be found, are not changed.
117 void fillDictionary(const StringVariantContainerBaseMap& source,
118 StringVariantContainerBaseMap& destination);
119 //! \brief Tries to fill the destination map with matching entries of the source map. Entries that could not be found, are not changed.
120 void fillDictionary(const StringVariantContainerBaseMap& source,
121 StateParameterMap& destination);
122
123 //! Converts the map into a string-representation.
124 std::string getDictionaryString(const StringVariantContainerBaseMap& mymap);
125 //! Converts the map into a string-representation.
126 std::string getDictionaryString(const StateParameterMap& mymap);
127
128 std::string getVariantString(const VariantBasePtr& var, const std::string& name = "");
129 std::string getVariantString(const VariantPtr& var, const std::string& name = "");
130
131} // namespace armarx::StateUtilFunctions
The Variant class is described here: Variants.
Definition Variant.h:224
std::string getVariantString(const VariantBasePtr &var, const std::string &name="")
void copyDictionary(const StringVariantContainerBaseMap &source, StringVariantContainerBaseMap &destination)
Clears the destination map and copies the parameters of the source in it.
std::string transitionErrorToString(TransitionErrorType type)
std::string getDictionaryString(const StringVariantContainerBaseMap &mymap)
Converts the map into a string-representation.
StringVariantContainerBaseMap getValues(const StateParameterMap &paramMap)
bool checkForCompleteParameters(const StateParameterMap &paramMap, std::string *logOutput=nullptr)
void unsetParameters(StateParameterMap &paramMap)
Sets all entries of the given dictionary to the stored default values.
StringVariantContainerBaseMap getSetValues(const StateParameterMap &paramMap)
bool equalKeys(const StringVariantContainerBaseMap &dict1, const StringVariantContainerBaseMap &dict2)
Checks whether the maps have equal keys and equal Types.
void fillDictionary(const StringVariantContainerBaseMap &source, StringVariantContainerBaseMap &destination)
Tries to fill the destination map with matching entries of the source map. Entries that could not be ...
bool waitForChannelRefs(const StateParameterMap &paramMap)
Waits for all ChannelRefs to be initialized in the given Map.
bool addToDictionary(EventPtr event, const std::string key, const Variant &value)
Adds the (key,defaulfValue) pair to the event-dictionary.
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< SingleTypeVariantList > SingleTypeVariantListPtr
@ eTransitionErrorUnexpectedEvent
@ eTransitionErrorUndefined
IceInternal::Handle< Variant > VariantPtr
Definition Variant.h:41
::IceInternal::Handle<::armarx::VariantBase > VariantBasePtr
IceInternal::Handle< Event > EventPtr
Typedef of EventPtr as IceInternal::Handle<Event> for convenience.
Definition Event.h:40
std::vector< std::string > infos
vector to store info data in
TransitionErrorType errorType