My Project  UNKNOWN_GIT_VERSION
Public Types | Private Types | Private Member Functions
CountedRefData Class Reference

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  }

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

◆ 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
87  m_data.clearid(root());
88  }
89  }

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  }

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

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

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

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

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

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

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:
LeftvDeep::ringed
BOOLEAN ringed()
Test whether we reference to ring-dependent data.
Definition: countedref.h:428
FALSE
#define FALSE
Definition: auxiliary.h:94
LeftvDeep::put
BOOLEAN put(leftv result)
Put a shallow copy to given leftv.
Definition: countedref.h:396
result
return result
Definition: facAbsBiFact.cc:76
CountedRefData::rering
BOOLEAN rering()
Determine active ring when ring dependency changes.
Definition: countedref.cc:114
LeftvDeep::brokenid
BOOLEAN brokenid(idhdl context) const
Check a given context for our identifier.
Definition: countedref.h:389
LeftvShallow
Definition: countedref.h:284
CountedRefData::parent
static ring parent(leftv rhs)
Store ring for ring-dependent objects.
Definition: countedref.cc:165
LeftvDeep::isid
BOOLEAN isid() const
Check for being an identifier.
Definition: countedref.h:426
CountedRefData::put
BOOLEAN put(leftv res)
Write (shallow) copy to given handle.
Definition: countedref.cc:108
currPack
package currPack
Definition: ipid.cc:59
CountedRefWeakPtr::invalidate
void invalidate()
Mark weak reference as invalid.
Definition: countedref.h:178
sleftv::RingDependend
BOOLEAN RingDependend()
Definition: subexpr.cc:424
LeftvDeep::retrieve
BOOLEAN retrieve(leftv res)
Get additional data (e.g. subexpression data) from likewise instances.
Definition: countedref.h:414
CountedRefWeakPtr::unassigned
bool unassigned() const
Test whether reference was never used.
Definition: countedref.h:181
currRing
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
TRUE
#define TRUE
Definition: auxiliary.h:98
res
CanonicalForm res
Definition: facAbsFact.cc:64
CountedRefData::root
idhdl * root()
Get the current context.
Definition: countedref.cc:120
IDROOT
#define IDROOT
Definition: ipid.h:18
CountedRefData::weakref
back_ptr weakref()
Gerenate weak (but managed) reference to *this.
Definition: countedref.cc:95
CountedRefData::broken
BOOLEAN broken() const
Check whether identifier became invalid.
Definition: countedref.cc:123
LeftvDeep::idify
leftv idify(idhdl *root)
Wrap data by identifier, if not done yet.
Definition: countedref.h:433
CountedRefData::complain
BOOLEAN complain(const char *text) const
Raise error message and return TRUE.
Definition: countedref.cc:158
LeftvDeep::unassigned
BOOLEAN unassigned() const
Check whether (all-zero) initialized data was never assigned.
Definition: countedref.h:430
CountedRefData::m_data
LeftvDeep m_data
Singular object.
Definition: countedref.cc:172
CountedRefData::m_back
back_ptr m_back
Reference to actual object for wrap structures.
Definition: countedref.cc:178
LeftvDeep::clearid
void clearid(idhdl *root)
Erase identifier handles by *this.
Definition: countedref.h:442
CountedRefData::base
RefCounter base
Definition: countedref.cc:47
WerrorS
void WerrorS(const char *s)
Definition: feFopen.cc:24
basePack
package basePack
Definition: ipid.cc:60
NULL
#define NULL
Definition: omList.c:10
CountedRefData::m_ring
ring_ptr m_ring
Store namespace for ring-dependent objects.
Definition: countedref.cc:175
CountedRefData::wrapid
ptr_type wrapid()
Generate object for indexing.
Definition: countedref.cc:92
iiAssign
BOOLEAN iiAssign(leftv l, leftv r, BOOLEAN toplevel)
Definition: ipassign.cc:1819