Loading...
Searching...
No Matches
LeftvDeep Class Reference

This class wraps `leftv` by taking into account memory allocation, destruction as well as deeply copying of a given `leftv`, i.e. More...

`#include <countedref.h>`

## Data Structures

struct | copy_tag
| Construct even deeper copy: Skip identifier (if any) and take care of the data on our own. More...

## Private Types

typedef LeftvDeep | self

## Access via shallow copy to avoid invalidating the stored handle

leftv | m_data
| Store the actual data.
| operator LeftvShallow ()
| Store the actual data.
LeftvShallow | operator* ()
| Store the actual data.
bool | like (const self &rhs) const
| Determine whether we point to the same data.
self & | operator= (leftv rhs)
| Reassign a new deep copy by occupieing another `leftv`.
BOOLEAN | brokenid (idhdl context) const
| Check a given context for our identifier.
BOOLEAN | put (leftv result)
| Put a shallow copy to given `leftv`.
BOOLEAN | retrieve (leftv res)
| Get additional data (e.g. subexpression data) from likewise instances.
BOOLEAN | isid () const
| Check for being an identifier.
BOOLEAN | ringed ()
| Test whether we reference to ring-dependent data.
BOOLEAN | unassigned () const
| Check whether (all-zero) initialized data was never assigned.
leftv | idify (idhdl *root)
| Wrap data by identifier, if not done yet.
void | clearid (idhdl *root)
| Erase identifier handles by `*this`.

## Do not permit copying (avoid inconsistence)

self & | operator= (const self &)
| Allocate all-zero object by default.
| LeftvDeep (const self &)
| Allocate all-zero object by default.
| LeftvDeep ()
| Allocate all-zero object by default.
| LeftvDeep (leftv data)
| Store a deep copy of the data @ note Occupies the provided `leftv` and invalidates the latter.
| LeftvDeep (leftv data, copy_tag)
| Allocate all-zero object by default.
| ~LeftvDeep ()
| Really clear data.

## Additional Inherited Members

Static Public Member Functions inherited from LeftvHelper
static leftv | idify (leftv head, idhdl *root)
static idhdl | newid (leftv head, idhdl *root)
static void | clearid (idhdl handle, idhdl *root)
template<class Type>
static Type * | cpy (Type *result, Type *data)
template<class Type>
static Type * | cpy (Type *data)
template<class Type>
static Type * | recursivecpy (Type *data)
template<class Type>
static Type * | shallowcpy (Type *result, Type *data)
template<class Type>
static Type * | shallowcpy (Type *data)
template<class Type>
static void | recursivekill (Type *current)
static leftv | allocate ()

## Detailed Description

This class wraps `leftv` by taking into account memory allocation, destruction as well as deeply copying of a given `leftv`, i.e.

we also take over ownership of the `leftv` data.

We have two variants:

- LeftvDeep(leftv): treats referenced identifiers as "the data"
- LeftvDeep(leftv, copy_tag): takes care of a full copy of identifier's data

Note
  It invalidats `leftv` on input.

Definition at line 334 of file countedref.h.

## Data Structure Documentation

## LeftvDeep::copy_tag

struct LeftvDeep::copy_tag

Construct even deeper copy: Skip identifier (if any) and take care of the data on our own.

Definition at line 357 of file countedref.h.

## Member Typedef Documentation

## self

typedef LeftvDeep LeftvDeep::self

private

Definition at line 336 of file countedref.h.

## Constructor & Destructor Documentation

## LeftvDeep() [1/4]

LeftvDeep::LeftvDeep | ( | const self & |  | ) |

private

Allocate all-zero object by default.

## LeftvDeep() [2/4]

LeftvDeep::LeftvDeep | ( |  | ) |

inline

Allocate all-zero object by default.

Definition at line 346 of file countedref.h.

: m_data(allocate()) {}
LeftvDeep::m_data
leftv m_data
Store the actual data.
Definition countedref.h:450
LeftvHelper::allocate
static leftv allocate()
Definition countedref.h:273

## LeftvDeep() [3/4]

LeftvDeep::LeftvDeep | ( | leftv | data | ) |

inline

Store a deep copy of the data @ note Occupies the provided `leftv` and invalidates the latter.

Definition at line 350 of file countedref.h.

: m_data(cpy(data)) {
data->e = NULL; // occupy subexpression
if(!isid()) m_data->data=data->CopyD();
}
LeftvDeep::isid
BOOLEAN isid() const
Check for being an identifier.
Definition countedref.h:426
LeftvHelper::cpy
static Type * cpy(Type *result, Type *data)
Definition countedref.h:244
sleftv::CopyD
void * CopyD(int t)
Definition subexpr.cc:714
sleftv::e
Subexpr e
Definition subexpr.h:105
NULL
#define NULL
Definition omList.c:12

## LeftvDeep() [4/4]

LeftvDeep::LeftvDeep | ( | leftv | data,
|  | copy_tag | )

inline

Allocate all-zero object by default.

Definition at line 358 of file countedref.h.

: m_data(allocate()) { m_data->Copy(data); }

## ~LeftvDeep()

LeftvDeep::~LeftvDeep | ( |  | ) |

inline

Really clear data.

Definition at line 361 of file countedref.h.

{ m_data->CleanUp(); }

## Member Function Documentation

## brokenid()

BOOLEAN LeftvDeep::brokenid | ( | idhdl | context | ) | const

inline

Check a given context for our identifier.

Definition at line 389 of file countedref.h.

{
assume(isid());
return (context == NULL) ||
((context != (idhdl) m_data->data) && brokenid(IDNEXT(context)));
}
LeftvDeep::brokenid
BOOLEAN brokenid(idhdl context) const
Check a given context for our identifier.
Definition countedref.h:389
IDNEXT
#define IDNEXT(a)
Definition ipid.h:118
assume
#define assume(x)
Definition mod2.h:389
idhdl
idrec * idhdl
Definition ring.h:22

## clearid()

void LeftvDeep::clearid | ( | idhdl * | root | ) |

inline

Erase identifier handles by `*this`.

Note
  Assumes that we reference an identifier and that we own the latter. This is useful to clear the result of a subsequent call of `idify`.

Definition at line 442 of file countedref.h.

{
assume(isid());
if (--((idhdl)m_data->data)->ref <= 0) // clear only if we own
LeftvHelper::clearid((idhdl)m_data->data, root);
}
LeftvHelper::clearid
static void clearid(idhdl handle, idhdl *root)
Definition countedref.h:237

## idify()

leftv LeftvDeep::idify | ( | idhdl * | root | ) |

inline

Wrap data by identifier, if not done yet.

Definition at line 433 of file countedref.h.

{
leftv res = (isid()? m_data: LeftvHelper::idify(m_data, root));
++(((idhdl)res->data)->ref);
return res;
}
LeftvHelper::idify
static leftv idify(leftv head, idhdl *root)
Definition countedref.h:215
res
CanonicalForm res
Definition facAbsFact.cc:60
leftv
sleftv * leftv
Definition structs.h:53

## isid()

BOOLEAN LeftvDeep::isid | ( |  | ) | const

inline

Check for being an identifier.

Definition at line 426 of file countedref.h.

{ return m_data->rtyp==IDHDL;}
IDHDL
#define IDHDL
Definition tok.h:31

## like()

bool LeftvDeep::like | ( | const self & | rhs | ) | const

inline

Determine whether we point to the same data.

Definition at line 370 of file countedref.h.

{ return m_data->data == rhs.m_data->data; }

## operator LeftvShallow()

LeftvDeep::operator LeftvShallow | ( |  | ) |

inline

Store the actual data.

Definition at line 365 of file countedref.h.

{ return m_data; }

## operator*()

LeftvShallow LeftvDeep::operator* | ( |  | ) |

inline

Store the actual data.

Definition at line 366 of file countedref.h.

{return *this; }

## operator=() [1/2]

self & LeftvDeep::operator= | ( | const self & |  | ) |

private

Allocate all-zero object by default.

## operator=() [2/2]

self & LeftvDeep::operator= | ( | leftv | rhs | ) |

inline

Reassign a new deep copy by occupieing another `leftv`.

Note
  clears `*this` in the first

Definition at line 374 of file countedref.h.

{
if(isid()) {
m_data->e = rhs->e;
rhs->e = NULL;
IDTYP((idhdl)m_data->data) = rhs->Typ();
IDDATA((idhdl)m_data->data) = (char*) rhs->CopyD();
}
else {
m_data->CleanUp();
m_data->Copy(rhs);
}
return *this;
}
sleftv::Typ
int Typ()
Definition subexpr.cc:1048
IDDATA
#define IDDATA(a)
Definition ipid.h:126
IDTYP
#define IDTYP(a)
Definition ipid.h:119

## put()

BOOLEAN LeftvDeep::put | ( | leftv | result | ) |

inline

Put a shallow copy to given `leftv`.

Note
  `attrib` should read the attributes of the identifier

Definition at line 396 of file countedref.h.

{
leftv next = result->next;
result->next = NULL;
result->CleanUp();
shallowcpy(result, m_data);
result->next = next;
/// @note @c attrib should read the attributes of the identifier
if (isid()) {
result->attribute = ((idhdl)m_data->data)->attribute;
result->flag = ((idhdl)m_data->data)->flag;
}
return FALSE;
}
FALSE
#define FALSE
Definition auxiliary.h:97
LeftvHelper::shallowcpy
static Type * shallowcpy(Type *result, Type *data)
Definition countedref.h:259
sleftv::next
leftv next
Definition subexpr.h:86
sleftv::CleanUp
void CleanUp(ring r=currRing)
Definition subexpr.cc:351
result
return result
Definition facAbsBiFact.cc:76
next
ListNode * next
Definition janet.h:31

## retrieve()

BOOLEAN LeftvDeep::retrieve | ( | leftv | res | ) |

inline

Get additional data (e.g. subexpression data) from likewise instances.

Definition at line 414 of file countedref.h.

{
if (res->data == m_data->data) {
if(m_data->e != res->e) recursivekill(m_data->e);
cpy(m_data, res);
res->Init();
return TRUE;
}
return FALSE;
}
TRUE
#define TRUE
Definition auxiliary.h:101
LeftvHelper::recursivekill
static void recursivekill(Type *current)
Definition countedref.h:268

## ringed()

BOOLEAN LeftvDeep::ringed | ( |  | ) |

inline

Test whether we reference to ring-dependent data.

Definition at line 428 of file countedref.h.

{ return m_data->RingDependend(); }

## unassigned()

BOOLEAN LeftvDeep::unassigned | ( |  | ) | const

inline

Check whether (all-zero) initialized data was never assigned.

Definition at line 430 of file countedref.h.

{ return m_data->Typ()==0; }

## Field Documentation

## m_data

leftv LeftvDeep::m_data

private

Store the actual data.

Definition at line 450 of file countedref.h.

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

- Singular/countedref.h