Luiza  v03-01
CCProcessor.h
1 #ifndef CCPROCESSOR_H
2 #define CCPROCESSOR_H
3 
4 #include "luiza/Processor.h"
5 
6 #include <set>
7 #include <fstream>
8 
9 #define ACTIVE true
10 #define INACTIVE false
11 
12 #define MAX_ERRORS 4
13 #define NO_PARAMETERS 0
14 #define NOT_INSTALLED 1
15 #define COL_ERRORS 2
16 #define COL_MISSING 3
17 
18 #define INPUT "gloriaInType"
19 #define OUTPUT "gloriaOutType"
20 #define UNAVAILABLE "gloriaUnavailableType"
21 #define DUPLICATE "gloriaDuplicate"
22 #define MISSING "gloriaMissing"
23 
24 namespace luiza {
25 
26  class CCCollection;
27 
28  typedef std::set< std::string > sSet;
29  typedef std::vector< CCCollection* > ColVec;
30  typedef std::map< std::string, std::string > ssMap;
31  typedef std::map< std::string, ssMap > sssMap;
32  typedef std::map< std::string, ColVec > sColVecMap;
33  typedef std::map< std::string, sColVecMap > ssColVecMap;
34 
43  class CCProcessor{
44 
45  public:
46 
47  // Constructor
48  CCProcessor( bool status, const std::string& name, const std::string& type, StringParameters* p=NULL);
49 
50  // Copy Constructor
52 
53  // Destructor
54  ~CCProcessor();
55 
57  bool hasErrors();
58 
60  bool hasParameters(){ return !_error[ NO_PARAMETERS ]; }
61 
63  bool hasErrorCols(){ return _error[ COL_ERRORS] || _error[COL_MISSING] ; }
64 
66  bool isInstalled(){ return !_error[ NOT_INSTALLED ]; }
67 
69  bool isActive(){ return _status; }
70 
72  bool hasCondition( const std::string& condition );
73 
75  const std::string& getName(){ return _name; }
76 
78  const std::string& getType(){ return _type; }
79 
81  sSet& getConditions(){ return _conditions; }
82 
84  const std::string getDescription(){ return (isInstalled() ? _proc->description() :
85  "This processor is NOT installed in your Luiza binary: parameter descriptions and types lost!!");
86  }
87 
88  /* Returns a string vector with the errors of the processor - Obsolete: use getError() instead */
89  //const StringVec& getErrors(){ return _errors; }
90 
92  const std::string getError(){ return ( _errors.size() != 0 ? _errors[0] : "" ); }
93 
95  const std::string getStatusDesc(){ return ( isActive() ? "Active" : "Inactive" ); }
96 
98  bool isErrorCol( const std::string& type, const std::string& value );
99 
101  bool isParamOptional( const std::string& key );
102 
104  StringParameters* getParameters(){ return _param; }
105 
107  const ssMap& getColHeaders( const std::string& iotype ){ return _types[iotype]; }
108 
112  ColVec& getCols( const std::string& iotype, const std::string& type_name="ALL_COLLECTIONS" );
113 
117  sSet& getColTypeNames( const std::string& iotype );
118 
120  void addCol( const std::string& iotype, const std::string& name, const std::string& type, const std::string& value );
121 
123  void remCol( const std::string& iotype, const std::string& name, unsigned int index );
124 
126  void addUCol( CCCollection* c );
127 
129  void addDCol( CCCollection* c );
130 
132  void changeStatus();
133 
135  void setName( const std::string& name ){ _name = name; };
136 
138  void setConditions( const std::string& conditions );
139 
141  void setError( int error );
142 
144  void clearError( int error );
145 
147  void setOptionalParam( const std::string& key, bool optional=true );
148 
150  void writeToXML( std::ofstream& stream );
151 
152  private:
153 
155  // METHODS
157  void addColsFromParam( StringParameters* p );
158  void writeColsToParam();
159  void clearParameters();
160  void setLuizaProc(); //sets error flag NOT_INSTALLED if processor couldn't be set
161  CCCollection* popCol( ColVec& v, CCCollection* c );
162 
164  // VARIABLES
166  bool _status; // false = INACTIVE ; true = ACTIVE
167  bool _error[MAX_ERRORS]; // 0 = proc has no parameters; 1 = proc is not build in this luiza installation; 2 = unavailable collections
168  std::string _name; // name of the processor
169  std::string _type; // type of the processor
170  StringParameters* _param; // parameters from processor
171  Processor* _proc; // associated Luiza processor
172 
173  StringVec _error_desc; // error descriptions for all processors
174  StringVec _errors; // list of errors found in a processor
175 
176  sSet _conditions; // processor's conditions
177 
178  ssColVecMap _cols; // first key for Types INPUT : OUTPUT : UNAVAILABLE : DUPLICATE
179  // for INPUT/OUPUT the second key is for Collection Names
180  // for UNAVAILABLE/DUPLICATE the second key is for Collection Types
181 
182  sssMap _types; // first key for Types INPUT : OUTPUT
183  // second key is for Collection Names and the third string for Collection Types
184 
185  sSet _optParams; // list of optional parameters that shall be written out as normal parameters
186  };
187 
188 } // end namespace luiza
189 #endif
void writeToXML(std::ofstream &stream)
Definition: CCProcessor.cc:470
const ssMap & getColHeaders(const std::string &iotype)
Definition: CCProcessor.h:107
bool hasErrors()
Definition: CCProcessor.cc:443
void setName(const std::string &name)
Definition: CCProcessor.h:135
void addDCol(CCCollection *c)
Definition: CCProcessor.cc:331
bool isErrorCol(const std::string &type, const std::string &value)
Definition: CCProcessor.cc:393
const std::string & description()
Description of processor.
Definition: Processor.h:187
void remCol(const std::string &iotype, const std::string &name, unsigned int index)
Definition: CCProcessor.cc:339
bool hasErrorCols()
Definition: CCProcessor.h:63
void clearError(int error)
Definition: CCProcessor.cc:418
StringParameters * getParameters()
Definition: CCProcessor.h:104
sSet & getConditions()
Definition: CCProcessor.h:81
bool isInstalled()
Definition: CCProcessor.h:66
const std::string getStatusDesc()
Definition: CCProcessor.h:95
Base class for Luiza processors.
Definition: Processor.h:55
sSet & getColTypeNames(const std::string &iotype)
Definition: CCProcessor.cc:382
const std::string getError()
Definition: CCProcessor.h:92
void setOptionalParam(const std::string &key, bool optional=true)
Definition: CCProcessor.cc:461
const std::string & getType()
Definition: CCProcessor.h:78
void setConditions(const std::string &conditions)
Definition: CCProcessor.cc:153
void setError(int error)
Definition: CCProcessor.cc:411
void addCol(const std::string &iotype, const std::string &name, const std::string &type, const std::string &value)
Definition: CCProcessor.cc:291
bool isParamOptional(const std::string &key)
Definition: CCProcessor.cc:452
const std::string & getName()
Definition: CCProcessor.h:75
bool hasCondition(const std::string &condition)
Definition: CCProcessor.cc:201
const std::string getDescription()
Definition: CCProcessor.h:84
bool isActive()
Definition: CCProcessor.h:69
Namespace for Luiza framework.
Definition: CCCollection.h:6
void addUCol(CCCollection *c)
Definition: CCProcessor.cc:312
bool hasParameters()
Definition: CCProcessor.h:60
Definition: CCCollection.h:17
void changeStatus()
Definition: CCProcessor.cc:281
Definition: CCProcessor.h:43
ColVec & getCols(const std::string &iotype, const std::string &type_name="ALL_COLLECTIONS")
Definition: CCProcessor.cc:364