VirtualInstrumentManager.cc
1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* VirtualInstrumentManager.cc
*
* Created on: Jan 17, 2013
* Author: f.casimir
*/
#include "VirtualInstrumentManager.hh"
#include "VirtualInstrument.hh"
#include "Properties.hh"
namespace AMDA {
namespace DDServerInterface {
VirtualInstrumentManager::VirtualInstrumentManager() {
AMDA::helpers::Properties lProperties("app.properties");
_userHost = lProperties["app.user.host"];
_userName = lProperties["app.user.name"];
}
VirtualInstrumentManager::~VirtualInstrumentManager() {
}
VirtualInstrumentSPtr VirtualInstrumentManager::getVirtualInstrument(const std::string& pVirtualInstrumentName) {
VirtualInstrumentSPtr lResult;
auto lIt = _virtualInstrumentMap.find(pVirtualInstrumentName);
if (lIt == _virtualInstrumentMap.end()) {
lResult = VirtualInstrumentSPtr(new VirtualInstrument(*this,pVirtualInstrumentName));
_virtualInstrumentMap[pVirtualInstrumentName]=lResult;
} else {
lResult = lIt->second.lock();
if ( ! lResult) {
_virtualInstrumentMap.erase(lIt);
lResult = VirtualInstrumentSPtr(new VirtualInstrument(*this,pVirtualInstrumentName));
_virtualInstrumentMap[pVirtualInstrumentName]=lResult;
}
}
return lResult;
}
const char* VirtualInstrumentManager::getUserHost() {
return _userHost.c_str();
}
const char* VirtualInstrumentManager::getUserName() {
return _userName.c_str();
}
} /* namespace DDServerInterface */
} /* namespace AMDA */