22 #ifndef _cvc3__include__smartcdo_h_
23 #define _cvc3__include__smartcdo_h_
78 RefCDO(
Context* context): d_refCount(0), d_cdo(context), d_delay(false),
82 : d_refCount(0), d_cdo(context, cdo, scope), d_delay(false),
87 void kill() {
if(d_refCount==0 && !d_delay)
delete this; }
94 bool isNull()
const {
return (d_data==NULL); }
99 { d_data =
new RefCDO<T>(context); d_data->d_refCount++; }
102 { d_data =
new RefCDO<T>(context, data, scope); d_data->d_refCount++; }
106 if (--d_data->d_refCount == 0) d_data->kill(); }
109 {
if (!
isNull()) d_data->d_refCount++; }
113 if (
this == &cdo)
return *
this;
114 if (!
isNull() && --(d_data->d_refCount)) d_data->kill();
116 if (!
isNull()) ++(d_data->d_refCount);
120 void set(
const T& data,
int scope=-1)
const {
122 d_data->d_cdo.set(data, scope);
124 const T&
get()
const {
126 return d_data->d_cdo.get();
128 operator T()
const {
return get(); }
bool isNull() const
Check if the SmartCDO object is Null.
const SmartCDO< T > & operator=(const T &data) const
RefCDO(Context *context, const U &cdo, int scope=-1)
SmartCDO(Context *context)
Create and initialize SmartCDO object at the current scope.
#define DebugAssert(cond, str)
friend class RefNotifyObj
SmartCDO(const SmartCDO< T > &cdo)
SmartCDO< T > & operator=(const SmartCDO< T > &cdo)
RefNotifyObj * d_notifyObj
SmartCDO(Context *context, const T &data, int scope=-1)
Create and initialize SmartCDO object at the given scope.
void set(const T &data, int scope=-1) const
bool d_delay
Whether to delay our own deletion.
void kill()
Delete itself, unless delayed (then we'll be called again later)
SmartCDO()
Default constructor: create a Null SmartCDO object.
RefNotifyObj(RefCDO< U > *ref, Context *context)
Constructor.