-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathSBSManager.cxx
48 lines (43 loc) · 1.31 KB
/
SBSManager.cxx
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
#include "SBSManager.h"
std::unique_ptr<SBSManager> SBSManager::fManager = nullptr;
///////////////////////////////////////////////////////////////////////////////
// Get an instance of the singleton
SBSManager* SBSManager::GetInstance()
{
if(!fManager) {
fManager.reset(new SBSManager);
}
return fManager.get();
}
///////////////////////////////////////////////////////////////////////////////
// Get the instance of the global crate map
// Initialize the map for the given Unix time 'tloc'. If the time changed since
// the previous initialization, then re-initialize the map.
Decoder::THaCrateMap* SBSManager::GetCrateMap( Long64_t tloc )
{
if(!fCrateMap) {
fCrateMap.reset(new Decoder::THaCrateMap(fCrateMapName));
fCrateMapInitTime = -1;
}
if(fCrateMapInitTime != tloc) {
fCrateMap->init(tloc);
fCrateMapInitTime = tloc;
}
return fCrateMap.get();
}
///////////////////////////////////////////////////////////////////////////////
void SBSManager::SetDefaultCrateMapName(const char* name)
{
if( fCrateMapName != name ) {
// Force re-init
fCrateMap.reset();
}
fCrateMapName = name;
}
///////////////////////////////////////////////////////////////////////////////
// Basic constructor
SBSManager::SBSManager()
: fCrateMap{}
, fCrateMapName{"cratemap"}
, fCrateMapInitTime{-1}
{}