CXXR (C++ R) API
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends
CXXR::HandleVector< T, ST > Class Template Reference

Vector of RObject::Handle smart pointers. More...

#include <HandleVector.hpp>

Inheritance diagram for CXXR::HandleVector< T, ST >:
Inheritance graph
[legend]
Collaboration diagram for CXXR::HandleVector< T, ST >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef Vector::const_iterator const_iterator

Public Member Functions

 HandleVector (size_t sz, T *init=0)
 Create a vector.
 HandleVector (const HandleVector< T, ST > &pattern)
 Copy constructor.
Handle< T > & operator[] (unsigned int index)
 Element access.
const T * operator[] (unsigned int index) const
 Read-only element access.
const_iterator begin () const
 Iterator designating first element.
const_iterator end () const
 One-past-the-end iterator.
const char * typeName () const
 Name within R of this type of object.
void visitReferents (const_visitor *v) const
 Conduct a visitor to the nodes referred to by this one.
- Public Member Functions inherited from CXXR::VectorBase
 VectorBase (SEXPTYPE stype, std::size_t sz)
 VectorBase (const VectorBase &pattern)
 Copy constructor.
const ListVectordimensionNames () const
 Names associated with the rows, columns or other dimensions of an R matrix or array.
const StringVectordimensionNames (unsigned int d) const
 Names associated with a particular dimension of an R matrix or array.
const IntVectordimensions () const
 Dimensions of R matrix or array.
const StringVectornames () const
 Names of vector elements.
void setDimensionNames (ListVector *names)
 Associate names with the rows, columns or other dimensions of an R matrix or array.
void setDimensionNames (unsigned int d, StringVector *names)
 Associate names with a particular dimension of an R matrix or array.
void setDimensions (IntVector *dims)
 Define the dimensions of R matrix or array.
void setNames (StringVector *names)
 Associate names with the elements of a VectorBase.
virtual void setSize (std::size_t new_size)
 Adjust the number of elements in the vector.
std::size_t size () const
 Number of elements in the vector.
VectorBaseclone () const
 Return pointer to a copy of this object.
- 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 unsigned int packGPBits () const
 Reproduce the gp bits field used in CR.
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.
virtual void unpackGPBits (unsigned int gpbits)
 Interpret the gp bits field used in CR.
- 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 const char * staticTypeName ()
 Name by which this type is known in R.
- Static Public Member Functions inherited from CXXR::VectorBase
template<class V >
static V * resize (const V *pattern, std::size_t new_size)
 Create an extended or shrunken copy of an R vector.
static PairListresizeAttributes (const PairList *attributes, std::size_t new_size)
 Adjust attributes for a resized vector.
- 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.

Protected Member Functions

 ~HandleVector ()
void detachReferents ()
 Null out all references from this node to other nodes.
- Protected Member Functions inherited from CXXR::VectorBase
void adjustSize (std::size_t new_size)
 Adjust the number of elements in the vector.
- 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 ()

Friends

class ElementProxy

Additional Inherited Members

- Public Attributes inherited from CXXR::VectorBase
R_len_t m_truelength
- Public Attributes inherited from CXXR::RObject
unsigned char m_named
unsigned m_missing: 2
unsigned m_argused: 2
bool m_active_binding: 1
bool m_binding_locked: 1

Detailed Description

template<typename T, SEXPTYPE ST>
class CXXR::HandleVector< T, ST >

Vector of RObject::Handle smart pointers.

This is a templated class to represent a vector whose elements are are smart pointers of type RObject::Handle<T>. As explained in the documentation for RObject::Handle, copying the vector will copy the objects pointed to, provided that they are clonable.

Parameters:
TThis should be RObject or a type (publicly) derived from RObject. The vector elements will be of type Handle<T>.
STThe required SEXPTYPE of the vector.

Constructor & Destructor Documentation

template<typename T, SEXPTYPE ST>
CXXR::HandleVector< T, ST >::HandleVector ( size_t  sz,
T *  init = 0 
)
inlineexplicit

Create a vector.

Parameters:
szNumber of elements required. Zero is permissible.
initInitial value for the destination of each T* in the HandleVector.
template<typename T, SEXPTYPE ST>
CXXR::HandleVector< T, ST >::HandleVector ( const HandleVector< T, ST > &  pattern)
inline

Copy constructor.

Parameters:
patternHandleVector to be copied. Beware that if any of the elements of pattern are unclonable, they will be shared between pattern and the created object. This is necessarily prejudicial to the constness of the pattern parameter.
template<typename T, SEXPTYPE ST>
CXXR::HandleVector< T, ST >::~HandleVector ( )
inlineprotected

Declared protected to ensure that HandleVector objects are allocated only using 'new'.


Member Function Documentation

template<typename T, SEXPTYPE ST>
const_iterator CXXR::HandleVector< T, ST >::begin ( ) const
inline

Iterator designating first element.

Returns:
An iterator designating the first element of the HandleVector. Returns end() if the vector is empty.
template<typename T , SEXPTYPE ST>
void CXXR::HandleVector< T, ST >::detachReferents ( )
protectedvirtual

Null out all references from this node to other nodes.

The referents of this node are those objects (derived from GCNode) designated by a GCEdge within this object. This function changes all GCEdges within this object to encapsulate a null pointer. It is used during the sweep phase of a mark-sweep garbage collection to break up unreachable subgraphs, and in particular to remove reference loops from them. After the application of this method, the GCNode should be regarded as a 'zombie', kept in existence only so other nodes can detach their references to it cleanly (using decRefCount()).

Note:
If this method is reimplemented in a derived class, the reimplemented version must remember to invoke detachReferents() for the immediate base class of the derived class, to ensure that all referents of the object get detached.

Reimplemented from CXXR::RObject.

template<typename T, SEXPTYPE ST>
const_iterator CXXR::HandleVector< T, ST >::end ( ) const
inline

One-past-the-end iterator.

Returns:
An iterator designating a position 'one past the end' of the HandleVector.
template<typename T, SEXPTYPE ST>
Handle<T>& CXXR::HandleVector< T, ST >::operator[] ( unsigned int  index)
inline

Element access.

Parameters:
indexIndex of required element (counting from zero). No bounds checking is applied.
Returns:
the specified element.
template<typename T, SEXPTYPE ST>
const T* CXXR::HandleVector< T, ST >::operator[] ( unsigned int  index) const
inline

Read-only element access.

Parameters:
indexIndex of required element (counting from zero). No bounds checking is applied.
Returns:
the specified element.
template<typename T, SEXPTYPE ST>
static const char* CXXR::HandleVector< T, ST >::staticTypeName ( )
inlinestatic

Name by which this type is known in R.

Returns:
the name by which this type is known in R.
Note:
This function is declared but not defined as part of the HandleVector template. It must be defined as a specialization for each instantiation of the template for which it or typeName() is used.

Reimplemented from CXXR::VectorBase.

template<typename T , SEXPTYPE ST>
const char * CXXR::HandleVector< T, ST >::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.

template<typename T , SEXPTYPE ST>
void CXXR::HandleVector< T, ST >::visitReferents ( const_visitor v) const
virtual

Conduct a visitor to the nodes referred to by this one.

The referents of this node are those objects (derived from GCNode) designated by a GCEdge within this object.

Parameters:
vPointer to the visitor object.
Note:
If this method is reimplemented in a derived class, the reimplemented version must remember to invoke visitReferents() for the immediate base class of the derived class, to ensure that all referents of the object get visited. It is suggested that implementations set up stack-based pointers to all the referents of a node before visiting any of them; in that case, if the (recursive) visiting pushes the node out of the processor cache, there is no need to fetch it back in.

Reimplemented from CXXR::RObject.


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