CXXR (C++ R)
Public Member Functions | Static Public Member Functions | Friends
CXXR::PairList Class Reference

Singly linked list of pairs. More...

#include <ConsCell.h>

Inheritance diagram for CXXR::PairList:
Inheritance graph
[legend]
Collaboration diagram for CXXR::PairList:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 PairList (RObject *cr=0, PairList *tl=0, const RObject *tg=0)
 PairList (const PairList &pattern)
 Copy constructor.
PairListclone () const
 Return pointer to a copy of this object.
unsigned int packGPBits () const
 Reproduce the gp bits field used in CR.
const char * typeName () const
 Name within R of this type of object.
void unpackGPBits (unsigned int gpbits)
 Interpret the gp bits field used in CR.
- Public Member Functions inherited from CXXR::ConsCell
iterator begin ()
const_iterator begin () const
RObjectcar () const
iterator end ()
const_iterator end () const
void setCar (RObject *cr)
 Set the 'car' value.
void setTag (const RObject *tg)
 Set the 'tag' value.
void setTail (PairList *tl)
 Set the 'tail' value.
const RObjecttag () const
const PairListtail () const
PairListtail ()
void visitReferents (const_visitor *v) const
 Conduct a visitor to the nodes referred to by this one.
- Public Member Functions inherited from CXXR::RObject
virtual const PairListattributes () const
 Get object attributes.
virtual void clearAttributes ()
 Remove all attributes.
void copyAttribute (const Symbol *name, const RObject *source)
 Copy an attribute from one RObject to another.
void copyAttributes (const RObject *source, bool copyS4)
 Copy attributes from one RObject to another.
virtual RObjectevaluate (Environment *env)
 Evaluate object in a specified Environment.
virtual RObjectgetAttribute (const Symbol *name) const
 Get the value a particular attribute.
virtual bool hasAttributes () const
 Has this object any attributes?
bool hasClass () const
 Has this object the class attribute?
bool isS4Object () const
 Is this an S4 object?
void maybeTraceMemory (const RObject *src)
 Carry out memory tracing.
void maybeTraceMemory (const RObject *src1, const RObject *src2)
 Carry out memory tracing.
void maybeTraceMemory (const RObject *src1, const RObject *src2, const RObject *src3)
 Carry out memory tracing.
bool memoryTraced () const
 Is copying etc. of this object being traced?
virtual void setAttribute (const Symbol *name, RObject *value)
 Set or remove an attribute.
void setAttributes (const PairList *new_attributes)
 Replace the attributes of an object.
void setMemoryTracing (bool on)
 Enable/disable tracing of copying etc.
void setS4Object (bool on)
 Set the status of this RObject as an S4 object.
SEXPTYPE sexptype () const
 Get an object's SEXPTYPE.
- Public Member Functions inherited from CXXR::GCNode
void expose () const
 Record that construction of a node is complete.
bool isExposed () const
 Has this node been exposed to garbage collection?

Static Public Member Functions

static PairListcons (RObject *cr, PairList *tl=0, const RObject *tag=0)
 Create a PairList element on the free store.
static PairListmake (size_t sz) throw (std::bad_alloc)
 Create a PairList of a specified length.
static const char * staticTypeName ()
 The name by which this type is known in R.
- Static Public Member Functions inherited from CXXR::ConsCell
template<class T >
static T * convert (ConsCell *cc)
 Convert a ConsCell to a (possibly) different ConsCell type.
- Static Public Member Functions inherited from CXXR::RObject
template<class T >
static T * clone (const T *pattern)
 Return a pointer to a copy of an object.
- Static Public Member Functions inherited from CXXR::GCNode
static void * operator new (size_t bytes)
 Allocate memory.
static void * operator new (size_t, void *where)
 Placement new for GCNode.
static void operator delete (void *p, size_t bytes)
 Deallocate memory.
static bool check ()
 Integrity check.
template<class T >
static T * expose (T *node)
 Record that construction of a node is complete.
static void gc ()
 Initiate a garbage collection.
static void gclite ()
 Lightweight garbage collection.
static void maybeCheckExposed (const GCNode *node)
 Subject to configuration, check that a GCNode is exposed.
static size_t numNodes ()
 Number of GCNode objects in existence.

Friends

class boost::serialization::access

Additional Inherited Members

- Protected Member Functions inherited from CXXR::ConsCell
 ConsCell (SEXPTYPE st, RObject *cr=0, PairList *tl=0, const RObject *tg=0)
 ConsCell (const ConsCell &pattern)
 Copy constructor.
 ConsCell (const ConsCell &pattern, int dummy)
 Tailless copy constructor.
 ~ConsCell ()
void detachReferents ()
 Null out all references from this node to other nodes.
- Protected Member Functions inherited from CXXR::RObject
 RObject (SEXPTYPE stype=CXXSXP)
 RObject (const RObject &pattern)
 Copy constructor.
- Protected Member Functions inherited from CXXR::GCNode
virtual ~GCNode ()

Detailed Description

Singly linked list of pairs.

LISP-like singly-linked list, each element containing pointers to a 'car' object (this is LISP terminology, and has nothing to do with automobiles) and to a 'tag' object, as well as a pointer to the next element of the list. (Any of these pointers may be null.) A PairList object is considered to 'own' its car, its tag, and all its successors.


Constructor & Destructor Documentation

CXXR::PairList::PairList ( RObject cr = 0,
PairList tl = 0,
const RObject tg = 0 
)
inlineexplicit
Parameters:
crPointer to the 'car' of the element to be constructed.
tlPointer to the 'tail' (LISP cdr) of the element to be constructed.
tgPointer to the 'tag' of the element to be constructed.
PairList::PairList ( const PairList pattern)

Copy constructor.

Parameters:
patternPairList to be copied.

Member Function Documentation

PairList * PairList::clone ( ) const
virtual

Return pointer to a copy of this object.

This function creates a copy of this object, and returns a pointer to that copy.

Generally this function (and the copy constructors it utilises) will attempt to create a 'deep' copy of the object; this follows standard practice within C++, and it is intended to extend this practice as CXXR development continues.

However, if the pattern object contains unclonable subobjects, then the created copy will at the relevant places simply contain pointers to those subobjects, i.e. to that extent the copy is 'shallow'. This is managed using the smart pointers defined by nested class RObject::Handle.

Returns:
a pointer to a clone of this object, or a null pointer if this object cannot be cloned.
Note:
Derived classes should exploit the covariant return type facility to return a pointer to the type of object being cloned.

Reimplemented from CXXR::RObject.

static PairList* CXXR::PairList::cons ( RObject cr,
PairList tl = 0,
const RObject tag = 0 
)
inlinestatic

Create a PairList element on the free store.

Unlike the constructor (and contrary to CXXR conventions generally) this function protects its arguments from the garbage collector.

Parameters:
crPointer to the 'car' of the element to be constructed.
tlPointer to the 'tail' (LISP cdr) of the element to be constructed.
tagPointer to the tag of the element to be constructed.
Returns:
Pointer to newly created PairList element.
PairList * PairList::make ( size_t  sz) throw (std::bad_alloc)
static

Create a PairList of a specified length.

This constructor creates a chain of PairList nodes with a specified number of elements. On creation, each element has null 'car' and 'tag'.

Parameters:
szNumber of elements required in the list. If zero, the function returns a null pointer.
unsigned int PairList::packGPBits ( ) const
virtual

Reproduce the gp bits field used in CR.

This function is used to reproduce the sxpinfo_struct.gp field used in CR. It should be used exclusively for serialization. Refer to the 'R Internals' document for details of this field.

Returns:
the reconstructed gp bits field (within the least significant 16 bits).
Note:
If this function is overridden in a derived class, the overriding function should call packGPBits() for its immediate base class, and then 'or' further bits into the result.

Reimplemented from CXXR::RObject.

static const char* CXXR::PairList::staticTypeName ( )
inlinestatic

The name by which this type is known in R.

Returns:
the name by which this type is known in R.

Reimplemented from CXXR::ConsCell.

const char * PairList::typeName ( ) const
virtual

Name within R of this type of object.

Returns:
the name by which this type of object is known within R.

Reimplemented from CXXR::RObject.

void PairList::unpackGPBits ( unsigned int  gpbits)
virtual

Interpret the gp bits field used in CR.

This function is used to interpret the sxpinfo_struct.gp field used in CR in a way appropriate to a particular node class. It should be used exclusively for deserialization. Refer to the 'R Internals' document for details of this field.

Parameters:
gpbitsthe gp bits field (within the least significant 16 bits).
Note:
If this function is overridden in a derived class, the overriding function should also pass its argument to unpackGPBits() for its immediate base class.

Reimplemented from CXXR::RObject.


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