My Project
Loading...
Searching...
No Matches
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.
 

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)
 

Disallow copying to avoid inconsistence

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

Additional Inherited Members

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

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.
LeftvDeep m_data
Singular object.
RefCounter base
Definition countedref.cc:47
back_ptr m_back
Reference to actual object for wrap structures.
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.

◆ 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)
85 m_back.invalidate();
86 else
87 m_data.clearid(root());
88 }
89 }
idhdl * root()
Get the current context.

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:97
BOOLEAN rering()
Determine active ring when ring dependency changes.
BOOLEAN put(leftv res)
Write (shallow) copy to given handle.
return result
BOOLEAN iiAssign(leftv l, leftv r, BOOLEAN toplevel)
Definition ipassign.cc:2097

◆ 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.
VAR package basePack
Definition ipid.cc:56
VAR package currPack
Definition ipid.cc:55
#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:101
void WerrorS(const char *s)
Definition feFopen.cc:24

◆ operator*()

LeftvShallow CountedRefData::operator* ( )
inline

Extract (shallow) copy of stored data.

Definition at line 111 of file countedref.cc.

111{ return (broken()? LeftvShallow(): LeftvShallow(m_data)); }
BOOLEAN broken() const
Check whether identifier became invalid.

◆ 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:421
#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); }
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 {
115 if (m_ring ^ m_data.ringed()) m_ring = (m_ring? NULL: currRing);
116 return (m_back && (m_back != this) && m_back->rering());
117 }

◆ 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); }

◆ 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(); }

◆ 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

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: