1 #include "TangoHKLAdapterFactory.h"
2 #include "TangoHKLAdapter.h"
3 #include "DiffractometerDevice.h"
5 namespace DiffractometerDevice_ns
9 * Static instance of the factory
12 TangoHKLAdapterFactory
* TangoHKLAdapterFactory::_instance
= NULL
;
16 * Return the instance of the factory
19 TangoHKLAdapterFactory
* TangoHKLAdapterFactory::instance(void)
22 _instance
= new TangoHKLAdapterFactory();
27 * method: DiffractometerFactory::createDiffractometer
29 * description: create a hkl library associated with device name
31 * @return an instance of hkl adapter which contains an instance of the library
34 TangoHKLAdapter
* TangoHKLAdapterFactory::attach_device(
35 DiffractometerDevice
*device
,
38 TangoHKLAdapter
* adapter
= NULL
;
40 // Check if it already build
41 adapterMap_t::const_iterator iter
;
42 iter
= _adapterMap
.find( device
);
44 if (iter
== _adapterMap
.end()) {
45 adapter
= new TangoHKLAdapter(device
, type
);
46 _adapterMap
[device
] = adapter
;
47 std::cout
<< "TangoHKLAdapterFactory::attach_device new Diffractometer device " << device
->get_name() << " created." << std::endl
;
49 adapter
= iter
->second
;
54 void TangoHKLAdapterFactory::detach_device(DiffractometerDevice
*device
)
56 // Find the name in map
57 adapterMap_t::iterator iter
;
58 iter
= _adapterMap
.find( device
);
60 if (iter
!= _adapterMap
.end()) {
61 // Do Delete it as it is used by the PseudoAxes.
62 //delete iter->second;
63 //_adapterMap.erase(iter);
64 std::cout
<< "TangoHKLAdapterFactory::removeDiffractometer Diffractometer device " << device
->get_name() << " removed." << std::endl
;
69 * @brief Get the TangoHKLAdapter associated to a device named:
70 * @param devicename The name of the device.
71 * @return The TangoHKLAdapter pointer of the Device or NULL if the device is not present.
73 TangoHKLAdapter
* TangoHKLAdapterFactory::get_diffractometer_adapter(std::string
const & diffractometerProxyName
)
75 TangoHKLAdapter
* adapter
= NULL
;
77 adapterMap_t::iterator iter
= _adapterMap
.begin();
78 adapterMap_t::iterator end
= _adapterMap
.end();
80 if (iter
->first
->get_name() == diffractometerProxyName
) {
81 adapter
= iter
->second
;
90 TangoHKLAdapterFactory::~TangoHKLAdapterFactory()
93 // remove all undeleted devices.
94 adapterMap_t::iterator iter
= _adapterMap
.begin();
95 adapterMap_t::iterator end
= _adapterMap
.end();