00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef flc_cobject_H
00018 #define flc_cobject_H
00019
00020 #include <falcon/types.h>
00021 #include <falcon/garbageable.h>
00022 #include <falcon/common.h>
00023 #include <falcon/proptable.h>
00024 #include <falcon/deepitem.h>
00025 #include <falcon/item.h>
00026 #include <falcon/objectfactory.h>
00027
00028 namespace Falcon {
00029
00030 class VMachine;
00031 class String;
00032 class CoreClass;
00033 class MemPool;
00034 class Sequence;
00035 class FalconData;
00036 class ItemDict;
00037
00108 class FALCON_DYN_CLASS CoreObject: public DeepItem, public Garbageable
00109 {
00110 protected:
00111 void *m_user_data;
00112 bool m_bIsFalconData;
00113 bool m_bIsSequence;
00114
00115 const CoreClass *m_generatedBy;
00116 CoreObject( const CoreClass *parent );
00117 CoreObject( const CoreObject &other );
00118
00149 bool defaultProperty( const String &key, Item &prop ) const;
00150
00157 void readOnlyError( const String &key ) const;
00158
00159 protected:
00160
00174 bool getMethodDefault( const String &name, Item &mth ) const;
00175
00176 public:
00177
00181 virtual ~CoreObject();
00182
00191 Sequence* getSequence() const { return m_bIsSequence ? static_cast<Sequence*>( m_user_data ) : 0; }
00192
00201 FalconData *getFalconData() const { return m_bIsFalconData ? static_cast<FalconData*>( m_user_data ) : 0; }
00202
00204 void *getUserData() const { return m_user_data; }
00205
00211 void setUserData( void *data ) { m_user_data = data; }
00212
00220 void setUserData( FalconData* fdata ) { m_bIsFalconData = true; m_user_data = fdata; }
00221
00226 void setUserData( Sequence* sdata ) { m_bIsSequence = true; m_bIsFalconData = true; m_user_data = sdata; }
00227
00229 bool derivedFrom( const String &className ) const;
00230
00234 virtual bool serialize( Stream *stream, bool bLive ) const;
00235
00248 virtual bool deserialize( Stream *stream, bool bLive );
00249
00255 virtual void gcMark( uint32 mark );
00256
00262 virtual bool hasProperty( const String &prop ) const;
00263
00280 virtual CoreObject *clone() const = 0;
00281
00293 virtual bool setProperty( const String &prop, const Item &value ) = 0;
00294
00298 bool setProperty( const String &prop, const String &value );
00299
00300
00309 virtual bool getProperty( const String &prop, Item &value ) const = 0;
00310
00324 bool getMethod( const String &propName, Item &method ) const
00325 {
00326 if ( getProperty( propName, method ) )
00327 return method.methodize( SafeItem(const_cast<CoreObject*>(this)) );
00328 return false;
00329 }
00330
00336 const CoreClass *generator() const { return m_generatedBy; }
00337
00356 bool apply( const ItemDict& dict, bool bRaiseOnError = false );
00357
00380 bool retrieve( ItemDict& dict, bool bRaiseOnError = false, bool bFillDict = false, bool bIgnoreMethods = true ) const;
00381
00386 virtual void readIndex( const Item &pos, Item &target );
00387
00392 virtual void writeIndex( const Item &pos, const Item &target );
00393
00397 virtual void readProperty( const String &pos, Item &target );
00398
00402 virtual void writeProperty( const String &pos, const Item &target );
00403
00404
00405 };
00406
00407 }
00408
00409 #endif
00410
00411