Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JTriggerParametersSupportkit.hh
Go to the documentation of this file.
1#ifndef __JSUPPORT__JTRIGGERPARAMETERSSUPPORTKIT__
2#define __JSUPPORT__JTRIGGERPARAMETERSSUPPORTKIT__
3
6#include "JLang/JException.hh"
8
9
10/**
11 * \author mdejong
12 */
13
14namespace JSUPPORT {}
15namespace JPP { using namespace JSUPPORT; }
16
17namespace JSUPPORT {
18
23
24
25 /**
26 * Template specialisation of JMultipleFileScanner for trigger parameters.
27 *
28 * This class re-implements the methods rewind and setObject of the JLANG::JRewindableAbstractObjectIterator interface
29 * so that all trigger parameter objects in the complete file list are read and checked for consistency.
30 */
31 template<>
33 public virtual JMultipleFileScanner<>,
34 public JRewindableAbstractObjectIterator<JTriggerParameters>
35 {
36 public:
37 /**
38 * Default constructor.
39 */
45
46
47 /**
48 * Copy constructor.
49 * The file list is copied.
50 *
51 * \param file_list JMultipleFileScanner
52 */
56 do_next(true)
57 {
58 configure(file_list, JLimit());
59 }
60
61
62 /**
63 * Rewind.
64 */
65 virtual void rewind() override
66 {
67 do_next = true;
68 }
69
70
71 /**
72 * Set object.
73 *
74 * \param object reference to object to be set
75 * \return true if set; else false
76 */
77 virtual bool setObject(JTriggerParameters& object) override
78 {
79 if (do_next) {
80
81 using namespace JLANG;
82
83 object = JTriggerParameters();
84 do_next = false;
85
86 unsigned int count = 0;
87
89
90 for (const_iterator i = this->begin(); i != this->end(); ++i) {
91
92 scanner.open(i->c_str());
93
94 if (scanner.hasNext()) {
95
96 const JTriggerParameters* __p = scanner.next();
97
98 if (count == 0)
99 object = *__p;
100 else if (!object.equals(*__p))
101 THROW(JException, "JMultipleFileScanner<JTriggerParameters>::setObject(): inconsistent trigger parameters.");
102
103 ++count;
104 }
105
106 scanner.close();
107 }
108
109 return count != 0;
110
111 } else {
112
113 return false;
114 }
115 }
116
117
118 /**
119 * Get trigger parameters.
120 *
121 * \return trigger parameters
122 */
124 {
125 const JTriggerParameters* p = NULL;
126
127 if (!this->hasNext() || (p = this->next()) == NULL) {
128 THROW(JNullPointerException, "JMultipleFileScanner<JTriggerParameters>::getTriggerParameters(): Missing trigger parameters.");
129 }
130
131 rewind();
132
133 return *p;
134 }
135
136
137 private:
139 };
140
141
142 /**
143 * Get trigger parameters.
144 *
145 * \param file_list file list
146 * \return trigger parameters
147 */
149 {
150 return JMultipleFileScanner<JTriggerParameters>(file_list).getTriggerParameters();
151 }
152}
153
154#endif
Exceptions.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Scanning of objects from multiple files according a format that follows from the extension of each fi...
General exception.
Definition JException.hh:24
Exception for null pointer operation.
Abstract object iterator with rewinding.
Object reading from file.
const JTriggerParameters & getTriggerParameters()
Get trigger parameters.
JMultipleFileScanner(const JMultipleFileScanner_t &file_list)
Copy constructor.
virtual bool setObject(JTriggerParameters &object) override
Set object.
General purpose class for object reading from a list of file names.
virtual void rewind() override
Rewind.
virtual bool hasNext() override
Check availability of next element.
virtual const pointer_type & next() override
Get next element.
Data structure for all trigger parameters.
Auxiliary classes and methods for language specific functionality.
bool equals(const JFirst_t &first, const JSecond_t &second, const double precision=std::numeric_limits< double >::min())
Check equality.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Support classes and methods for experiment specific I/O.
JTriggerParameters getTriggerParameters(const JMultipleFileScanner_t &file_list)
Get trigger parameters.
void configure(const T &value, const JAbstractCollection< JAbscissa_t > &bounds, JBool< false > option)
Configuration of value.
Auxiliary class for defining the range of iterations of objects.
Definition JLimit.hh:45
Auxiliary base class for list of file names.