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 
26 #include <memory>
27 #include <set>
28 #include <string>
29 #include <vector>
30 
32 
33 namespace armarx
34 {
35  class StatechartProfiles;
36  using StatechartProfilesPtr = std::shared_ptr<StatechartProfiles>;
37 
38  class StatechartProfile;
39  using StatechartProfilePtr = std::shared_ptr<StatechartProfile>;
40  using StatechartProfileWeakPtr = std::weak_ptr<StatechartProfile>;
41 
42  class StatechartProfile : 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:
68  std::vector<StatechartProfilePtr> children;
69  std::vector<std::string> packages;
70  std::string name;
71  std::string additionalProperties;
72  };
73 
75  {
76  public:
77  static std::string
79  {
80  return "Root";
81  }
82 
83 
84  public:
87 
88  static StatechartProfilesPtr ReadProfileFiles(const std::vector<std::string>& packages);
89 
90  std::vector<StatechartProfilePtr> getAllLeaves() const;
91  std::set<std::string> getAllLeafNames() const;
92  StatechartProfilePtr getProfileByName(std::string name);
94 
95  private:
96  StatechartProfilePtr rootProfile;
97  void getAllLeaves(StatechartProfilePtr currentProfile,
98  std::vector<StatechartProfilePtr>& profiles) const;
99  };
100 } // namespace armarx
armarx::RapidXmlReaderPtr
std::shared_ptr< RapidXmlReader > RapidXmlReaderPtr
Definition: RapidXmlReader.h:67
armarx::StatechartProfile::getAdditionalProperties
std::string getAdditionalProperties() const
Definition: StatechartProfiles.cpp:297
armarx::StatechartProfiles::getProfileByName
StatechartProfilePtr getProfileByName(std::string name)
Definition: StatechartProfiles.cpp:100
armarx::StatechartProfile
Definition: StatechartProfiles.h:42
armarx::StatechartProfileWeakPtr
std::weak_ptr< StatechartProfile > StatechartProfileWeakPtr
Definition: StatechartProfiles.h:40
armarx::StatechartProfile::getStatechartGroupPrefix
std::string getStatechartGroupPrefix() const
Definition: StatechartProfiles.cpp:291
armarx::StatechartProfilePtr
std::shared_ptr< class StatechartProfile > StatechartProfilePtr
Definition: StatechartContext.h:51
armarx::StatechartProfiles::getRootProfile
StatechartProfilePtr getRootProfile() const
Definition: StatechartProfiles.cpp:111
armarx::StatechartProfile::findByNameRecursive
StatechartProfilePtr findByNameRecursive(std::string name) const
Definition: StatechartProfiles.cpp:238
armarx::StatechartProfiles::getAllLeafNames
std::set< std::string > getAllLeafNames() const
Definition: StatechartProfiles.cpp:88
armarx::StatechartProfilesPtr
std::shared_ptr< StatechartProfiles > StatechartProfilesPtr
Definition: StatechartProfiles.h:36
armarx::StatechartProfile::StatechartProfile
StatechartProfile(const std::string &name, StatechartProfilePtr parent)
Definition: StatechartProfiles.cpp:133
armarx::StatechartProfiles
Definition: StatechartProfiles.h:74
armarx::StatechartProfile::getChildren
const std::vector< StatechartProfilePtr > & getChildren() const
Definition: StatechartProfiles.cpp:259
armarx::StatechartProfile::isLeaf
bool isLeaf() const
Definition: StatechartProfiles.cpp:180
armarx::StatechartProfile::getNesting
int getNesting() const
Definition: StatechartProfiles.cpp:285
armarx::StatechartProfiles::getAllLeaves
std::vector< StatechartProfilePtr > getAllLeaves() const
Definition: StatechartProfiles.cpp:80
armarx::RapidXmlReaderNode
Definition: RapidXmlReader.h:69
armarx::StatechartProfile::isRoot
bool isRoot() const
Definition: StatechartProfiles.cpp:186
armarx::StatechartProfile::getParent
StatechartProfilePtr getParent() const
Definition: StatechartProfiles.cpp:279
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:220
armarx::StatechartProfile::getAllPackages
std::vector< std::string > getAllPackages() const
Definition: StatechartProfiles.cpp:192
armarx::StatechartProfile::getName
std::string getName() const
Definition: StatechartProfiles.cpp:214
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:140
armarx::StatechartProfiles::readStatechartProfiles
void readStatechartProfiles(RapidXmlReaderPtr reader)
Definition: StatechartProfiles.cpp:40
armarx::StatechartProfile::getChildByName
StatechartProfilePtr getChildByName(std::string name) const
Definition: StatechartProfiles.cpp:265
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27