Marlin  1.10.0
 All Classes Namespaces Functions Variables Enumerations Friends Pages
CCProcessor.h
1 #ifndef CCPROCESSOR_H
2 #define CCPROCESSOR_H
3 
4 #include "marlin/Processor.h"
5 
6 #include <set>
7 #include <fstream>
8 
9 #define MAX_ERRORS 3
10 #define ACTIVE true
11 #define INACTIVE false
12 #define NO_PARAMETERS 0
13 #define NOT_INSTALLED 1
14 #define COL_ERRORS 2
15 #define INPUT "lcioInType"
16 #define OUTPUT "lcioOutType"
17 #define UNAVAILABLE "lcioUnavailableType"
18 #define DUPLICATE "lcioDuplicate"
19 
20 namespace marlin {
21 
22  class CCCollection;
23 
24  typedef std::set< std::string > sSet;
25  typedef std::vector< CCCollection* > ColVec;
26  typedef std::map< std::string, std::string > ssMap;
27  typedef std::map< std::string, ssMap > sssMap;
28  typedef std::map< std::string, ColVec > sColVecMap;
29  typedef std::map< std::string, sColVecMap > ssColVecMap;
30 
39  class CCProcessor{
40 
41  public:
42 
43  // Constructor
44  CCProcessor( bool status, const std::string& name, const std::string& type, StringParameters* p=NULL);
45 
46  // Copy Constructor
48 
49  // Destructor
50  ~CCProcessor();
51 
53  bool hasErrors();
54 
56  bool hasParameters(){ return !_error[ NO_PARAMETERS ]; }
57 
59  bool hasErrorCols(){ return _error[ COL_ERRORS ]; }
60 
62  bool isInstalled(){ return !_error[ NOT_INSTALLED ]; }
63 
65  bool isActive(){ return _status; }
66 
68  bool hasCondition( const std::string& condition );
69 
71  const std::string& getName(){ return _name; }
72 
74  const std::string& getType(){ return _type; }
75 
77  sSet& getConditions(){ return _conditions; }
78 
80  const std::string getDescription(){ return (isInstalled() ? _proc->description() :
81  "This processor is NOT installed in your Marlin binary: parameter descriptions and types lost!!");
82  }
83 
84  /* Returns a string vector with the errors of the processor - Obsolete: use getError() instead */
85  //const StringVec& getErrors(){ return _errors; }
86 
88  const std::string getError(){ return ( _errors.size() != 0 ? _errors[0] : "" ); }
89 
91  const std::string getStatusDesc(){ return ( isActive() ? "Active" : "Inactive" ); }
92 
94  bool isErrorCol( const std::string& type, const std::string& value );
95 
97  bool isParamOptional( const std::string& key );
98 
100  StringParameters* getParameters(){ return _param; }
101 
103  const ssMap& getColHeaders( const std::string& iotype ){ return _types[iotype]; }
104 
108  ColVec& getCols( const std::string& iotype, const std::string& type_name="ALL_COLLECTIONS" );
109 
113  sSet& getColTypeNames( const std::string& iotype );
114 
116  void addCol( const std::string& iotype, const std::string& name, const std::string& type, const std::string& value );
117 
119  void remCol( const std::string& iotype, const std::string& name, unsigned int index );
120 
122  void addUCol( CCCollection* c );
123 
125  void addDCol( CCCollection* c );
126 
128  void changeStatus();
129 
131  void setName( const std::string& name ){ _name = name; };
132 
134  void setConditions( const std::string& conditions );
135 
137  void setError( int error );
138 
140  void clearError( int error );
141 
143  void setOptionalParam( const std::string& key, bool optional=true );
144 
146  void writeToXML( std::ofstream& stream );
147 
148  private:
149 
151  // METHODS
153  void addColsFromParam( StringParameters* p );
154  void writeColsToParam();
155  void clearParameters();
156  void setMarlinProc(); //sets error flag NOT_INSTALLED if processor couldn't be set
157  CCCollection* popCol( ColVec& v, CCCollection* c );
158 
160  // VARIABLES
162  bool _status; // false = INACTIVE ; true = ACTIVE
163  bool _error[MAX_ERRORS]; // 0 = proc has no parameters; 1 = proc is not build in this marlin installation; 2 = unavailable collections
164  std::string _name; // name of the processor
165  std::string _type; // type of the processor
166  StringParameters* _param; // parameters from processor
167  Processor* _proc; // associated Marlin processor
168 
169  StringVec _error_desc; // error descriptions for all processors
170  StringVec _errors; // list of errors found in a processor
171 
172  sSet _conditions; // processor's conditions
173 
174  ssColVecMap _cols; // first key for Types INPUT : OUTPUT : UNAVAILABLE : DUPLICATE
175  // for INPUT/OUPUT the second key is for Collection Names
176  // for UNAVAILABLE/DUPLICATE the second key is for Collection Types
177 
178  sssMap _types; // first key for Types INPUT : OUTPUT
179  // second key is for Collection Names and the third string for Collection Types
180 
181  sSet _optParams; // list of optional parameters that shall be written out as normal parameters
182  };
183 
184 } // end namespace marlin
185 #endif
void addDCol(CCCollection *c)
Adds a duplicate collection to this processor.
Definition: CCProcessor.cc:318
const std::string getError()
Returns a string with the error of the processor.
Definition: CCProcessor.h:88
sSet & getConditions()
Returns the Conditions of the processor.
Definition: CCProcessor.h:77
bool isErrorCol(const std::string &type, const std::string &value)
Returns true if the given collection is in the unavailable or duplicate list of this processor...
Definition: CCProcessor.cc:380
handles information about LCIO collections needed by MarlinSteerCheck
Definition: CCCollection.h:17
void remCol(const std::string &iotype, const std::string &name, unsigned int index)
Removes collection of the given iotype ( INPUT / OUTPUT ) with the given name at the given index...
Definition: CCProcessor.cc:326
void setError(int error)
Activates an error flag in this processor ( NO_PARAMETERS=0, NOT_INSTALLED=1, COL_ERRORS=2 ) ...
Definition: CCProcessor.cc:398
handles information about marlin processors and their collections needed by MarlinSteerCheck ...
Definition: CCProcessor.h:39
sSet & getColTypeNames(const std::string &iotype)
Returns collection's types/names of a given iotype found in the processor If iotype == INPUT/OUTPUT t...
Definition: CCProcessor.cc:369
void clearError(int error)
Clears an error flag in this processor ( NO_PARAMETERS=0, NOT_INSTALLED=1, COL_ERRORS=2 ) ...
Definition: CCProcessor.cc:405
void setConditions(const std::string &conditions)
Sets the processor's conditions.
Definition: CCProcessor.cc:152
bool isParamOptional(const std::string &key)
Returns true if a parameter is optional (optional means the parameter will be written out as a commen...
Definition: CCProcessor.cc:436
bool isInstalled()
Returns true if the processor is installed.
Definition: CCProcessor.h:62
void setOptionalParam(const std::string &key, bool optional=true)
Sets a parameter as optional (if optional=true parameter is written out as a comment) ...
Definition: CCProcessor.cc:445
StringParameters * getParameters()
Returns the string parameters for this processor.
Definition: CCProcessor.h:100
void writeToXML(std::ofstream &stream)
Writes this processor to a stream using the XML format.
Definition: CCProcessor.cc:454
bool hasErrors()
Returns true if the processor has errors.
Definition: CCProcessor.cc:427
const std::string & description()
Description of processor.
Definition: Processor.h:192
const std::string & getType()
Returns the Type of the processor.
Definition: CCProcessor.h:74
bool hasCondition(const std::string &condition)
Returns true if the processor is constrained by the given condition.
Definition: CCProcessor.cc:200
void changeStatus()
Changes the processor status ( ACTIVE->INACTIVE or INACTIVE->ACTIVE )
Definition: CCProcessor.cc:280
const std::string & getName()
Returns the Name of the processor.
Definition: CCProcessor.h:71
ColVec & getCols(const std::string &iotype, const std::string &type_name="ALL_COLLECTIONS")
Returns collections of a given iotype ( INPUT, OUTPUT, UNAVAILABLE, DUPLICATE ) for a given name or t...
Definition: CCProcessor.cc:351
void addCol(const std::string &iotype, const std::string &name, const std::string &type, const std::string &value)
Adds a collection of the given iotype ( INPUT / OUTPUT ) with the given name, type and value...
Definition: CCProcessor.cc:289
const ssMap & getColHeaders(const std::string &iotype)
Returns a map with collection names and their respective types for INPUT/OUTPUT collections of this p...
Definition: CCProcessor.h:103
bool hasParameters()
Returns true if the processor has parameters.
Definition: CCProcessor.h:56
Base class for Marlin processors.
Definition: Processor.h:63
void setName(const std::string &name)
Sets the processor's name.
Definition: CCProcessor.h:131
const std::string getStatusDesc()
Returns a string with the processor status ( "Active", "Inactive" )
Definition: CCProcessor.h:91
bool isActive()
Returns true if the processor is active.
Definition: CCProcessor.h:65
Simple parameters class for Marlin.
Definition: StringParameters.h:34
const std::string getDescription()
Returns the Description of the processor.
Definition: CCProcessor.h:80
bool hasErrorCols()
Returns true if the processor has collection errors.
Definition: CCProcessor.h:59
void addUCol(CCCollection *c)
Adds an unavailable collection to this processor.
Definition: CCProcessor.cc:310