Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | Related Pages

CCProcessor.h

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     // Constructor
00044     CCProcessor( bool status, const std::string& name, const std::string& type, StringParameters* p=NULL);
00045 
00046     // Copy Constructor
00047     CCProcessor( CCProcessor &p );
00048     
00049     // Destructor
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     /* Returns a string vector with the errors of the processor - Obsolete: use getError() instead */
00085     //const StringVec& getErrors(){ return _errors; }
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     // METHODS
00153     void addColsFromParam( StringParameters* p );
00154     void writeColsToParam();
00155     void clearParameters();
00156     void setMarlinProc();           //sets error flag NOT_INSTALLED if processor couldn't be set
00157     CCCollection* popCol( ColVec& v, CCCollection* c );   
00158 
00160     // VARIABLES
00162     bool _status;                   // false = INACTIVE ; true = ACTIVE
00163     bool _error[MAX_ERRORS];        // 0 = proc has no parameters; 1 = proc is not build in this marlin installation; 2 = unavailable collections
00164     std::string _name;              // name of the processor
00165     std::string _type;              // type of the processor
00166     StringParameters* _param;       // parameters from processor
00167     Processor* _proc;               // associated Marlin processor
00168  
00169     StringVec _error_desc;          // error descriptions for all processors
00170     StringVec _errors;              // list of errors found in a processor
00171 
00172     sSet _conditions;               // processor's conditions
00173   
00174     ssColVecMap _cols;              // first key for Types INPUT : OUTPUT : UNAVAILABLE : DUPLICATE
00175                                     // for INPUT/OUPUT the second key is for Collection Names
00176                                     // for UNAVAILABLE/DUPLICATE the second key is for Collection Types
00177 
00178     sssMap _types;                  // first key for Types INPUT : OUTPUT
00179                                     // second key is for Collection Names and the third string for Collection Types
00180 
00181     sSet _optParams;                // list of optional parameters that shall be written out as normal parameters
00182   };
00183 
00184 } // end namespace marlin
00185 #endif

Generated on Mon Jan 12 09:48:50 2009 for Marlin by doxygen 1.3.5