Chain.hpp
1 /*---------------------------------------------------------------------------*\
2  *
3  * mimmo
4  *
5  * Copyright (C) 2015-2021OPTIMAD engineering Srl
6  *
7  * -------------------------------------------------------------------------
8  * License
9  * This file is part of mimmo.
10  *
11  * mimmo is free software: you can redistribute it and/or modify it
12  * under the terms of the GNU Lesser General Public License v3 (LGPL)
13  * as published by the Free Software Foundation.
14  *
15  * mimmo is distributed in the hope that it will be useful, but WITHOUT
16  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18  * License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with mimmo. If not, see <http://www.gnu.org/licenses/>.
22  *
23 \*---------------------------------------------------------------------------*/
24 #ifndef __CHAIN_HPP__
25 #define __CHAIN_HPP__
26 
27 #include "BaseManipulation.hpp"
28 #include <memory>
29 
30 namespace mimmo{
31 
48 class Chain{
49 
50 protected:
51  //members
52  uint8_t m_id;
53  std::vector<BaseManipulation*> m_objects;
54  std::vector<int> m_idObjects;
55  uint32_t m_objcounter;
57  bitpit::Logger* m_log;
59  bool m_plotDebRes;
60  std::string m_outputDebRes;
61  //static members
62  static uint8_t sm_chaincounter;
65 public:
66  Chain();
67  virtual ~Chain();
68 
69  std::unique_ptr<Chain> clone() const;
70 
71  //get/set methods
72  uint32_t getNObjects();
73  uint8_t getID();
74  uint8_t getNChains();
75  int getID(int i);
76  std::string getName(int i);
77 
78  int addObject(BaseManipulation* obj, int id_ = -1);
79 
80  bool deleteObject(int idobj);
81  void clear();
82 
83  void setPlotDebugResults(bool active);
84  void setOutputDebugResults(std::string path);
86  std::string getOutputDebugResults();
87 
88  //relationship methods
89  void exec(bool debug = false);
90  void exec(int idobj);
91 
92 protected:
93  void swap(Chain &x) noexcept;
94  //check methods
95  void checkLoops();
96 
97 private:
98  // preventing copy constr and assignment. use clone instead.
99  Chain(const Chain & other);
100  Chain & operator=(const Chain & other);
101 };
102 
103 }
104 
105 
106 #endif /* __CHAIN_HPP__ */
void exec(bool debug=false)
Definition: Chain.cpp:284
uint32_t m_objcounter
Definition: Chain.hpp:55
uint8_t getID()
Definition: Chain.cpp:110
uint8_t m_id
Definition: Chain.hpp:52
Chain is the class used to manage the chain execution of multiple executable blocks (manipulation obj...
Definition: Chain.hpp:48
uint32_t getNObjects()
Definition: Chain.cpp:101
void swap(Chain &x) noexcept
Definition: Chain.cpp:58
std::string m_outputDebRes
Definition: Chain.hpp:60
std::unique_ptr< Chain > clone() const
Definition: Chain.cpp:71
std::string getName(int i)
Definition: Chain.cpp:139
virtual ~Chain()
Definition: Chain.cpp:49
uint8_t getNChains()
Definition: Chain.cpp:119
std::vector< int > m_idObjects
Definition: Chain.hpp:54
BaseManipulation is the base class of any manipulation object of the library.
std::string getOutputDebugResults()
Definition: Chain.cpp:271
bitpit::Logger * m_log
Definition: Chain.hpp:57
void clear()
Definition: Chain.cpp:90
void setOutputDebugResults(std::string path)
Definition: Chain.cpp:256
void setPlotDebugResults(bool active)
Definition: Chain.cpp:248
std::vector< BaseManipulation * > m_objects
Definition: Chain.hpp:53
static uint8_t sm_chaincounter
Definition: Chain.hpp:62
int addObject(BaseManipulation *obj, int id_=-1)
Definition: Chain.cpp:170
bool deleteObject(int idobj)
Definition: Chain.cpp:148
bool isPlottingDebugResults()
Definition: Chain.cpp:263
bool m_plotDebRes
Definition: Chain.hpp:59
void checkLoops()
Definition: Chain.cpp:337