GCC Code Coverage Report


Directory: ./
File: src/app/extension.cc
Date: 2025-09-01 06:19:01
Exec Total Coverage
Lines: 0 34 0.0%
Functions: 0 8 0.0%
Branches: 0 9 0.0%

Line Branch Exec Source
1 #include "na64app/extension.hh"
2
3 #include <log4cpp/Category.hh>
4
5 namespace na64dp {
6
7 Extensions * Extensions::_self = nullptr;
8
9 Extensions::Extensions() {}
10
11 Extensions &
12 Extensions::self() {
13 if(!_self) _self = new Extensions();
14 return *_self;
15 }
16
17 bool
18 Extensions::add( const std::string & name
19 , iRuntimeExtension * extPtr
20 ) {
21 auto ir = emplace(name, extPtr);
22 if(!ir.second) {
23 throw errors::DuplicateExtensionName(name);
24 }
25 return true;
26 }
27
28 iRuntimeExtension &
29 Extensions::operator[](const std::string & nm) {
30 auto extIt = find(nm);
31 if(extIt == end()) {
32 throw errors::NoExtension(nm);
33 }
34 return *(extIt->second);
35 }
36
37 void
38 Extensions::set_parameter( const std::string & parPath
39 , const std::string & parVal
40 ) {
41 auto c = parPath.find('.');
42 if(std::string::npos == c) {
43 NA64DP_RUNTIME_ERROR( "Parameter path string \"%s\" have no extension"
44 " name delimiter (.)", parPath.c_str() );
45 }
46 std::string extName = parPath.substr(0, c)
47 , parName = parPath.substr(c+1)
48 ;
49 // If parameter has to be set BEFORE logging is initialized, consider
50 // to delete line below:
51 log4cpp::Category::getInstance("extensions") << log4cpp::Priority::DEBUG
52 << " setting parameter \"" << parName << "\" of extension \""
53 << extName << "\" to \"" << parVal << "\"";
54 this->operator[](extName).set_parameter(parName, parVal);
55 }
56
57 void
58 Extensions::init( calib::Manager & cmgr, iEvProcInfo * epiPtr ) {
59 for( auto p : *this ) {
60 p.second->init(cmgr, epiPtr);
61 }
62 }
63
64 void
65 Extensions::finalize() {
66 for( auto p : *this ) {
67 p.second->finalize();
68 }
69 }
70
71 void
72 Extensions::shutdown() {
73 for( auto p : *this ) {
74 delete p.second;
75 }
76 clear();
77 }
78
79 } // namespace na64dp
80
81