LibCT 2.0

Include/VariableInterface.h

Go to the documentation of this file.
00001 // ------------------------------------------------------------------
00012 #ifndef _LIBCT_VARIABLEINTERFACE_H
00013 #define _LIBCT_VARIABLEINTERFACE_H
00014 
00015 #include "VariableTypes.h"
00016 #include "VariableContainer.h"
00017 
00018 #include <string>
00019 #include <assert.h>
00020 
00021 namespace LibCT
00022 {
00024         class VariableInterface
00025         {
00026         public:
00028                 VariableInterface(VariableContainer* pContainer, const std::string& name)
00029                         : m_pContainer(pContainer)
00030                         , m_Name(name)
00031                 {
00032                 }
00033 
00035                 virtual ~VariableInterface() {}
00036 
00039                 virtual VariableType    GetType() const = 0;
00040 
00043                 virtual std::string             ToString() const = 0;
00044 
00047                 virtual std::string             GetTypeString() const = 0;
00048 
00051                 virtual bool operator	==	(
00052                         const VariableInterface& rhs    
00053                         ) const = 0;
00054 
00057                 virtual bool operator	!=	(
00058                         const VariableInterface& rhs    
00059                         ) const = 0;
00060 
00063                 virtual bool operator	<	(
00064                         const VariableInterface& rhs    
00065                         ) const = 0;
00066 
00069                 virtual bool operator	<=	(
00070                         const VariableInterface& rhs    
00071                         ) const = 0;
00072 
00075                 virtual bool operator	>	(
00076                         const VariableInterface& rhs    
00077                         ) const = 0;
00078 
00081                 virtual bool operator	>=	(
00082                         const VariableInterface& rhs    
00083                         ) const = 0;
00084 
00087                 VariableContainer* GetContainer() const
00088                 {
00089                         return m_pContainer;
00090                 }
00091 
00094                 const std::string& GetName() const
00095                 {
00096                         return m_Name;
00097                 }
00098 
00101                 bool Execute(
00102                         VariableOperator oper,                  
00103                         const VariableInterface& rhs    
00104                         )
00105                 {
00106                         switch(oper)
00107                         {
00108                         case LibCT::VariableOperatorEq:
00109                                 return *this == rhs;
00110                                 break;
00111                         case LibCT::VariableOperatorNe:
00112                                 return *this != rhs;
00113                                 break;
00114                         case LibCT::VariableOperatorLt:
00115                                 return *this < rhs;
00116                                 break;
00117                         case LibCT::VariableOperatorLtEq:
00118                                 return *this <= rhs;
00119                                 break;
00120                         case LibCT::VariableOperatorGt:
00121                                 return *this > rhs;
00122                                 break;
00123                         case LibCT::VariableOperatorGtEq:
00124                                 return *this >= rhs;
00125                                 break;
00126                         default:
00127                                 assert(0 && "Unknown operator");
00128                                 break;
00129                         }
00130                         return false;
00131                 }
00132 
00133         private:
00134                 VariableContainer*      m_pContainer;   
00135                 std::string                     m_Name;                 
00136         };
00137 }
00138 
00139 #endif // _LIBCT_VARIABLEINTERFACE_H