My Project
Loading...
Searching...
No Matches
Public Types | Private Types | Private Member Functions
CountedRefData Class Reference

This class stores a reference counter as well as a Singular interpreter object. More...

Public Types

typedef CountedRefWeakPtr< self * > back_ptr
 
- Public Types inherited from RefCounter
typedef short count_type
 Name numerical type for enumbering. More...
 

Private Types

typedef CountedRefData self
 
typedef RefCounter base
 

Private Member Functions

 CountedRefData (leftv wrapid, back_ptr back)
 Generate object linked to other reference (e.g. for subscripts) More...
 

Disallow copying to avoid inconsistence

typedef LeftvDeep::copy_tag copy_tag
 Fix smart pointer type to referenced data. More...
 
typedef back_ptr::ptr_type ptr_type
 Fix smart pointer type to referenced data. More...
 
typedef CountedRefPtr< ring, true > ring_ptr
 Fix smart pointer type to ring. More...
 
LeftvDeep m_data
 Singular object. More...
 
ring_ptr m_ring
 Store namespace for ring-dependent objects. More...
 
back_ptr m_back
 Reference to actual object for wrap structures. More...
 
selfoperator= (const self &)
 Fix smart pointer type to referenced data. More...
 
 CountedRefData (const self &)
 Fix smart pointer type to referenced data. More...
 
BOOLEAN complain (const char *text) const
 Raise error message and return TRUE. More...
 
 CountedRefData ()
 Construct shared memory empty Singular object. More...
 
 CountedRefData (leftv data)
 Reference Singular object. More...
 
 CountedRefData (leftv data, copy_tag do_copy)
 Construct reference for Singular object. More...
 
 ~CountedRefData ()
 Destruct. More...
 
ptr_type wrapid ()
 Generate object for indexing. More...
 
back_ptr weakref ()
 Gerenate weak (but managed) reference to *this. More...
 
selfoperator= (leftv rhs)
 Replace with other Singular data. More...
 
BOOLEAN put (leftv res)
 Write (shallow) copy to given handle. More...
 
LeftvShallow operator* () const
 Extract (shallow) copy of stored data. More...
 
BOOLEAN rering ()
 Determine active ring when ring dependency changes. More...
 
idhdlroot ()
 Get the current context. More...
 
BOOLEAN broken () const
 Check whether identifier became invalid. More...
 
BOOLEAN assign (leftv result, leftv arg)
 Reassign actual object. More...
 
BOOLEAN retrieve (leftv res)
 Recover additional information (e.g. subexpression) from likewise object. More...
 
BOOLEAN unassigned () const
 Check whether data is all-zero. More...
 
static ring parent (leftv rhs)
 Store ring for ring-dependent objects. More...
 

Additional Inherited Members

- Public Member Functions inherited from RefCounter
 RefCounter (...)
 Any Constructor resets the counter. More...
 
 ~RefCounter ()
 Destructor. More...
 

Detailed Description

This class stores a reference counter as well as a Singular interpreter object.

It also take care of the context, e.g. the current ring, wrap object, etc.

Definition at line 41 of file countedref.cc.

Member Typedef Documentation

◆ back_ptr

Definition at line 45 of file countedref.cc.

◆ base

Definition at line 47 of file countedref.cc.

◆ copy_tag

Fix smart pointer type to referenced data.

Definition at line 61 of file countedref.cc.

◆ ptr_type

Fix smart pointer type to referenced data.

Definition at line 64 of file countedref.cc.

◆ ring_ptr

Fix smart pointer type to ring.

Definition at line 67 of file countedref.cc.

◆ self

Definition at line 43 of file countedref.cc.

Constructor & Destructor Documentation

◆ CountedRefData() [1/5]

CountedRefData::CountedRefData ( leftv  wrapid,
back_ptr  back 
)
inlineprivate

Generate object linked to other reference (e.g. for subscripts)

Definition at line 50 of file countedref.cc.

50 :
51 base(), m_data(wrapid), m_ring(back->m_ring), m_back(back) {
52 }
ring_ptr m_ring
Store namespace for ring-dependent objects.
Definition: countedref.cc:175
LeftvDeep m_data
Singular object.
Definition: countedref.cc:172
RefCounter base
Definition: countedref.cc:47
back_ptr m_back
Reference to actual object for wrap structures.
Definition: countedref.cc:178
ptr_type wrapid()
Generate object for indexing.
Definition: countedref.cc:92

◆ CountedRefData() [2/5]

CountedRefData::CountedRefData ( const self )
private

Fix smart pointer type to referenced data.

◆ CountedRefData() [3/5]

CountedRefData::CountedRefData ( )
inlineexplicit

Construct shared memory empty Singular object.

Definition at line 70 of file countedref.cc.

70 :
71 base(), m_data(), m_ring(), m_back() { }

◆ CountedRefData() [4/5]

CountedRefData::CountedRefData ( leftv  data)
inlineexplicit

Reference Singular object.

Definition at line 74 of file countedref.cc.

74 :
75 base(), m_data(data), m_ring(parent(data)), m_back() { }
static ring parent(leftv rhs)
Store ring for ring-dependent objects.
Definition: countedref.cc:165

◆ CountedRefData() [5/5]

CountedRefData::CountedRefData ( leftv  data,
copy_tag  do_copy 
)
inline

Construct reference for Singular object.

Definition at line 78 of file countedref.cc.

78 :
79 base(), m_data(data, do_copy), m_ring(parent(data)), m_back() { }

◆ ~CountedRefData()

CountedRefData::~CountedRefData ( )
inline

Destruct.

Definition at line 82 of file countedref.cc.

82 {
83 if (!m_back.unassigned()) {
84 if (m_back == this)
86 else
88 }
89 }
idhdl * root()
Get the current context.
Definition: countedref.cc:120
bool unassigned() const
Test whether reference was never used.
Definition: countedref.h:181
void invalidate()
Mark weak reference as invalid.
Definition: countedref.h:178
void clearid(idhdl *root)
Erase identifier handles by *this.
Definition: countedref.h:442

Member Function Documentation

◆ assign()

BOOLEAN CountedRefData::assign ( leftv  result,
leftv  arg 
)
inline

Reassign actual object.

Definition at line 142 of file countedref.cc.

142 {
143
144 if (!m_data.isid()) {
145 (*this) = arg;
146 return FALSE;
147 }
148 return put(result) || iiAssign(result, arg) || rering();
149 }
#define FALSE
Definition: auxiliary.h:96
BOOLEAN rering()
Determine active ring when ring dependency changes.
Definition: countedref.cc:114
BOOLEAN put(leftv res)
Write (shallow) copy to given handle.
Definition: countedref.cc:108
BOOLEAN isid() const
Check for being an identifier.
Definition: countedref.h:426
return result
Definition: facAbsBiFact.cc:75
BOOLEAN iiAssign(leftv l, leftv r, BOOLEAN toplevel)
Definition: ipassign.cc:1963

◆ broken()

BOOLEAN CountedRefData::broken ( ) const
inline

Check whether identifier became invalid.

Definition at line 123 of file countedref.cc.

123 {
124 if (!m_back.unassigned() && !m_back)
125 return complain("Back-reference broken");
126
127 if (m_ring) {
128 if (m_ring != currRing)
129 return complain("Referenced identifier not from current ring");
130
131 return m_data.isid() && m_data.brokenid(currRing->idroot) &&
132 complain("Referenced identifier not available in ring anymore");
133 }
134
135 if (!m_data.isid()) return FALSE;
136 return m_data.brokenid(IDROOT) &&
137 ((currPack == basePack) || m_data.brokenid(basePack->idroot)) &&
138 complain("Referenced identifier not available in current context");
139 }
BOOLEAN complain(const char *text) const
Raise error message and return TRUE.
Definition: countedref.cc:158
BOOLEAN brokenid(idhdl context) const
Check a given context for our identifier.
Definition: countedref.h:389
VAR package basePack
Definition: ipid.cc:58
VAR package currPack
Definition: ipid.cc:57
#define IDROOT
Definition: ipid.h:19
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13

◆ complain()

BOOLEAN CountedRefData::complain ( const char *  text) const
inlineprivate

Raise error message and return TRUE.

Definition at line 158 of file countedref.cc.

159 {
160 WerrorS(text);
161 return TRUE;
162 }
#define TRUE
Definition: auxiliary.h:100
void WerrorS(const char *s)
Definition: feFopen.cc:24

◆ operator*()

LeftvShallow CountedRefData::operator* ( ) const
inline

Extract (shallow) copy of stored data.

Definition at line 111 of file countedref.cc.

111{ return (broken()? LeftvShallow(): (const LeftvShallow&)m_data); }
BOOLEAN broken() const
Check whether identifier became invalid.
Definition: countedref.cc:123
Ths class wraps leftv by taking into acount memory allocation, destruction as well as shallowly copyi...
Definition: countedref.h:285

◆ operator=() [1/2]

self & CountedRefData::operator= ( const self )
private

Fix smart pointer type to referenced data.

◆ operator=() [2/2]

self & CountedRefData::operator= ( leftv  rhs)
inline

Replace with other Singular data.

Definition at line 101 of file countedref.cc.

101 {
102 m_data = rhs;
103 m_ring = parent(rhs);
104 return *this;
105 }

◆ parent()

static ring CountedRefData::parent ( leftv  rhs)
inlinestaticprivate

Store ring for ring-dependent objects.

Definition at line 165 of file countedref.cc.

166 {
167 return (rhs->RingDependend()? currRing: NULL);
168 }
BOOLEAN RingDependend()
Definition: subexpr.cc:418
#define NULL
Definition: omList.c:12

◆ put()

BOOLEAN CountedRefData::put ( leftv  res)
inline

Write (shallow) copy to given handle.

Definition at line 108 of file countedref.cc.

108{ return broken() || m_data.put(res); }
BOOLEAN put(leftv result)
Put a shallow copy to given leftv.
Definition: countedref.h:396
CanonicalForm res
Definition: facAbsFact.cc:60

◆ rering()

BOOLEAN CountedRefData::rering ( )
inline

Determine active ring when ring dependency changes.

Definition at line 114 of file countedref.cc.

114 {
116 return (m_back && (m_back != this) && m_back->rering());
117 }
BOOLEAN ringed()
Test whether we reference to ring-dependent data.
Definition: countedref.h:428

◆ retrieve()

BOOLEAN CountedRefData::retrieve ( leftv  res)
inline

Recover additional information (e.g. subexpression) from likewise object.

Definition at line 151 of file countedref.cc.

151{ return m_data.retrieve(res); }
BOOLEAN retrieve(leftv res)
Get additional data (e.g. subexpression data) from likewise instances.
Definition: countedref.h:414

◆ root()

idhdl * CountedRefData::root ( )
inline

Get the current context.

Definition at line 120 of file countedref.cc.

120{ return (m_ring? &m_ring->idroot: &IDROOT); }

◆ unassigned()

BOOLEAN CountedRefData::unassigned ( ) const
inline

Check whether data is all-zero.

Definition at line 154 of file countedref.cc.

154{ return m_data.unassigned(); }
BOOLEAN unassigned() const
Check whether (all-zero) initialized data was never assigned.
Definition: countedref.h:430

◆ weakref()

back_ptr CountedRefData::weakref ( )
inline

Gerenate weak (but managed) reference to *this.

Definition at line 95 of file countedref.cc.

95 {
96 if (m_back.unassigned())
97 m_back = this;
98 return m_back;
99 }

◆ wrapid()

ptr_type CountedRefData::wrapid ( )
inline

Generate object for indexing.

Definition at line 92 of file countedref.cc.

92{ return new self(m_data.idify(root()), weakref()); }
CountedRefData self
Definition: countedref.cc:43
back_ptr weakref()
Gerenate weak (but managed) reference to *this.
Definition: countedref.cc:95
leftv idify(idhdl *root)
Wrap data by identifier, if not done yet.
Definition: countedref.h:433

Field Documentation

◆ m_back

back_ptr CountedRefData::m_back
protected

Reference to actual object for wrap structures.

Definition at line 178 of file countedref.cc.

◆ m_data

LeftvDeep CountedRefData::m_data
protected

Singular object.

Definition at line 172 of file countedref.cc.

◆ m_ring

ring_ptr CountedRefData::m_ring
protected

Store namespace for ring-dependent objects.

Definition at line 175 of file countedref.cc.


The documentation for this class was generated from the following file: