WB-Toolbox  5.6.1
ASimulinkToolboxforWholeBodyControl
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WholeBodySingleton.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * GNU Lesser General Public License v2.1 or any later version.
7  */
8 
9 #ifndef WBT_WHOLEBODYSINGLETON_H
10 #define WBT_WHOLEBODYSINGLETON_H
11 
12 #include <memory>
13 #include <string>
14 #include <unordered_map>
15 
16 namespace wbt {
17  namespace base {
18  class WholeBodySingleton;
19  class RobotInterface;
20  class Configuration;
21  } // namespace base
22 } // namespace wbt
23 
24 namespace blockfactory {
25  namespace core {
26  class Parameters;
27  } // namespace core
28 } // namespace blockfactory
29 
30 namespace iDynTree {
31  class KinDynComputations;
32 }
33 
45 {
46 private:
50  std::unordered_map<std::string, std::weak_ptr<wbt::base::RobotInterface>> m_interfaces;
51 
52 public:
53  // CONSTRUCTOR / DESTRUCTOR
54  // ========================
55 
58 
59  WholeBodySingleton(const WholeBodySingleton&) = delete;
61 
62  // UTILITIES
63  // =========
64 
72  bool isKeyValid(const std::string& confKey) const;
73 
80  int numberOfDoFs(const std::string& confKey) const;
81 
82  // GET METHODS
83  // ===========
84 
95 
104  const Configuration& getConfiguration(const std::string& confKey) const;
105 
113  const std::shared_ptr<RobotInterface> getRobotInterface(const std::string& confKey) const;
114 
123  const std::shared_ptr<iDynTree::KinDynComputations>
124  getKinDynComputations(const std::string& confKey) const;
125 
126  // WHOLEBODYSINGLETON CONFIGURATION
127  // ================================
128 
144  std::shared_ptr<RobotInterface> createRobotInterface(const Configuration& config);
145 
155  std::shared_ptr<RobotInterface>
156  storeConfiguration(const blockfactory::core::Parameters& parameters);
157 
163  void eraseConfiguration(const std::string& confKey);
164 };
165 
166 #endif // WBT_WHOLEBODYSINGLETON_H
wbt::base::WholeBodySingleton::sharedInstance
static wbt::base::WholeBodySingleton & sharedInstance()
Definition: WholeBodySingleton.cpp:65
wbt::base::WholeBodySingleton::m_interfaces
std::unordered_map< std::string, std::weak_ptr< wbt::base::RobotInterface > > m_interfaces
Definition: WholeBodySingleton.h:50
wbt::base::WholeBodySingleton::getKinDynComputations
const std::shared_ptr< iDynTree::KinDynComputations > getKinDynComputations(const std::string &confKey) const
Definition: WholeBodySingleton.cpp:87
wbt::base::WholeBodySingleton::numberOfDoFs
int numberOfDoFs(const std::string &confKey) const
Definition: WholeBodySingleton.cpp:37
wbt::base::WholeBodySingleton
Definition: WholeBodySingleton.h:44
wbt::base::WholeBodySingleton::~WholeBodySingleton
~WholeBodySingleton()
wbt
Definition: Configuration.h:17
wbt::base::WholeBodySingleton::createRobotInterface
std::shared_ptr< RobotInterface > createRobotInterface(const Configuration &config)
Definition: WholeBodySingleton.cpp:100
wbt::base::WholeBodySingleton::getConfiguration
const Configuration & getConfiguration(const std::string &confKey) const
Definition: WholeBodySingleton.cpp:71
wbt::base::WholeBodySingleton::isKeyValid
bool isKeyValid(const std::string &confKey) const
Definition: WholeBodySingleton.cpp:46
wbt::base::WholeBodySingleton::operator=
WholeBodySingleton & operator=(const WholeBodySingleton &)=delete
wbt::base::WholeBodySingleton::storeConfiguration
std::shared_ptr< RobotInterface > storeConfiguration(const blockfactory::core::Parameters &parameters)
Definition: WholeBodySingleton.cpp:187
wbt::base::WholeBodySingleton::WholeBodySingleton
WholeBodySingleton()
iDynTree
Definition: RobotInterface.h:33
blockfactory
Definition: WBBlock.h:16
wbt::base::Configuration
Store the configuration for whole-body blocks.
Definition: Configuration.h:36
wbt::base::WholeBodySingleton::getRobotInterface
const std::shared_ptr< RobotInterface > getRobotInterface(const std::string &confKey) const
Definition: WholeBodySingleton.cpp:77
wbt::base::WholeBodySingleton::eraseConfiguration
void eraseConfiguration(const std::string &confKey)
Definition: WholeBodySingleton.cpp:215