20#ifndef SINGULAR_COUNTEDREF_H_
21#define SINGULAR_COUNTEDREF_H_
41template <
class PtrType,
bool Nondestructive =
false,
bool NeverNull =
false,
42 class CountType =
short>
86 operator bool()
const {
return NeverNull ||
m_ptr; }
133template <
class PtrType>
136template <
class PtrType>
150template <
class PtrType>
153template <
class PtrType>
218 res->data =(
void*) handle;
227 sprintf(
name,
" :%u:%p:_shared_: ", ++counter,
head->data);
228 if ((*root) ==
NULL )
243 template <
class Type>
245 return (Type*)memcpy(
result, data,
sizeof(Type));
247 template <
class Type>
248 static Type*
cpy(Type* data) {
251 template <
class Type>
253 if (data ==
NULL)
return data;
258 template <
class Type>
263 template <
class Type>
267 template <
class Type>
269 if(current ==
NULL)
return;
391 return (context ==
NULL) ||
CountedRefIndirectPtr & operator=(PtrType ptr)
CountedRefIndirectPtr(PtrType ptr)
This class implements a smart pointer which handles pointer-style access to a reference-counted struc...
count_type count() const
Store actual pointer.
ptr_type m_ptr
Store actual pointer.
self & operator=(const self &rhs)
self & operator=(ptr_type ptr)
const ptr_type operator->() const
CountedRefPtr(ptr_type ptr)
Convert from pointer.
void release()
Store actual pointer.
void reclaim()
Store actual pointer.
bool operator==(const self &rhs) const
Checking equality.
~CountedRefPtr()
Unlink one reference.
CountedRefPtr(const CountedRefPtr< ptr_type, !nondestructive, Never, count_type > &rhs)
Convert from compatible smart pointer.
CountedRefPtr()
Default constructor.
CountedRefPtr(const self &rhs)
Construct refernce copy.
bool operator==(ptr_type ptr) const
CountedRefWeakPtr(const self &rhs)
Construct copy.
CountedRefPtr< CountedRefIndirectPtr< ptr_type > * > ptrptr_type
Construct unassigned weak reference.
bool unassigned() const
Test whether reference was never used.
CountedRefWeakPtr()
Construct unassigned weak reference.
CountedRefWeakPtr(ptr_type ptr)
Convert from pointer.
ptr_type operator->()
Construct unassigned weak reference.
PtrType ptr_type
Construct unassigned weak reference.
bool operator==(ptr_type ptr) const
Construct unassigned weak reference.
self & operator=(ptr_type ptr)
Construct unassigned weak reference.
~CountedRefWeakPtr()
Unlink one reference (handled by CountedRefPtr)
void invalidate()
Mark weak reference as invalid.
ptrptr_type m_indirect
Construct unassigned weak reference.
const ptr_type operator->() const
Construct unassigned weak reference.
bool operator!=(ptr_type rhs) const
Construct unassigned weak reference.
self & operator=(const self &rhs)
Construct unassigned weak reference.
This class wraps leftv by taking into acount memory allocation, destruction as well as deeply copying...
LeftvDeep(leftv data)
Store a deep copy of the data @ note Occupies the provided leftv and invalidates the latter.
LeftvShallow operator*()
Store the actual data.
void clearid(idhdl *root)
Erase identifier handles by *this.
BOOLEAN isid() const
Check for being an identifier.
BOOLEAN ringed()
Test whether we reference to ring-dependent data.
BOOLEAN brokenid(idhdl context) const
Check a given context for our identifier.
LeftvDeep(leftv data, copy_tag)
Allocate all-zero object by default.
~LeftvDeep()
Really clear data.
BOOLEAN unassigned() const
Check whether (all-zero) initialized data was never assigned.
self & operator=(leftv rhs)
Reassign a new deep copy by occupieing another leftv.
LeftvDeep()
Allocate all-zero object by default.
self & operator=(const self &)
Allocate all-zero object by default.
BOOLEAN retrieve(leftv res)
Get additional data (e.g. subexpression data) from likewise instances.
bool like(const self &rhs) const
Determine whether we point to the same data.
leftv idify(idhdl *root)
Wrap data by identifier, if not done yet.
BOOLEAN put(leftv result)
Put a shallow copy to given leftv.
LeftvDeep(const self &)
Allocate all-zero object by default.
leftv m_data
Store the actual data.
Construct even deeper copy: Skip identifier (if any) and take care of the data on our own.
This class implements some recurrent code sniplets to be used with leftv and idhdl....
static Type * shallowcpy(Type *data)
static void recursivekill(Type *current)
static Type * cpy(Type *result, Type *data)
static idhdl newid(leftv head, idhdl *root)
static Type * recursivecpy(Type *data)
static void clearid(idhdl handle, idhdl *root)
static leftv idify(leftv head, idhdl *root)
static Type * cpy(Type *data)
static Type * shallowcpy(Type *result, Type *data)
Ths class wraps leftv by taking into acount memory allocation, destruction as well as shallowly copyi...
leftv operator->()
The actual data pointer.
leftv m_data
The actual data pointer.
LeftvShallow()
Just allocate (all-zero) leftv.
leftv operator->() const
The actual data pointer.
LeftvShallow(leftv data)
Shallow copy the input data.
self & operator=(leftv rhs)
Assign shallow copy of the input.
LeftvShallow(const self &rhs)
Construct (shallow) copy of *this.
self & operator=(const self &rhs)
Assign (shallow) copy of *this.
This class implements implements a refernce counter which we can use as a public base of objects mana...
RefCounter(...)
Any Constructor resets the counter.
count_type ref
Number of references.
short count_type
Name numerical type for enumbering.
idhdl set(const char *s, int lev, int t, BOOLEAN init=TRUE)
Class used for (list of) interpreter objects.
void CleanUp(ring r=currRing)
void countedref_reference_load()
Initialize blackbox types 'reference' and 'shared', or both.
void CountedRefPtr_kill(CountedRefIndirectPtr< PtrType > *pval)
void countedref_shared_load()
void killhdl2(idhdl h, idhdl *ih, ring r)
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
int name
New type name for int.