00001 #ifndef CCPROCESSOR_H
00002 #define CCPROCESSOR_H
00003
00004 #include "marlin/Processor.h"
00005
00006 #include <set>
00007 #include <fstream>
00008
00009 #define MAX_ERRORS 3
00010 #define ACTIVE true
00011 #define INACTIVE false
00012 #define NO_PARAMETERS 0
00013 #define NOT_INSTALLED 1
00014 #define COL_ERRORS 2
00015 #define INPUT "lcioInType"
00016 #define OUTPUT "lcioOutType"
00017 #define UNAVAILABLE "lcioUnavailableType"
00018 #define DUPLICATE "lcioDuplicate"
00019
00020 namespace marlin {
00021
00022 class CCCollection;
00023
00024 typedef std::set< std::string > sSet;
00025 typedef std::vector< CCCollection* > ColVec;
00026 typedef std::map< std::string, std::string > ssMap;
00027 typedef std::map< std::string, ssMap > sssMap;
00028 typedef std::map< std::string, ColVec > sColVecMap;
00029 typedef std::map< std::string, sColVecMap > ssColVecMap;
00030
00039 class CCProcessor{
00040
00041 public:
00042
00043
00044 CCProcessor( bool status, const std::string& name, const std::string& type, StringParameters* p=NULL);
00045
00046
00047 CCProcessor( CCProcessor &p );
00048
00049
00050 ~CCProcessor();
00051
00053 bool hasErrors();
00054
00056 bool hasParameters(){ return !_error[ NO_PARAMETERS ]; }
00057
00059 bool hasErrorCols(){ return _error[ COL_ERRORS ]; }
00060
00062 bool isInstalled(){ return !_error[ NOT_INSTALLED ]; }
00063
00065 bool isActive(){ return _status; }
00066
00068 bool hasCondition( const std::string& condition );
00069
00071 const std::string& getName(){ return _name; }
00072
00074 const std::string& getType(){ return _type; }
00075
00077 sSet& getConditions(){ return _conditions; }
00078
00080 const std::string getDescription(){ return (isInstalled() ? _proc->description() :
00081 "This processor is NOT installed in your Marlin binary: parameter descriptions and types lost!!");
00082 }
00083
00084
00085
00086
00088 const std::string getError(){ return ( _errors.size() != 0 ? _errors[0] : "" ); }
00089
00091 const std::string getStatusDesc(){ return ( isActive() ? "Active" : "Inactive" ); }
00092
00094 bool isErrorCol( const std::string& type, const std::string& value );
00095
00097 bool isParamOptional( const std::string& key );
00098
00100 StringParameters* getParameters(){ return _param; }
00101
00103 const ssMap& getColHeaders( const std::string& iotype ){ return _types[iotype]; }
00104
00108 ColVec& getCols( const std::string& iotype, const std::string& type_name="ALL_COLLECTIONS" );
00109
00113 sSet& getColTypeNames( const std::string& iotype );
00114
00116 void addCol( const std::string& iotype, const std::string& name, const std::string& type, const std::string& value );
00117
00119 void remCol( const std::string& iotype, const std::string& name, unsigned int index );
00120
00122 void addUCol( CCCollection* c );
00123
00125 void addDCol( CCCollection* c );
00126
00128 void changeStatus();
00129
00131 void setName( const std::string& name ){ _name = name; };
00132
00134 void setConditions( const std::string& conditions );
00135
00137 void setError( int error );
00138
00140 void clearError( int error );
00141
00143 void setOptionalParam( const std::string& key, bool optional=true );
00144
00146 void writeToXML( std::ofstream& stream );
00147
00148 private:
00149
00151
00153 void addColsFromParam( StringParameters* p );
00154 void writeColsToParam();
00155 void clearParameters();
00156 void setMarlinProc();
00157 CCCollection* popCol( ColVec& v, CCCollection* c );
00158
00160
00162 bool _status;
00163 bool _error[MAX_ERRORS];
00164 std::string _name;
00165 std::string _type;
00166 StringParameters* _param;
00167 Processor* _proc;
00168
00169 StringVec _error_desc;
00170 StringVec _errors;
00171
00172 sSet _conditions;
00173
00174 ssColVecMap _cols;
00175
00176
00177
00178 sssMap _types;
00179
00180
00181 sSet _optParams;
00182 };
00183
00184 }
00185 #endif