Go to the documentation of this file.00001 
00007 #pragma once
00008 
00009 #include "object.hpp"
00010 
00015 class agls_API IAttribute
00016     : public IObject
00017 {
00018 public:
00019     virtual ~IAttribute(void) { ; }
00020 
00021 public:
00022     inline virtual void SetValue(const int& riValue) = 0;
00023     inline virtual void GetValue(int& riValue) const = 0;
00024     inline virtual void SetValue(const float& rfValue) = 0;
00025     inline virtual void GetValue(float& rfValue) const = 0;
00026     inline virtual void SetValue(const double& rdValue) = 0;
00027     inline virtual void GetValue(double& rdValue) const = 0;
00028 };
00029 
00034 template<typename TN>
00035 class agls_API TAttribute
00036     : public TObject<TN>
00037 {
00038 public:
00039     TAttribute(void)
00040     {
00041         sprintf_s(this->m_acValue, STRLEN_ATTRIBUTE_VALUE, "\0");
00042     }
00043 
00044     virtual ~TAttribute(void) { ; }
00045 
00046 public:
00047     inline virtual void SetValue(const int& riValue)
00048     {
00049         sprintf_s(this->m_acValue, STRLEN_ATTRIBUTE_VALUE, "%d", riValue);
00050     }
00051 
00052     inline virtual void GetValue(int& riValue) const
00053     {
00054         riValue = atoi(this->m_acValue);
00055     }
00056 
00057     inline virtual void SetValue(const float& rfValue)
00058     {
00059         sprintf_s(this->m_acValue, STRLEN_ATTRIBUTE_VALUE, "%f", rfValue);
00060     }
00061 
00062     inline virtual void GetValue(float& rfValue) const
00063     {
00064         rfValue = static_cast<float>(atof(this->m_acValue));
00065     }
00066 
00067     inline virtual void SetValue(const double& rdValue)
00068     {
00069         sprintf_s(this->m_acValue, STRLEN_ATTRIBUTE_VALUE, "%f", rdValue);
00070     }
00071 
00072     inline virtual void GetValue(double& rdValue) const
00073     {
00074         rdValue = atof(this->m_acValue);
00075     }
00076 
00077 private:
00078     char m_acValue[STRLEN_ATTRIBUTE_VALUE];
00079 };
00080 
00085 class agls_API CAttribute
00086     : public TAttribute<IAttribute>
00087 {
00088 public:
00089     CAttribute(void);
00090     virtual ~CAttribute(void);
00091 };