00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef FALCON_CORESLOT_H
00017 #define FALCON_CORESLOT_H
00018
00019 #include <falcon/setup.h>
00020 #include <falcon/types.h>
00021 #include <falcon/itemlist.h>
00022 #include <falcon/string.h>
00023 #include <falcon/traits.h>
00024 #include <falcon/mt.h>
00025 #include <falcon/falconobject.h>
00026
00027 namespace Falcon {
00028
00029 class VMachine;
00030 class VMContext;
00031 class VMMessage;
00032
00039 class CoreSlot: public ItemList
00040 {
00041 String m_name;
00042 mutable Mutex m_mtx;
00043 mutable volatile int32 m_refcount;
00044
00045 Item m_assertion;
00046 bool m_bHasAssert;
00047
00048 public:
00049 CoreSlot( const String &name ):
00050 m_name( name ),
00051 m_refcount(1),
00052 m_bHasAssert( false )
00053 {}
00054
00055 const String& name() const { return m_name; }
00056
00068 void prepareBroadcast( VMContext *vmc, uint32 pfirst, uint32 pcount, VMMessage* msg = 0 );
00069
00073 bool remove( const Item &subsriber );
00074
00075
00076 void incref() const;
00077 void decref();
00078
00080 bool hasAssert() const { return m_bHasAssert; }
00081
00085 const Item &assertion() const { return m_assertion; }
00086
00090 void setAssertion( const Item &a ) { m_assertion = a; m_bHasAssert = true; }
00091
00095 void setAssertion( VMachine* vm, const Item &a );
00096
00100 void retract() {
00101 m_bHasAssert = false;
00102 m_assertion.setNil();
00103 }
00104
00105 virtual FalconData *clone() const;
00106 virtual void gcMark( uint32 mark );
00107
00108 virtual void getIterator( Iterator& tgt, bool tail = false ) const;
00109 virtual void copyIterator( Iterator& tgt, const Iterator& source ) const;
00110
00111 virtual void disposeIterator( Iterator& tgt ) const;
00112 };
00113
00114
00116 class CoreSlotPtrTraits: public ElementTraits
00117 {
00118 public:
00119 virtual ~CoreSlotPtrTraits() {}
00120 virtual uint32 memSize() const;
00121 virtual void init( void *itemZone ) const;
00122 virtual void copy( void *targetZone, const void *sourceZone ) const;
00123 virtual int compare( const void *first, const void *second ) const;
00124 virtual void destroy( void *item ) const;
00125 virtual bool owning() const;
00126 };
00127
00128 namespace traits
00129 {
00130 extern CoreSlotPtrTraits &t_coreslotptr();
00131 }
00132
00133 bool coreslot_broadcast_internal( VMachine *vm );
00134
00136 class FALCON_DYN_CLASS CoreSlotCarrier: public FalconObject
00137 {
00138 public:
00139 CoreSlotCarrier( const CoreClass* generator, CoreSlot* cs, bool bSeralizing = false );
00140 CoreSlotCarrier( const CoreSlotCarrier &other );
00141 virtual ~CoreSlotCarrier();
00142 virtual CoreObject *clone() const;
00143
00145 void setSlot( CoreSlot* cs );
00146 };
00147
00148 CoreObject* CoreSlotFactory( const CoreClass *cls, void *user_data, bool bDeserial );
00149
00150 }
00151
00152 #endif
00153
00154
00155