RTFX  0.3
Real time special effects collaborative visualization and production library.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
RTFXPropertyBasic.h
Go to the documentation of this file.
1 #ifndef __RTFX_PROPERTY_BASIC__
2 #define __RTFX_PROPERTY_BASIC__
3 
4 
5 
6 #include "RTFXBoostIncludes.h"
7 
8 #include "RTFXMath.h"
9 #include "RTFXRecorder.h"
10 #include "RTFXHelpers.h"
11 
20 using namespace std;
21 
22 namespace RTFX
23 {
31  template <class T>
32  class RTFXAPI RTFXPropertyBasic : public RTFXProperty
33  {
34  public:
36  RTFXPropertyBasic() { SetType( RTFXProperty::BASICTYPE ); value = 0; }
37 
39  void Copy( RTFXProperty * _p )
40  {
41  SetID( _p->GetID() );
42  SetName( _p->GetName() );
43  SetDescription( _p->GetDescription() );
44  SetOwner( _p->GetOwner() );
45  SetChanged( _p->GetChanged() );
46  SetType( _p->GetType() );
47  SetDelete( _p->GetDelete() );
48 
50  value = ptr_->GetValue();
51  }
52 
55 
57  void SetValue( T _value )
58  {
59  boost::lock_guard<boost::mutex> lock( *dataLock );
60  value = _value;
61  SetChanged( true );
62 
63  }
64 
66  T GetValue()
67  {
68  boost::lock_guard<boost::mutex> lock( *dataLock );
69  SetChanged( false );
70  T v_ = value;
71 
72  return value;
73  }
74 
77  bool EqualTo( RTFXProperty * _other )
78  {
79  // Check if Property types match (just in case)
80  if ( GetType() == _other->GetType() )
81  {
82  if ( value == (( RTFXPropertyBasic<T> * )_other)->value )
83  return true;
84  }
85  return false;
86  }
87 
88  private:
89 
91  T value;
92 
94  friend class boost::serialization::access;
95 
96  template<class Archive>
97  void serialize( Archive &_ar, const unsigned int _version )
98  {
99  // verbose( ostringstream().flush() << "RTFXPropertyBasic::serialize" << endl );
100  _ar & boost::serialization::base_object<RTFXProperty>( *this );
101  _ar & BOOST_SERIALIZATION_NVP( value );
102  };
103  };
104 }
105 
106 BOOST_CLASS_EXPORT_KEY( RTFX::RTFXPropertyBasic<bool> )
107 BOOST_CLASS_EXPORT_KEY( RTFX::RTFXPropertyBasic<unsigned int> )
108 BOOST_CLASS_EXPORT_KEY( RTFX::RTFXPropertyBasic<float> )
109 BOOST_CLASS_EXPORT_KEY( RTFX::RTFXPropertyBasic<double> )
110 BOOST_CLASS_EXPORT_KEY( RTFX::RTFXPropertyBasic<char> )
111 BOOST_CLASS_EXPORT_KEY( RTFX::RTFXPropertyBasic<int> )
112 
113 #endif