TransferPropertiesBehavior.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013-2016, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_FRAMEWORK_TRANSFERPROPERTIESBEHAVIOR_H
#define SURGSIM_FRAMEWORK_TRANSFERPROPERTIESBEHAVIOR_H
#include <boost/thread/mutex.hpp>
#include <string>
#include "SurgSim/Framework/Accessible.h"
#include "SurgSim/Framework/Behavior.h"
namespace SurgSim
{
namespace Framework
{
class TransferPropertiesBehavior : public SurgSim::Framework::Behavior
{
public:
explicit TransferPropertiesBehavior(const std::string& name);
virtual ~TransferPropertiesBehavior();
bool connect(
std::shared_ptr<SurgSim::Framework::Accessible> sourceAccessible,
const std::string& sourcePropertyName,
std::shared_ptr<SurgSim::Framework::Accessible> tagetAccessible,
const std::string& targetPropertyName);
bool connect(const Property& source, const Property& target);
void setTargetManagerType(int managerType);
int getTargetManagerType() const override;
void update(double dt) override;
private:
bool doInitialize() override;
bool doWakeUp() override;
typedef std::pair<Property, Property> Connection;
std::vector<Connection> m_connections;
boost::mutex m_incomingMutex;
std::vector<Connection> m_incomingConnections;
int m_targetManager;
};
}
}
#endif
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Framework::TransferPropertiesBehavior::doWakeUp
bool doWakeUp() override
Definition: TransferPropertiesBehavior.cpp:107
SurgSim::Framework::TransferPropertiesBehavior::m_targetManager
int m_targetManager
The manager type that will handle this behavior.
Definition: TransferPropertiesBehavior.h:100
SurgSim::Framework::TransferPropertiesBehavior::TransferPropertiesBehavior
TransferPropertiesBehavior(const std::string &name)
Constructor.
Definition: TransferPropertiesBehavior.cpp:26
Accessible.h
SurgSim::Framework::TransferPropertiesBehavior::m_incomingMutex
boost::mutex m_incomingMutex
Lock for adding new connections.
Definition: TransferPropertiesBehavior.h:94
SurgSim::Framework::TransferPropertiesBehavior::Connection
std::pair< Property, Property > Connection
Local typedefs.
Definition: TransferPropertiesBehavior.h:88
SurgSim::Framework::Property
Public struct to pair an accessible with its appropriate property.
Definition: Accessible.h:178
SurgSim::Framework::TransferPropertiesBehavior::getTargetManagerType
int getTargetManagerType() const override
Specifies which manger will handle this behavior.
Definition: TransferPropertiesBehavior.cpp:121
Behavior.h
SurgSim::Framework::TransferPropertiesBehavior::~TransferPropertiesBehavior
virtual ~TransferPropertiesBehavior()
Destructor.
Definition: TransferPropertiesBehavior.cpp:33
SurgSim::Framework::TransferPropertiesBehavior::m_connections
std::vector< Connection > m_connections
List of connections in this object.
Definition: TransferPropertiesBehavior.h:91
SurgSim::Framework::TransferPropertiesBehavior::doInitialize
bool doInitialize() override
Definition: TransferPropertiesBehavior.cpp:102
SurgSim::Framework::Behavior
Behaviors perform actions.
Definition: Behavior.h:40
SurgSim::Framework::TransferPropertiesBehavior
Behavior to copy properties between instances of Accessible.
Definition: TransferPropertiesBehavior.h:33
SurgSim::Framework::TransferPropertiesBehavior::update
void update(double dt) override
Update the behavior.
Definition: TransferPropertiesBehavior.cpp:38
SurgSim::Framework::TransferPropertiesBehavior::connect
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
SurgSim::Framework::TransferPropertiesBehavior::setTargetManagerType
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
SurgSim::Framework::TransferPropertiesBehavior::m_incomingConnections
std::vector< Connection > m_incomingConnections
Queue for adding new connections.
Definition: TransferPropertiesBehavior.h:97