TransferPropertiesBehavior.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_FRAMEWORK_TRANSFERPROPERTIESBEHAVIOR_H
17 #define SURGSIM_FRAMEWORK_TRANSFERPROPERTIESBEHAVIOR_H
18 
19 #include <string>
20 
23 
24 #include <boost/thread/mutex.hpp>
25 
26 namespace SurgSim
27 {
28 namespace Framework
29 {
30 
34 {
35 public:
36 
39  explicit TransferPropertiesBehavior(const std::string& name);
40 
43 
54  bool connect(
55  std::shared_ptr<SurgSim::Framework::Accessible> sourceAccessible,
56  const std::string& sourcePropertyName,
57  std::shared_ptr<SurgSim::Framework::Accessible> tagetAccessible,
58  const std::string& targetPropertyName);
59 
68  bool connect(const Property& source, const Property& target);
69 
73  void setTargetManagerType(int managerType);
74 
77  virtual void update(double dt) override;
78 
79 private:
80 
83  virtual bool doInitialize() override;
84  virtual bool doWakeUp() override;
85  virtual int getTargetManagerType() const;
87 
89  typedef std::pair<Property, Property> Connection;
90 
92  std::vector<Connection> m_connections;
93 
95  boost::mutex m_incomingMutex;
96 
98  std::vector<Connection> m_incomingConnections;
100 };
101 
102 }
103 }
104 
105 #endif
Definition: DriveElementFromInputBehavior.cpp:27
virtual bool doWakeUp() override
Definition: TransferPropertiesBehavior.cpp:107
int m_targetManager
Definition: TransferPropertiesBehavior.h:99
TransferPropertiesBehavior(const std::string &name)
Constructor.
Definition: TransferPropertiesBehavior.cpp:26
boost::mutex m_incomingMutex
Lock for adding new connections.
Definition: TransferPropertiesBehavior.h:95
std::pair< Property, Property > Connection
Local typedefs.
Definition: TransferPropertiesBehavior.h:89
Public struct to pair an accessible with its appropriate property.
Definition: Accessible.h:170
string(TOUPPER ${DEVICE}DEVICE_UPPER_CASE) option(BUILD_DEVICE_ $
Definition: CMakeLists.txt:35
virtual ~TransferPropertiesBehavior()
Destructor.
Definition: TransferPropertiesBehavior.cpp:33
std::vector< Connection > m_connections
List of connections in this object.
Definition: TransferPropertiesBehavior.h:92
virtual int getTargetManagerType() const
Definition: TransferPropertiesBehavior.cpp:121
virtual bool doInitialize() override
Definition: TransferPropertiesBehavior.cpp:102
Behaviors perform actions.
Definition: Behavior.h:40
Behavior to copy properties between instances of Accessible.
Definition: TransferPropertiesBehavior.h:33
virtual void update(double dt) override
Overridden from Behavior.
Definition: TransferPropertiesBehavior.cpp:38
bool connect(std::shared_ptr< SurgSim::Framework::Accessible > sourceAccessible, const std::string &sourcePropertyName, std::shared_ptr< SurgSim::Framework::Accessible > tagetAccessible, const std::string &targetPropertyName)
Connect two properties of two instances of accessible, once connected the value of the property will ...
Definition: TransferPropertiesBehavior.cpp:57
void setTargetManagerType(int managerType)
Sets the type of manager that this behavior should use, this cannot be done after initialization has ...
Definition: TransferPropertiesBehavior.cpp:114
std::vector< Connection > m_incomingConnections
Queue for adding new connections.
Definition: TransferPropertiesBehavior.h:98