DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
ers
src
PluginManager.cpp
Go to the documentation of this file.
1
/*
2
* DUNE DAQ modification notice:
3
* This file has been modified from the original ATLAS ers source for the DUNE DAQ project.
4
* Fork baseline commit: 8267df82a4f6fe6bf02c4014923eba19eddc4614 (2020-04-14).
5
* Renamed since fork: yes (from src/PluginManager.cxx to src/PluginManager.cpp).
6
*
7
* Original copyright:
8
* Copyright (C) 2001-2020 CERN for the benefit of the ATLAS collaboration.
9
* Licensed under the Apache License, Version 2.0.
10
*/
11
12
#ifndef __rtems__
13
#include <dlfcn.h>
14
#endif
15
16
#include <vector>
17
18
#include <
ers/internal/Util.hpp
>
19
#include <
ers/internal/PluginManager.hpp
>
20
#include <
ers/internal/macro.hpp
>
21
22
namespace
23
{
24
const
char
*
const
SEPARATOR =
":"
;
25
const
char
*
const
DefaultLibraryName =
"ers_AbortStream_ersStream:ers_ExitStream_ersStream:ers_FilterStream_ersStream:ers_GlobalLockStream_ersStream:ers_LockStream_ersStream:ers_NullStream_ersStream:ers_RFilterStream_ersStream:ers_StandardStream_ersStream:ers_ThrottleStream_ersStream:ers_ThrowStream_ersStream"
;
26
const
char
*
const
EnvironmentName =
"DUNEDAQ_ERS_STREAM_LIBS"
;
27
}
28
29
namespace
ers
30
{
31
32
PluginManager::SharedLibrary::SharedLibrary
(
const
std::string & name )
33
{
34
#ifndef __rtems__
35
std::string library =
"lib"
+ name +
".so"
;
36
37
handle_
= dlopen( library.c_str(), RTLD_LAZY|RTLD_GLOBAL );
38
char
*
error
= dlerror();
39
40
if
( !
handle_
)
41
{
42
throw
PluginException
(
error
);
43
}
44
#endif
45
}
46
47
PluginManager::SharedLibrary::~SharedLibrary
( )
48
{
50
// Library should be unloaded, but with some compilers (e.g gcc323)
51
// this results in crash of program, because it is not recognized
52
// that the library is still in use
54
55
//dlclose( handle_ );
56
}
57
58
PluginManager::~PluginManager
()
59
{
60
LibMap::iterator it =
libraries_
.begin();
61
for
( ; it !=
libraries_
.end(); )
62
{
63
delete
it->second;
64
libraries_
.erase( it++ );
65
}
66
}
67
68
PluginManager::PluginManager
( )
69
{
70
const
char
* env = ::getenv( EnvironmentName );
71
std::string config( env ? std::string( env ) + SEPARATOR + DefaultLibraryName : DefaultLibraryName );
72
73
std::vector<std::string> libs;
74
ers::tokenize
( config, SEPARATOR, libs );
75
76
77
for
(
size_t
i = 0; i < libs.size(); i++ )
78
{
79
LibMap::iterator it =
libraries_
.find( libs[i] );
80
if
( it ==
libraries_
.end() )
81
{
82
try
83
{
84
libraries_
[libs[i]] =
new
SharedLibrary
( libs[i] );
85
}
86
catch
(
PluginException
& ex )
87
{
88
ERS_INTERNAL_ERROR
(
"Library "
<< libs[i] <<
" can not be loaded because "
<< ex.
reason
() )
89
}
90
}
91
}
92
}
93
}
PluginManager.hpp
Util.hpp
ers::PluginException
Definition
PluginManager.hpp:35
ers::PluginException::reason
const std::string & reason() const
Definition
PluginManager.hpp:41
ers::PluginManager::SharedLibrary
Definition
PluginManager.hpp:51
ers::PluginManager::SharedLibrary::handle_
void * handle_
Definition
PluginManager.hpp:65
ers::PluginManager::SharedLibrary::SharedLibrary
SharedLibrary(const std::string &name)
Definition
PluginManager.cpp:32
ers::PluginManager::SharedLibrary::~SharedLibrary
~SharedLibrary()
Definition
PluginManager.cpp:47
ers::PluginManager::PluginManager
PluginManager()
Definition
PluginManager.cpp:68
ers::PluginManager::~PluginManager
~PluginManager()
Definition
PluginManager.cpp:58
ers::PluginManager::libraries_
LibMap libraries_
Definition
PluginManager.hpp:70
macro.hpp
ERS_INTERNAL_ERROR
#define ERS_INTERNAL_ERROR(message)
Definition
macro.hpp:63
ers
Definition
Logger.hxx:202
ers::tokenize
void tokenize(const std::string &text, const std::string &separators, std::vector< std::string > &tokens)
Definition
Util.cpp:18
ers::error
void error(const Issue &issue)
Definition
ers.hpp:92
Generated on
for DUNE-DAQ by
1.17.0