1 #ifndef _det_DetectorComponent_h_
2 #define _det_DetectorComponent_h_
4 #include <det/VManager.h>
5 #include <det/Detector.h>
7 #include <utl/ErrorLogger.h>
8 #include <utl/AugerException.h>
9 #include <utl/Validated.h>
10 #include <utl/VValidated.h>
11 #include <utl/ShadowPtr.h>
16 #include <boost/utility.hpp>
52 {
WARNING(
"Call to unspecialized DetectorUserData::DetectorUserData(const std::string&)."); }
82 template<
class C,
class ManagerProv
ider>
126 std::ostringstream o;
158 std::string dataMngr;
160 GetDataNoWrap(dataMngr,
"userData");
190 template<
typename T,
template<
typename>
class P>
191 T&
GetData(P<T>&
d,
const std::string&
p)
const {
return GetDataUnwrap<T>(
d,
p); }
199 template<
typename T1,
typename T2,
template<
typename,
typename>
class P>
201 GetData(P<T1, T2>&
d,
const std::string&
p)
206 return GetDataUnwrap<T1>(
d,
p);
218 GetDataNoWrap(d.
Get(),
p);
232 T&
GetData(T&
d,
const std::string&
p)
const {
return GetDataNoWrap(d, p); }
251 typedef det::VManager::IndexMap::const_iterator It;
253 s <<
"id=" <<
GetId() <<
" [";
257 s <<
" " << i->first <<
"=" << i->second;
276 DetectorComponent(
const int i) :
fId(i) {
Init(); }
278 virtual ~DetectorComponent() { }
288 Update(
const bool invalidateData,
const bool )
291 for (FieldsContainer::iterator i =
fFields.begin(), e =
fFields.end(); i != e; ++i)
292 (*i)->SetValid(
false);
313 GetDataNoWrap(T&
d,
const std::string&
p)
317 const VManager& mngr = ManagerProvider::GetInstance();
321 std::ostringstream err;
322 err <<
"Did not find the requested component: '"
323 << p <<
"' in " << GetIdMessage() <<
".";
337 template<
typename R,
typename T>
339 GetDataUnwrap(T& d ,
const std::string& p)
344 R*
const t =
new R();
349 return GetDataNoWrap(*t, p);
362 std::ostringstream
s;
363 s << c <<
", " << p <<
" in " << GetIdMessage() <<
" with data= " <<
d;
376 std::ostringstream
s;
378 for (
typename std::list<T>::const_iterator i = d.begin(); i != d.end(); ++i)
397 std::ostringstream idStr;
401 fIdsMap[C::kComponentId] = idStr.str();
pointer with built-in initialization, deletion, deep copying
int fId
Id of the component.
utl::ShadowPtr< DetectorUserData< C > > fUserData
User customized detector component level data.
std::string BuildLogMessage(const std::list< T > &d, const std::string &p, const std::string &c)
Overload for list: don't show the list.
Minimum validation handling methods.
void Update(std::vector< double > &init, const std::vector< double > &res)
Base class for exceptions trying to access non-existing components.
Interface for detector managers.
const VManager::IndexMap & GetIdsMap() const
The id identifying this component within its detector hierarhy.
void Register(utl::VValidated &v)
Register the field so as to allow handling it.
T & GetData(P< T > &d, const std::string &p) const
Common utility function for configuration.
Wrapper class for initially unset data.
virtual Status GetData(double &returnData, const std::string &componentProperty, const std::string &componentName, const IndexMap &componentIndex) const =0
#define WARNING(message)
Macro for logging warning messages.
DetectorUserData(const std::string &)
Construct the user data according to an string read from configuration.
std::vector< utl::VValidated * > FieldsContainer
Container for those fields (from the deriving classes) meant to be managed by this object...
void Init()
Common object initialization method.
Base class for detector components.
VManager::IndexMap fIdsMap
Identifies this component within its hierarchy.
T & GetData(T &d, const std::string &p) const
Common utility function for configuration.
std::map< std::string, std::string > IndexMap
void SetValid(const bool valid=true)
User custom data base structure.
int GetId() const
The id of this component.
std::string BuildLogMessage(const T &d, const std::string &p, const std::string &c)
All the requested info in a line.
#define ERROR(message)
Macro for logging error messages.
Status
Specifies success or (eventually) various possible failure modes.
FieldsContainer fFields
Keep pointers to the detector-date fields of the particular (deriving) instance.