Public Types | Public Member Functions | Protected Attributes | Private Types | Private Member Functions | Static 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
 
typedef LeftvDeep::copy_tag copy_tag
 
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...
 
- Public Types inherited from RefCounter
typedef short count_type
 Name numerical type for enumbering. More...
 

Public Member Functions

 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...
 
- Public Member Functions inherited from RefCounter
 RefCounter (...)
 Any Constructor resets the counter. More...
 
 ~RefCounter ()
 Destructor. More...
 

Protected Attributes

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...
 

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...
 
BOOLEAN complain (const char *text) const
 Raise error message and return TRUE. More...
 
Disallow copying to avoid inconsistence
selfoperator= (const self &)
 
 CountedRefData (const self &)
 

Static Private Member Functions

static ring parent (leftv rhs)
 Store ring for ring-dependent objects. 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

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

◆ CountedRefData() [2/5]

CountedRefData::CountedRefData ( const self )
private

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

◆ 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() { }
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
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() { }
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
static ring parent(leftv rhs)
Store ring for ring-dependent objects.
Definition: countedref.cc:165

◆ ~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
87  m_data.clearid(root());
88  }
89  }
void invalidate()
Mark weak reference as invalid.
Definition: countedref.h:178
LeftvDeep m_data
Singular object.
Definition: countedref.cc:172
back_ptr m_back
Reference to actual object for wrap structures.
Definition: countedref.cc:178
bool unassigned() const
Test whether reference was never used.
Definition: countedref.h:181
void clearid(idhdl *root)
Erase identifier handles by *this.
Definition: countedref.h:442
idhdl * root()
Get the current context.
Definition: countedref.cc:120

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  }
BOOLEAN put(leftv res)
Write (shallow) copy to given handle.
Definition: countedref.cc:108
LeftvDeep m_data
Singular object.
Definition: countedref.cc:172
#define FALSE
Definition: auxiliary.h:94
BOOLEAN rering()
Determine active ring when ring dependency changes.
Definition: countedref.cc:114
BOOLEAN isid() const
Check for being an identifier.
Definition: countedref.h:426
BOOLEAN iiAssign(leftv l, leftv r, BOOLEAN toplevel)
Definition: ipassign.cc:1793

◆ 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  }
ring_ptr m_ring
Store namespace for ring-dependent objects.
Definition: countedref.cc:175
LeftvDeep m_data
Singular object.
Definition: countedref.cc:172
back_ptr m_back
Reference to actual object for wrap structures.
Definition: countedref.cc:178
#define FALSE
Definition: auxiliary.h:94
#define IDROOT
Definition: ipid.h:20
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
bool unassigned() const
Test whether reference was never used.
Definition: countedref.h:181
package basePack
Definition: ipid.cc:64
package currPack
Definition: ipid.cc:63
BOOLEAN complain(const char *text) const
Raise error message and return TRUE.
Definition: countedref.cc:158
BOOLEAN isid() const
Check for being an identifier.
Definition: countedref.h:426
BOOLEAN brokenid(idhdl context) const
Check a given context for our identifier.
Definition: countedref.h:389

◆ 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:98
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); }
LeftvDeep m_data
Singular object.
Definition: countedref.cc:172
Ths class wraps leftv by taking into acount memory allocation, destruction as well as shallowly copyi...
Definition: countedref.h:284
BOOLEAN broken() const
Check whether identifier became invalid.
Definition: countedref.cc:123

◆ operator=() [1/2]

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

◆ 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  }
ring_ptr m_ring
Store namespace for ring-dependent objects.
Definition: countedref.cc:175
LeftvDeep m_data
Singular object.
Definition: countedref.cc:172
static ring parent(leftv rhs)
Store ring for ring-dependent objects.
Definition: countedref.cc:165

◆ 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  }
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
BOOLEAN RingDependend()
Definition: subexpr.cc:402
#define NULL
Definition: omList.c:10

◆ 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); }
LeftvDeep m_data
Singular object.
Definition: countedref.cc:172
BOOLEAN put(leftv result)
Put a shallow copy to given leftv.
Definition: countedref.h:396
BOOLEAN broken() const
Check whether identifier became invalid.
Definition: countedref.cc:123

◆ 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  }
ring_ptr m_ring
Store namespace for ring-dependent objects.
Definition: countedref.cc:175
LeftvDeep m_data
Singular object.
Definition: countedref.cc:172
back_ptr m_back
Reference to actual object for wrap structures.
Definition: countedref.cc:178
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
#define NULL
Definition: omList.c:10
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); }
LeftvDeep m_data
Singular object.
Definition: countedref.cc:172
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); }
ring_ptr m_ring
Store namespace for ring-dependent objects.
Definition: countedref.cc:175
#define IDROOT
Definition: ipid.h:20

◆ 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
LeftvDeep m_data
Singular object.
Definition: countedref.cc:172

◆ 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  }
back_ptr m_back
Reference to actual object for wrap structures.
Definition: countedref.cc:178
bool unassigned() const
Test whether reference was never used.
Definition: countedref.h:181

◆ 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()); }
LeftvDeep m_data
Singular object.
Definition: countedref.cc:172
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
idhdl * root()
Get the current context.
Definition: countedref.cc:120

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: