StatechartProfiles.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
19  * @author
20  * @date
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 #pragma once
25 
27 #include <vector>
28 #include <string>
29 #include <set>
30 #include <memory>
31 
32 namespace armarx
33 {
34  class StatechartProfiles;
35  using StatechartProfilesPtr = std::shared_ptr<StatechartProfiles>;
36 
37  class StatechartProfile;
38  using StatechartProfilePtr = std::shared_ptr<StatechartProfile>;
39  using StatechartProfileWeakPtr = std::weak_ptr<StatechartProfile>;
40 
42  : public std::enable_shared_from_this<StatechartProfile>
43  {
44  friend class StatechartProfiles;
45 
46  public:
47  StatechartProfile(const std::string& name, StatechartProfilePtr parent);
49  bool isLeaf() const;
50  bool isRoot() const;
51  std::vector<std::string> getAllPackages() const;
52  std::string getName() const;
53  /**
54  * @brief Returns name of profile with all parents in the form of
55  * *Root::Armar3Base::Armar3Simualation* if *Armar3Simulation* is the current profile.
56  */
57  std::string getFullName() const;
58  StatechartProfilePtr findByNameRecursive(std::string name) const;
59  const std::vector<StatechartProfilePtr>& getChildren() const;
60  StatechartProfilePtr getChildByName(std::string name) const;
62  int getNesting() const;
63  std::string getStatechartGroupPrefix() const;
64  std::string getAdditionalProperties() const;
65 
66  private:
67 
69  std::vector<StatechartProfilePtr> children;
70  std::vector<std::string> packages;
71  std::string name;
72  std::string additionalProperties;
73  };
74 
76  {
77  public:
78  static std::string GetRootName()
79  {
80  return "Root";
81  }
82 
83 
84 
85  public:
88 
89  static StatechartProfilesPtr ReadProfileFiles(const std::vector<std::string>& packages);
90 
91  std::vector<StatechartProfilePtr> getAllLeaves() const;
92  std::set<std::string> getAllLeafNames() const;
93  StatechartProfilePtr getProfileByName(std::string name);
95  private:
96  StatechartProfilePtr rootProfile;
97  void getAllLeaves(StatechartProfilePtr currentProfile, std::vector<StatechartProfilePtr>& profiles) const;
98  };
99 }
100 
armarx::RapidXmlReaderPtr
std::shared_ptr< RapidXmlReader > RapidXmlReaderPtr
Definition: RapidXmlReader.h:66
armarx::StatechartProfile::getAdditionalProperties
std::string getAdditionalProperties() const
Definition: StatechartProfiles.cpp:274
armarx::StatechartProfiles::getProfileByName
StatechartProfilePtr getProfileByName(std::string name)
Definition: StatechartProfiles.cpp:96
armarx::StatechartProfile
Definition: StatechartProfiles.h:41
armarx::StatechartProfileWeakPtr
std::weak_ptr< StatechartProfile > StatechartProfileWeakPtr
Definition: StatechartProfiles.h:39
armarx::StatechartProfile::getStatechartGroupPrefix
std::string getStatechartGroupPrefix() const
Definition: StatechartProfiles.cpp:269
armarx::StatechartProfilePtr
std::shared_ptr< class StatechartProfile > StatechartProfilePtr
Definition: StatechartContext.h:52
armarx::StatechartProfiles::getRootProfile
StatechartProfilePtr getRootProfile() const
Definition: StatechartProfiles.cpp:106
armarx::StatechartProfile::findByNameRecursive
StatechartProfilePtr findByNameRecursive(std::string name) const
Definition: StatechartProfiles.cpp:221
armarx::StatechartProfiles::getAllLeafNames
std::set< std::string > getAllLeafNames() const
Definition: StatechartProfiles.cpp:85
armarx::StatechartProfilesPtr
std::shared_ptr< StatechartProfiles > StatechartProfilesPtr
Definition: StatechartProfiles.h:35
armarx::StatechartProfile::StatechartProfile
StatechartProfile(const std::string &name, StatechartProfilePtr parent)
Definition: StatechartProfiles.cpp:127
armarx::StatechartProfiles
Definition: StatechartProfiles.h:75
armarx::StatechartProfile::getChildren
const std::vector< StatechartProfilePtr > & getChildren() const
Definition: StatechartProfiles.cpp:241
armarx::StatechartProfile::isLeaf
bool isLeaf() const
Definition: StatechartProfiles.cpp:168
armarx::StatechartProfile::getNesting
int getNesting() const
Definition: StatechartProfiles.cpp:264
armarx::StatechartProfiles::getAllLeaves
std::vector< StatechartProfilePtr > getAllLeaves() const
Definition: StatechartProfiles.cpp:78
armarx::RapidXmlReaderNode
Definition: RapidXmlReader.h:68
armarx::StatechartProfile::isRoot
bool isRoot() const
Definition: StatechartProfiles.cpp:173
armarx::StatechartProfile::getParent
StatechartProfilePtr getParent() const
Definition: StatechartProfiles.cpp:259
armarx::StatechartProfiles::StatechartProfiles
StatechartProfiles()
Definition: StatechartProfiles.cpp:34
armarx::StatechartProfile::getFullName
std::string getFullName() const
Returns name of profile with all parents in the form of Root::Armar3Base::Armar3Simualation if Armar3...
Definition: StatechartProfiles.cpp:204
armarx::StatechartProfile::getAllPackages
std::vector< std::string > getAllPackages() const
Definition: StatechartProfiles.cpp:178
armarx::StatechartProfile::getName
std::string getName() const
Definition: StatechartProfiles.cpp:199
RapidXmlReader.h
armarx::StatechartProfiles::GetRootName
static std::string GetRootName()
Definition: StatechartProfiles.h:78
armarx::StatechartProfiles::ReadProfileFiles
static StatechartProfilesPtr ReadProfileFiles(const std::vector< std::string > &packages)
Definition: StatechartProfiles.cpp:47
armarx::StatechartProfile::readFromXml
void readFromXml(RapidXmlReaderNode node)
Definition: StatechartProfiles.cpp:133
armarx::StatechartProfiles::readStatechartProfiles
void readStatechartProfiles(RapidXmlReaderPtr reader)
Definition: StatechartProfiles.cpp:39
armarx::StatechartProfile::getChildByName
StatechartProfilePtr getChildByName(std::string name) const
Definition: StatechartProfiles.cpp:246
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28