ArtMOO
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
G:/dev/qt/MOO/ServerCore/property.h
Go to the documentation of this file.
00001 #ifndef PROPERTY_H
00002 #define PROPERTY_H
00003 
00004 #include "mooglobal.h"
00005 
00006 #include <QVariant>
00007 #include <QDataStream>
00008 
00009 class Property
00010 {
00011 public:
00012         enum Permissions
00013         {
00014                 READ   = ( 1 << 0 ),
00015                 WRITE  = ( 1 << 1 ),
00016                 CHANGE = ( 1 << 2 )
00017         };
00018 
00019         void save( QDataStream &pData ) const;
00020         void load( QDataStream &pData );
00021 
00022         quint16 permissions( void ) const;
00023 
00024         inline ObjectId parent( void ) const
00025         {
00026                 return( mParent );
00027         }
00028 
00029         inline ObjectId owner( void ) const
00030         {
00031                 return( mOwner );
00032         }
00033 
00034         inline bool read( void ) const
00035         {
00036                 return( mRead );
00037         }
00038 
00039         inline bool write( void ) const
00040         {
00041                 return( mWrite );
00042         }
00043 
00044         inline bool change( void ) const
00045         {
00046                 return( mChange );
00047         }
00048 
00049         inline const QVariant &value( void ) const
00050         {
00051                 return( mValue );
00052         }
00053 
00054         inline QVariant::Type type( void ) const
00055         {
00056                 return( mValue.type() );
00057         }
00058 
00059         void setPermissions( quint16 pPerms );
00060 
00061         inline void setParent( ObjectId pParent )
00062         {
00063                 mParent = pParent;
00064         }
00065 
00066         inline void setOwner( ObjectId pOwner )
00067         {
00068                 mOwner = pOwner;
00069         }
00070 
00071         inline void setValue( const QVariant &pValue )
00072         {
00073                 mValue = pValue;
00074         }
00075 
00076         inline void setRead( bool pValue )
00077         {
00078                 mRead = pValue;
00079         }
00080 
00081         inline void setWrite( bool pValue )
00082         {
00083                 mWrite = pValue;
00084         }
00085 
00086         inline void setChange( bool pValue )
00087         {
00088                 mChange = pValue;
00089         }
00090 
00091         void initialise( void );
00092 
00093 private:
00094         ObjectId                mParent;
00095         ObjectId                mOwner;                 // The object that owns this property
00096         bool                    mRead;                  // Read permission lets non-owners get the value of the property
00097         bool                    mWrite;                 // write permission lets them set that value
00098         bool                    mChange;                // change ownership in descendants
00099         QVariant                mValue;
00100 };
00101 
00102 #endif // PROPERTY_H