Loading...
Searching...
No Matches
CountedRef Class Reference

## Public Types

typedef int | id_type
| name type for identifiers
typedef CountedRefData | data_type
| Name type for handling referenced data.
typedef CountedRefPtr< CountedRefData * > | data_ptr
| Fix smart pointer type to referenced data.

## Public Member Functions

| CountedRef (leftv arg)
| Reference given Singular data.
| CountedRef (const self &rhs)
| Construct copy.
self & | operator= (const self &rhs)
| Replace reference.
BOOLEAN | assign (leftv result, leftv arg)
LeftvShallow | operator* ()
| Extract (shallow) copy of stored data.
BOOLEAN | outcast (leftv res, int typ)
| Construct reference data object marked by given identifier number.
BOOLEAN | outcast (leftv res)
| Construct reference data object from *this.
data_type * | outcast ()
| Construct raw reference data.
void | destruct ()
| Kills a link to the referenced object.
| ~CountedRef ()
| Kills the link to the referenced object.
BOOLEAN | dereference (leftv arg)
| Replaces argument by a shallow copy of the references data.
BOOLEAN | broken ()
| Check whether object in valid in current context.
BOOLEAN | unassigned () const
| Check whether (shared) data was initialized but not assigned yet.
BOOLEAN | count (leftv res)
| Get number of references pointing here, too.
BOOLEAN | enumerate (leftv res)
BOOLEAN | likewise (leftv res, leftv arg)
| Check for likewise identifiers.
BOOLEAN | same (leftv res, leftv arg)
| Check for identical reference objects.
BOOLEAN | type (leftv res)
| Get type of references data.
BOOLEAN | name (leftv res)
| Get (possibly) internal identifier name.

## Static Public Member Functions

static BOOLEAN | is_ref (leftv arg)
| Check whether argument is already a reference type.
static self | cast (void *data)
| Recover the actual object from raw Singular data.
static self | cast (leftv arg)
| Recover the actual object from Singular interpreter object.
static BOOLEAN | resolve (leftv arg)
| If necessary dereference.
static BOOLEAN | construct (leftv res, long data)
| Construct integer value.
static BOOLEAN | construct (leftv res, const char *data)
| Construct string.
static BOOLEAN | construct (leftv res)
| Construct void-style object.

## Protected Member Functions

| CountedRef (data_ptr arg)
| Recover previously constructed reference.

## Protected Attributes

data_ptr | m_data
| Store pointer to actual data.

## Private Types

typedef CountedRef | self

## Detailed Description

Definition at line 199 of file countedref.cc.

## Member Typedef Documentation

## data_ptr

typedef CountedRefPtr<CountedRefData*> CountedRef::data_ptr

Fix smart pointer type to referenced data.

Definition at line 210 of file countedref.cc.

## data_type

typedef CountedRefData CountedRef::data_type

Name type for handling referenced data.

Definition at line 207 of file countedref.cc.

## id_type

typedef int CountedRef::id_type

name type for identifiers

Definition at line 204 of file countedref.cc.

## self

typedef CountedRef CountedRef::self

private

Definition at line 200 of file countedref.cc.

## Constructor & Destructor Documentation

## CountedRef() [1/3]

CountedRef::CountedRef | ( | leftv | arg | ) |

inline explicit

Reference given Singular data.

Definition at line 223 of file countedref.cc.

: m_data(new data_type(arg)) { }
CountedRef::m_data
data_ptr m_data
Store pointer to actual data.
Definition countedref.cc:352
CountedRef::data_type
CountedRefData data_type
Name type for handling referenced data.
Definition countedref.cc:207

## CountedRef() [2/3]

CountedRef::CountedRef | ( | data_ptr | arg | ) |

inline protected

Recover previously constructed reference.

Definition at line 227 of file countedref.cc.

: m_data(arg) { assume(arg); }
assume
#define assume(x)
Definition mod2.h:389

## CountedRef() [3/3]

CountedRef::CountedRef | ( | const self & | rhs | ) |

inline

Construct copy.

Definition at line 231 of file countedref.cc.

: m_data(rhs.m_data) { }

## ~CountedRef()

CountedRef::~CountedRef | ( |  | ) |

inline

Kills the link to the referenced object.

Definition at line 271 of file countedref.cc.

{ }

## Member Function Documentation

## assign()

BOOLEAN CountedRef::assign | ( | leftv | result,
|  | leftv | arg )

inline

Definition at line 239 of file countedref.cc.

{
return m_data->assign(result,arg);
}
result
return result
Definition facAbsBiFact.cc:76

## broken()

BOOLEAN CountedRef::broken | ( |  | ) |

inline

Check whether object in valid in current context.

Definition at line 282 of file countedref.cc.

{return m_data->broken(); }

## cast() [1/2]

self CountedRef::cast | ( | leftv | arg | ) |

inline static

Recover the actual object from Singular interpreter object.

Definition at line 318 of file countedref.cc.

{
assume(arg != NULL); assume(is_ref(arg));
return self::cast(arg->Data());
}
CountedRef::is_ref
static BOOLEAN is_ref(leftv arg)
Check whether argument is already a reference type.
Definition countedref.cc:216
CountedRef::cast
static self cast(void *data)
Recover the actual object from raw Singular data.
Definition countedref.cc:312
sleftv::Data
void * Data()
Definition subexpr.cc:1192
NULL
#define NULL
Definition omList.c:12

## cast() [2/2]

self CountedRef::cast | ( | void * | data | ) |

inline static

Recover the actual object from raw Singular data.

Definition at line 312 of file countedref.cc.

{
assume(data != NULL);
return self(static_cast<data_type*>(data));
}
CountedRef::self
CountedRef self
Definition countedref.cc:200

## construct() [1/3]

BOOLEAN CountedRef::construct | ( | leftv | res | ) |

inline static

Construct void-style object.

Definition at line 344 of file countedref.cc.

{
res->data = NULL;
res->rtyp = NONE;
return FALSE;
}
FALSE
#define FALSE
Definition auxiliary.h:97
res
CanonicalForm res
Definition facAbsFact.cc:60
NONE
#define NONE
Definition tok.h:223

## construct() [2/3]

BOOLEAN CountedRef::construct | ( | leftv | res,
|  | const char * | data )

inline static

Construct string.

Definition at line 338 of file countedref.cc.

{
res->data = (void*)omStrDup(data);
res->rtyp = STRING_CMD;
return FALSE;
}
omStrDup
#define omStrDup(s)
Definition omAllocDecl.h:263
STRING_CMD
@ STRING_CMD
Definition tok.h:187

## construct() [3/3]

BOOLEAN CountedRef::construct | ( | leftv | res,
|  | long | data )

inline static

Construct integer value.

Definition at line 331 of file countedref.cc.

{
res->data = (void*) data;
res->rtyp = INT_CMD;
return FALSE;
}
INT_CMD
@ INT_CMD
Definition tok.h:96

## count()

BOOLEAN CountedRef::count | ( | leftv | res | ) |

inline

Get number of references pointing here, too.

Definition at line 288 of file countedref.cc.

{ return construct(res, m_data.count() - 1); }
CountedRef::construct
static BOOLEAN construct(leftv res, long data)
Construct integer value.
Definition countedref.cc:331

## dereference()

BOOLEAN CountedRef::dereference | ( | leftv | arg | ) |

inline

Replaces argument by a shallow copy of the references data.

Definition at line 274 of file countedref.cc.

{
m_data.reclaim();
BOOLEAN b= m_data->put(arg) || ((arg->next != NULL) && resolve(arg->next));
m_data.release();
return b;
}
BOOLEAN
int BOOLEAN
Definition auxiliary.h:88
b
CanonicalForm b
Definition cfModGcd.cc:4111
CountedRef::resolve
static BOOLEAN resolve(leftv arg)
If necessary dereference.
Definition countedref.cc:324
sleftv::next
leftv next
Definition subexpr.h:86

## destruct()

void CountedRef::destruct | ( |  | ) |

inline

Kills a link to the referenced object.

Definition at line 268 of file countedref.cc.

{ m_data.release(); }

## enumerate()

BOOLEAN CountedRef::enumerate | ( | leftv | res | ) |

inline

Definition at line 291 of file countedref.cc.

{ return construct(res, (long)(data_type*)m_data); }

## is_ref()

BOOLEAN CountedRef::is_ref | ( | leftv | arg | ) |

inline static

Check whether argument is already a reference type.

Note
  We check for the function pointer `countedref_CheckAssign` here, that we (ab-)use as a unique marker. This avoids to check a bunch of of runtime-varying `typ` IDs for identifying reference-like types.

Definition at line 216 of file countedref.cc.

{
int typ = arg->Typ();
return ((typ > MAX_TOK) &&
(getBlackboxStuff(typ)->blackbox_CheckAssign == countedref_CheckAssign));
}
getBlackboxStuff
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition blackbox.cc:17
sleftv::Typ
int Typ()
Definition subexpr.cc:1048
countedref_CheckAssign
BOOLEAN countedref_CheckAssign(blackbox *, leftv, leftv)
We use the function pointer as a marker of reference types for CountedRef::is_ref(leftv),...
Definition countedref.cc:193
MAX_TOK
@ MAX_TOK
Definition tok.h:220

## likewise()

BOOLEAN CountedRef::likewise | ( | leftv | res,
|  | leftv | arg )

inline

Check for likewise identifiers.

Definition at line 294 of file countedref.cc.

{
return resolve(arg) || construct(res, operator*()->data == arg->data);
}
sleftv::data
void * data
Definition subexpr.h:88

## name()

BOOLEAN CountedRef::name | ( | leftv | res | ) |

inline

Get (possibly) internal identifier name.

Definition at line 309 of file countedref.cc.

{ return construct(res, operator*()->Name()); }

## operator*()

LeftvShallow CountedRef::operator* | ( |  | ) |

inline

Extract (shallow) copy of stored data.

Definition at line 244 of file countedref.cc.

{ return m_data->operator*(); }

## operator=()

self & CountedRef::operator= | ( | const self & | rhs | ) |

inline

Replace reference.

Definition at line 234 of file countedref.cc.

{
m_data = rhs.m_data;
return *this;
}

## outcast() [1/3]

data_type * CountedRef::outcast | ( |  | ) |

inline

Construct raw reference data.

Definition at line 262 of file countedref.cc.

{
m_data.reclaim();
return m_data;
}

## outcast() [2/3]

BOOLEAN CountedRef::outcast | ( | leftv | res | ) |

inline

Construct reference data object from *this.

Definition at line 253 of file countedref.cc.

{
if (res->rtyp == IDHDL)
IDDATA((idhdl)res->data) = (char *)outcast();
else
res->data = (void *)outcast();
return FALSE;
}
CountedRef::outcast
data_type * outcast()
Construct raw reference data.
Definition countedref.cc:262
IDDATA
#define IDDATA(a)
Definition ipid.h:126
idhdl
idrec * idhdl
Definition ring.h:22
IDHDL
#define IDHDL
Definition tok.h:31

## outcast() [3/3]

BOOLEAN CountedRef::outcast | ( | leftv | res,
|  | int | typ )

inline

Construct reference data object marked by given identifier number.

Definition at line 247 of file countedref.cc.

{
res->rtyp = typ;
return outcast(res);
}

## resolve()

BOOLEAN CountedRef::resolve | ( | leftv | arg | ) |

inline static

If necessary dereference.

Definition at line 324 of file countedref.cc.

{
assume(arg != NULL);
while (is_ref(arg)) { if(CountedRef::cast(arg).dereference(arg)) return TRUE; };
return (arg->next != NULL) && resolve(arg->next);
}
TRUE
#define TRUE
Definition auxiliary.h:101
CountedRef::dereference
BOOLEAN dereference(leftv arg)
Replaces argument by a shallow copy of the references data.
Definition countedref.cc:274

## same()

BOOLEAN CountedRef::same | ( | leftv | res,
|  | leftv | arg )

inline

Check for identical reference objects.

Definition at line 299 of file countedref.cc.

{
return construct(res, m_data == arg->Data());
}

## type()

BOOLEAN CountedRef::type | ( | leftv | res | ) |

inline

Get type of references data.

Definition at line 304 of file countedref.cc.

{
return construct(res, Tok2Cmdname(operator*()->Typ()));
};
Tok2Cmdname
const char * Tok2Cmdname(int tok)
Definition gentable.cc:137

## unassigned()

BOOLEAN CountedRef::unassigned | ( |  | ) | const

inline

Check whether (shared) data was initialized but not assigned yet.

Definition at line 285 of file countedref.cc.

{ return m_data->unassigned(); }

## Field Documentation

## m_data

data_ptr CountedRef::m_data

protected

Store pointer to actual data.

Definition at line 352 of file countedref.cc.

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

- Singular/countedref.cc