QCommand.hh

00001 /*
00002 * APOLLO: A complete DAQ and Online Data Analysis Framework for Cuore 
00003 * $Id: QCommand.hh 631 2006-12-19 11:54:27Z giacher $
00004 * M.P. created 16/4/4
00005 * 
00006 * Class QCommand: base class for all commands for all servers
00007 *
00008 */
00009 
00010 #ifndef _QCOMMAND_HH_
00011 #define _QCOMMAND_HH_
00012 
00013 // C/C++ Includes
00014 #include <string>
00015 #include <map>
00016 
00017 // Apollo Includes
00018 #include "QCuore.hh"
00019 
00020 #include "QError.hh"
00021 
00022 class QCommand {
00023 public:
00024         
00025   // ctor
00026   QCommand();
00027 
00028   // dtor
00029   virtual ~QCommand();
00030 
00031 
00032   // Inline Functions
00033   inline bool IsValid() const { return fIsValid;}
00034   inline bool HasAnswer() const { return fAnswer != "None";}
00035   inline const char* GetError() const { return fError.c_str();}
00036   inline const char* GetAnswer() const { return fAnswer.c_str();}
00037   inline const std::string& GetModifier() const {return fModifier;}
00038   inline const std::string& GetParams() const {return fParams;}
00039   
00040   virtual void Execute() = 0;
00041 
00042   virtual void CheckParams() = 0;
00043 
00044   static std::string& RemoveSpaces(std::string&);
00045 
00046 protected:
00047 
00048   inline void SetValid(bool val=true) {fIsValid=val;return;}
00049   inline void SetError (const std::string& val) {fError = val;return;}
00050   inline void SetAnswer(const std::string& val) {fAnswer = val;return;}
00051   inline void SetError (const char* val) { fError = val;return;}
00052   inline void SetAnswer(const char* val) { fAnswer = val;return;}
00053                 
00054   virtual void Reset() {SetModifier(""); SetParams(""); SetValid(false);return;}
00055   virtual void SetModifier(const std::string& s) {fModifier=s;return;}
00056   virtual void SetParams  (const std::string& s) {fParams=s;return;}
00057   
00058   int    GetIParameter (const std::string& name);
00059   double GetDParameter(const std::string& name);
00060   const std::string& GetSParameter(const std::string& name);
00061   bool   IsParamDefined (const std::string& name);
00062   
00063   virtual bool ParseParameters();
00064 
00065    virtual std::string GetFormattedError(const QError& err) const;
00066   // Map of key=value parameters
00067   std::map <std::string, std::string> fParamMap;
00068 
00069 private:
00070   bool fIsValid;
00071   std::string fError;
00072   std::string fAnswer;
00073   std::string fParams;
00074   std::string fModifier;
00075   
00076    
00077   friend class QBaseCmdParser;
00078   
00079 };
00080 
00081 #endif // _QCOMMAND_HH_

Generated on Fri Mar 6 13:40:40 2009 for CUORE Software by  doxygen 1.5.1