Commit 7af05629 authored by Flavien BRIDAULT-LOUCHEZ's avatar Flavien BRIDAULT-LOUCHEZ
Browse files

merge(dev): release 12.0.1

parents 30cdb025 f59b1d91
/* ***** BEGIN LICENSE BLOCK *****
* FW4SPL - Copyright (C) IRCAD, 2009-2015.
* Distributed under the terms of the GNU Lesser General Public License (LGPL) as
* published by the Free Software Foundation.
* ****** END LICENSE BLOCK ****** */
#ifndef __CTRLSELECTION_MANAGER_NAMESPACE_HPP__
#define __CTRLSELECTION_MANAGER_NAMESPACE_HPP__
namespace ctrlSelection
{
}
#endif /* __CTRLSELECTION_MANAGER_NAMESPACE_HPP__ */
/* ***** BEGIN LICENSE BLOCK *****
* FW4SPL - Copyright (C) IRCAD, 2009-2017.
* Distributed under the terms of the GNU Lesser General Public License (LGPL) as
* published by the Free Software Foundation.
* ****** END LICENSE BLOCK ****** */
#ifndef __CTRLSELECTION_MANAGER_SFIELD_HPP__
#define __CTRLSELECTION_MANAGER_SFIELD_HPP__
#include "ctrlSelection/IManagerSrv.hpp"
#include "ctrlSelection/config.hpp"
#include <fwRuntime/ConfigurationElement.hpp>
#include <fwServices/IService.hpp>
namespace ctrlSelection
{
namespace manager
{
/**
* @brief This services is a manager which starts, stops or swaps services on field contained in a composite when
* it receive specific message (mainly sent by updater).
*/
class CTRLSELECTION_CLASS_API SField : public ::ctrlSelection::IManagerSrv
{
public:
fwCoreServiceClassDefinitionsMacro( (SField)(::ctrlSelection::IManagerSrv) );
/// Constructor. Do nothing.
CTRLSELECTION_API SField() noexcept;
/// Destructor. Do nothing.
CTRLSELECTION_API virtual ~SField() noexcept;
/**
* @brief Returns proposals to connect service slots to associated object signals,
* this method is used for obj/srv auto connection
*
* Connect Object::s_ADDED_FIELDS_SIG to this::s_ADD_FIELDS_SLOT
* Connect Object::s_CHANGED_FIELDS_SIG to this::s_CHANGE_FIELDS_SLOT
* Connect Object::s_REMOVED_FIELDS_SIG to this::s_REMOVE_FIELDS_SLOT
*/
CTRLSELECTION_API virtual KeyConnectionsType getObjSrvConnections() const;
protected:
/// Implements starting method derived from IService. Starts the managed services if their fields are in the
// composite.
/// If the mode is "dummy", starts the the managed services on dummy fields if their fields are not in the
// composite.
CTRLSELECTION_API virtual void starting();
/// Implements stopping method derived from IService. Stops and erases all the managed services.
CTRLSELECTION_API virtual void stopping();
/**
* @brief Implements configuring method derived from IService. .
*
* Sample of declaration configuration for a simple swapper service
*
* @code{.xml}
<service uid="FieldManager" impl="::ctrlSelection::manager::SField" type="::ctrlSelection::IManagerSrv"
* autoConnect="yes" >
<mode type="dummy" />
<config>
<field id="TFSelection" type="::fwData::TransferFunction" >
<service uid="myServices" impl="..." type="..." autoConnect="yes" />
<connect>
<signal>key</signal>
<slot>uid/key</slot>
</connect>
</field>
<field id="AxialSliceIndex" type="::fwData::Integer" >
<service uid="Services2" impl="..." type="..." autoConnect="yes" worker="myThread" />
<proxy channel="...">
<signal>...</signal>
<signal>.../...</signal>
<slot>.../...</slot>
<slot>.../...</slot>
</proxy>
</field>
</config>
</service>
@endcode
* With:
* @li mode : must be "stop" or "dummy". The dummy mode doesn't stop the services when its attached field is deleted
* but swap it on a dummy field.
* @li the fields, services, connect and proxy tags are defined as same as the configuration of fields and services.
* @li autoConnect: optional (default value = false), if true allows to listen signals from the associated object.
* @li worker: optional, allows to manage the service in another thread.
*/
CTRLSELECTION_API virtual void configuring();
/// Implements reconfiguring method derived from IService. Do nothing.
CTRLSELECTION_API virtual void reconfiguring();
/// Implements updating method derived from IService. Do nothing.
CTRLSELECTION_API virtual void updating();
/// Implements info method derived from IService. Print classname.
CTRLSELECTION_API virtual void info( std::ostream& _sstream );
typedef ::fwRuntime::ConfigurationElement::sptr ConfigurationType;
typedef ::fwData::Object::FieldNameType FieldNameType;
class SubService
{
public:
SubService() :
m_hasAutoConnection(false)
{
}
~SubService()
{
}
SPTR(::fwServices::IService) getService()
{
return m_service.lock();
}
::fwData::Object::sptr m_dummy;
ConfigurationType m_config;
WPTR(::fwServices::IService) m_service;
::fwCom::helper::SigSlotConnection m_connections;
bool m_hasAutoConnection;
};
typedef std::vector< SPTR(SubService) > SubServicesVecType;
typedef std::map< FieldNameType, SubServicesVecType > SubServicesMapType;
void initOnDummyObject( const FieldNameType& fieldName );
void addField( const FieldNameType& fieldName, ::fwData::Object::sptr field );
void swapField(const FieldNameType& fieldName, ::fwData::Object::sptr field);
void removeField( const FieldNameType& fieldName );
/// Slot: add objects
void addFields(::fwData::Object::FieldsContainerType fields);
/// Slot: change objects
void changeFields(::fwData::Object::FieldsContainerType newFields, ::fwData::Object::FieldsContainerType oldFields);
/// Slot: remove objects
void removeFields(::fwData::Object::FieldsContainerType fields);
::fwServices::IService::sptr add( ::fwData::Object::sptr obj, ::fwRuntime::ConfigurationElement::sptr _elt );
private:
std::string m_mode;
bool m_dummyStopMode;
ConfigurationType m_managerConfiguration;
SubServicesMapType m_fieldsSubServices;
};
} // manager
} // ctrlSelection
#endif // __CTRLSELECTION_MANAGER_SFIELD_HPP__
/* ***** BEGIN LICENSE BLOCK *****
* FW4SPL - Copyright (C) IRCAD, 2009-2016.
* Distributed under the terms of the GNU Lesser General Public License (LGPL) as
* published by the Free Software Foundation.
* ****** END LICENSE BLOCK ****** */
#ifndef __CTRLSELECTION_MANAGER_SWAPPERSRV_HPP__
#define __CTRLSELECTION_MANAGER_SWAPPERSRV_HPP__
#include "ctrlSelection/IManagerSrv.hpp"
#include "ctrlSelection/config.hpp"
#include <fwCom/helper/SigSlotConnection.hpp>
#include <fwData/Composite.hpp>
#include <fwRuntime/ConfigurationElement.hpp>
#include <fwServices/IService.hpp>
namespace ctrlSelection
{
namespace manager
{
/**
* @brief This services is a manager which starts, stops or swaps services on object contained in a composite when
* it receive specific message (mainly sent by updater).
*/
class CTRLSELECTION_CLASS_API SwapperSrv : public ::ctrlSelection::IManagerSrv
{
public:
fwCoreServiceClassDefinitionsMacro ( (SwapperSrv)(::ctrlSelection::IManagerSrv) );
/// Constructor. Do nothing.
CTRLSELECTION_API SwapperSrv() noexcept;
/// Destructor. Do nothing.
CTRLSELECTION_API virtual ~SwapperSrv() noexcept;
/**
* @brief Returns proposals to connect service slots to associated object signals,
* this method is used for obj/srv auto connection
*
* Connect Composite::s_ADDED_OBJECTS_SIG to this::s_ADD_OBJECTS_SLOT
* Connect Composite::s_CHANGED_OBJECTS_SIG to this::s_CHANGE_OBJECTS_SLOT
* Connect Composite::s_REMOVED_OBJECTS_SIG to this::s_REMOVE_OBJECTS_SLOT
*/
CTRLSELECTION_API virtual KeyConnectionsType getObjSrvConnections() const;
protected:
/// Implements starting method derived from IService. Starts the managed services if their objects are in the composite.
/// If the mode is "dummy", starts the the managed services on dummy objects if their objects are not in the composite.
CTRLSELECTION_API virtual void starting();
/// Implements stopping method derived from IService. Stops and erases all the managed services.
CTRLSELECTION_API virtual void stopping();
/**
* @brief Implements configuring method derived from IService. .
*
* Sample of declaration configuration for a simple swapper service
*
* @code{.xml}
<service uid="myManager" impl="::ctrlSelection::manager::SwapperSrv" type="::ctrlSelection::IManagerSrv" autoConnect="yes" >
<mode type="dummy" />
<config>
<object id="myImage" type="::fwData::Image" >
<service uid="myMedicalImageConverter" impl="::ctrlSelection::MedicalImageSrv" type="::fwServices::IController" autoConnect="no" />
<service uid="myServices" impl="..." type="..." autoConnect="yes" />
<connect>
<signal>key</signal><!-- Signal of object "myImage" -->
<slot>uid/key</slot>
</connect>
</object>
<object id="myAcquisition" type="::fwData::Acquisition" >
<service uid="myServices2" impl="..." type="..." autoConnect="yes" worker="myThread" />
<proxy channel="...">
<signal>...</signal><!-- Signal of object "myAcquisition" -->
<signal>.../...</signal>
<slot>.../...</slot>
<slot>.../...</slot>
</proxy>
</object>
</config>
</service>
@endcode
* With:
* @li \b mode : must be "stop", "dummy" or "startAndUpdate".
* - The mode "stop", used by default, starts the services when their attached object is added in the compsite
* and stop and unregister the services when the object is deleted.
* - The mode "dummy" doesn't stop the services when its attached object is deleted but swap it on a dummy
* object.
* - The mode "startAndUpdate" start and update the services when its attached object is added in the composite.
* @li the objects and services tags are defined as same as the configuration of objects and services.
* @li \b autoConnect: optional (default value = false), if true allows to listen signals from the associated object.
* @li \b worker: optional, allows to manage the service in another thread.
* @li \b connect : not mandatory, connects signal to slot
* - \b signal : mandatory, must be signal holder UID, followed by '/', followed by signal name. To use the
* object signal, you don't have to write object uid, only the signal name.
* - \b slot : mandatory, must be slot holder UID, followed by '/', followed by slot name
* @li \b proxy : not mandatory, connects the signals/slots in a proxy
*/
CTRLSELECTION_API virtual void configuring();
/// Implements reconfiguring method derived from IService. Do nothing.
CTRLSELECTION_API virtual void reconfiguring();
/// Implements updating method derived from IService. Do nothing.
CTRLSELECTION_API virtual void updating();
/// Implements info method derived from IService. Print classname.
CTRLSELECTION_API virtual void info( std::ostream& _sstream );
typedef ::fwRuntime::ConfigurationElement::sptr ConfigurationType;
typedef std::string ObjectIdType;
class SubService
{
public:
SubService() : m_hasAutoConnection(false)
{
}
~SubService()
{
}
SPTR (::fwServices::IService) getService()
{
return m_service.lock();
}
::fwData::Object::sptr m_dummy;
ConfigurationType m_config;
WPTR(::fwServices::IService) m_service;
::fwCom::helper::SigSlotConnection m_connections;
bool m_hasAutoConnection;
};
typedef std::vector< SPTR(SubService) > SubServicesVecType;
typedef std::map< ObjectIdType, SubServicesVecType > SubServicesMapType;
/// Slot: add objects
void addObjects(::fwData::Composite::ContainerType objects);
/// Slot: change objects
void changeObjects(::fwData::Composite::ContainerType newObjects, ::fwData::Composite::ContainerType oldObjects);
/// Slot: remove objects
void removeObjects(::fwData::Composite::ContainerType objects);
void initOnDummyObject( std::string objectId );
void addObject( const std::string& objectId, ::fwData::Object::sptr object );
void changeObject(const std::string& objectId, ::fwData::Object::sptr object);
void removeObject( const std::string& objectId );
::fwServices::IService::sptr add( ::fwData::Object::sptr obj, ::fwRuntime::ConfigurationElement::sptr _elt );
private:
std::string m_mode;
bool m_dummyStopMode;
ConfigurationType m_managerConfiguration;
SubServicesMapType m_objectsSubServices;
};
} // manager
} // ctrlSelection
#endif // __CTRLSELECTION_MANAGER_SWAPPERSRV_HPP__
/* ***** BEGIN LICENSE BLOCK *****
* FW4SPL - Copyright (C) IRCAD, 2009-2015.
* Distributed under the terms of the GNU Lesser General Public License (LGPL) as
* published by the Free Software Foundation.
* ****** END LICENSE BLOCK ****** */
#ifndef __CTRLSELECTION_UPDATER_SDROP_HPP__
#define __CTRLSELECTION_UPDATER_SDROP_HPP__
#include "ctrlSelection/config.hpp"
#include "ctrlSelection/IUpdaterSrv.hpp"
namespace ctrlSelection
{
namespace updater
{
/**
* @class SDrop
* @brief Drop received object to associated ::fwData::Composite.
*
*/
class CTRLSELECTION_CLASS_API SDrop : public ::ctrlSelection::IUpdaterSrv
{
public:
fwCoreServiceClassDefinitionsMacro ( (SDrop)(::ctrlSelection::IUpdaterSrv) );
/// Constructor. Do nothing.
CTRLSELECTION_API SDrop() noexcept;
/// Destructor. Do nothing.
CTRLSELECTION_API virtual ~SDrop() noexcept;
protected:
/// Implements starting method derived from IService. Do nothing.
CTRLSELECTION_API virtual void starting();
/// Implements stopping method derived from IService. Do nothing.
CTRLSELECTION_API virtual void stopping();
/// Implements configuring method derived from IService. Do nothing.
CTRLSELECTION_API virtual void configuring();
/// Implements reconfiguring method derived from IService. Do nothing.
CTRLSELECTION_API virtual void reconfiguring();
/// Implements updating method derived from IService. Do nothing.
CTRLSELECTION_API virtual void updating();
/// Implements info method derived from IService. Print classname.
CTRLSELECTION_API virtual void info( std::ostream &_sstream );
private:
/// Slot: add the object defined by uid
void addObject(std::string uid);
};
} // updater
} // ctrlSelection
#endif // __CTRLSELECTION_UPDATER_SDROP_HPP__
/* ***** BEGIN LICENSE BLOCK *****
* FW4SPL - Copyright (C) IRCAD, 2009-2016.
* Distributed under the terms of the GNU Lesser General Public License (LGPL) as
* published by the Free Software Foundation.
* ****** END LICENSE BLOCK ****** */
#ifndef __CTRLSELECTION_UPDATER_STRANSLATE_HPP__
#define __CTRLSELECTION_UPDATER_STRANSLATE_HPP__
#include "ctrlSelection/IUpdaterSrv.hpp"
#include "ctrlSelection/config.hpp"
#include <fwData/Composite.hpp>
namespace ctrlSelection
{
namespace updater
{
/**
* @brief Update the composite related to this service according to the receiving composite signals and translate the
* composite keys.
*/
class CTRLSELECTION_CLASS_API STranslate : public ::ctrlSelection::IUpdaterSrv
{
public:
fwCoreServiceClassDefinitionsMacro ( (STranslate)(::ctrlSelection::IUpdaterSrv) );
/// Constructor. Do nothing.
CTRLSELECTION_API STranslate() noexcept;
/// Destructor. Do nothing.
CTRLSELECTION_API virtual ~STranslate() noexcept;
/**
* @brief Returns proposals to connect service slots to associated object signals,
* this method is used for obj/srv auto connection
*
* Connect Composite::s_ADDED_OBJECTS_SIG to this::s_ADD_OBJECTS_SLOT
* Connect Composite::s_CHANGED_OBJECTS_SIG to this::s_CHANGE_OBJECTS_SLOT
* Connect Composite::s_REMOVED_OBJECTS_SIG to this::s_REMOVE_OBJECTS_SLOT
*/
CTRLSELECTION_API virtual KeyConnectionsType getObjSrvConnections() const;
protected:
/// Implements starting method derived from IService. Do nothing.
CTRLSELECTION_API virtual void starting();
/// Implements stopping method derived from IService. Do nothing.
CTRLSELECTION_API virtual void stopping();
/**
* @brief Configure the services : declare the events to react.
* @code{.xml}
<service uid="myUpdater" impl="::ctrlSelection::updater::STranslate" type="::ctrlSelection::IUpdaterSrv" autoConnect="no" >
<source>compositeSrcUid</source>
<translate fromKey="myObject1Key1" toKey="myObject1Key2" />
<translate fromKey="myObject2Key1" toKey="myObject2Key2" />
</service>
@endcode
* - \b source (optional): composite used to translate objects. If it is defined, the service's slot saddObjects,
* changeObjects, removeObjects are connected to composite signal, and the objects are translated on start if
* they are present.
* - \b translate: objects to translate from source composite to current composite
* - \b fromKey: key of the object in the source composite
* - \b toKey: key of the object in the current composite
*/
CTRLSELECTION_API virtual void configuring();
/// Implements reconfiguring method derived from IService. Do nothing.
CTRLSELECTION_API virtual void reconfiguring();
/// Implements updating method derived from IService. Do nothing.
CTRLSELECTION_API virtual void updating();
/// Implements info method derived from IService. Print classname.
CTRLSELECTION_API virtual void info( std::ostream& _sstream );
private:
/// Slot: add objects
void addObjects(::fwData::Composite::ContainerType objects);
/// Slot: change objects
void changeObjects(::fwData::Composite::ContainerType newObjects, ::fwData::Composite::ContainerType oldObjects);
/// Slot: remove objects
void removeObjects(::fwData::Composite::ContainerType objects);
/// Managed translation : fromUID, fromKey, toKey
typedef std::map <std::string, std::string > ManagedTranslations;
/// List of the managed translations
ManagedTranslations m_managedTranslations;
/// FwID of the source composite.
std::string m_sourceCompositeID;
/// Source composite (can be current composite)
::fwData::Composite::wptr m_source;
/// Connection to source
::fwCom::helper::SigSlotConnection m_connections;
};
} // updater
} // ctrlSelection
#endif // __CTRLSELECTION_UPDATER_STRANSLATE_HPP__
/* ***** BEGIN LICENSE BLOCK *****
* FW4SPL - Copyright (C) IRCAD, 2009-2016.
* Distributed under the terms of the GNU Lesser General Public License (LGPL) as
* published by the Free Software Foundation.
* ****** END LICENSE BLOCK ****** */
#include "ctrlSelection/manager/SField.hpp"
#include <fwCom/Slot.hpp>
#include <fwCom/Slot.hxx>
#include <fwCom/Slots.hpp>
#include <fwCom/Slots.hxx>
#include <fwServices/macros.hpp>
#include <fwServices/op/Add.hpp>
#include <fwServices/registry/ActiveWorkers.hpp>
#include <fwServices/registry/ServiceConfig.hpp>
#include <fwTools/fwID.hpp>
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
namespace ctrlSelection
{
namespace manager
{
static const ::fwCom::Slots::SlotKeyType s_ADD_FIELDS_SLOT = "addFields";
static const ::fwCom::Slots::SlotKeyType s_CHANGE_FIELDS_SLOT = "changeFields";
static const ::fwCom::Slots::SlotKeyType s_REMOVE_FIELDS_SLOT = "removeFields";
//-----------------------------------------------------------------------------
fwServicesRegisterMacro( ::ctrlSelection::IManagerSrv, ::ctrlSelection::manager::SField, ::fwData::Object );
//-----------------------------------------------------------------------------
SField::SField() noexcept : m_dummyStopMode(false)
{
newSlot(s_ADD_FIELDS_SLOT, &SField::addFields, this);
newSlot(s_CHANGE_FIELDS_SLOT, &SField::changeFields, this);
newSlot(s_REMOVE_FIELDS_SLOT, &SField::removeFields, this);
}
//-----------------------------------------------------------------------------