PandaTree
Public Types | Public Member Functions | List of all members
panda::Ref< E > Class Template Reference

A reference to an element in a container. More...

#include <Ref.h>

Public Types

typedef Ref< E > self_type
 
typedef E value_type
 
typedef Short_t index_type
 

Public Member Functions

 Ref ()
 Default constructor.
 
 Ref (ContainerBase const *&c, index_type &idx)
 Standard constructor. More...
 
 Ref (self_type const &orig)
 Copy constructor.
 
void setIndex (index_type &idx)
 Set the index.
 
void setContainer (ContainerBase const *&c)
 Set the container. More...
 
value_type const * operator-> () const
 The arrow operator. More...
 
value_type const & operator* () const
 The dereference operator. More...
 
self_typeoperator= (self_type const &rhs)
 Copy assignment. More...
 
Bool_t setRef (value_type const *rhs)
 Setter function. More...
 
Bool_t isValid () const
 Validity check. Both container and idx must be valid, and idx must not be 0xffffffff.
 
void init ()
 Initializer. More...
 
index_type & idx ()
 Accessor to idx. More...
 
index_type idx () const
 Accessor to idx. More...
 
ContainerBase const * container () const
 Accessor to container. More...
 
value_type const * get () const
 Pointer to object.
 

Detailed Description

template<class E>
class panda::Ref< E >

A reference to an element in a container.

A Ref consists of a pointer reference to a collection and an integer that acts as the index to the element referred to. The references are supplied by the holder of the Ref during construction. At read time, the holder of the Ref is responsible for instructing the Ref to point to a specific index in the given collection. At write time, the Ref can be passed a pointer to the element to point to, using the operator=. The Ref object will find the proper index internally. The class has pointer-like operators (-> and *) to make the implementation details transparent to users.

Constructor & Destructor Documentation

§ Ref()

template<class E>
panda::Ref< E >::Ref ( ContainerBase const *&  c,
index_type &  idx 
)
inline

Standard constructor.

The container must be a derived class of Array<E> or Collection<E>. There is no protection against assigning a wrong type of container.

Member Function Documentation

§ container()

template<class E>
ContainerBase const* panda::Ref< E >::container ( ) const
inline

Accessor to container.

Throws a runtime_error if container is not valid.

§ idx() [1/2]

template<class E>
index_type& panda::Ref< E >::idx ( )
inline

Accessor to idx.

Throws a runtime_error if idx is not valid.

§ idx() [2/2]

template<class E>
index_type panda::Ref< E >::idx ( ) const
inline

Accessor to idx.

Throws a runtime_error if idx is not valid.

§ init()

template<class E>
void panda::Ref< E >::init ( )
inline

Initializer.

Invalidates the index by setting it to 0xffffffff.

§ operator*()

template<class E>
value_type const& panda::Ref< E >::operator* ( ) const
inline

The dereference operator.

Throws an invalid_argument exception if the reference is invalid.

§ operator->()

template<class E>
value_type const* panda::Ref< E >::operator-> ( ) const
inline

The arrow operator.

Returns a null pointer if the container is not set or the index points to an invalid location.

§ operator=()

template<class E>
self_type& panda::Ref< E >::operator= ( self_type const &  rhs)
inline

Copy assignment.

idx is copied by value. Change in the right-hand-side index value after the assignment is not reflected to the left-hand-side index.

§ setContainer()

template<class E>
void panda::Ref< E >::setContainer ( ContainerBase const *&  c)
inline

Set the container.

The container must be a derived class of Array<E> or Collection<E>. There is no protection against assigning a wrong type of container.

§ setRef()

template<class E>
Bool_t panda::Ref< E >::setRef ( value_type const *  rhs)
inline

Setter function.

Pass a pointer to a value_type object on the right hand side after the container is set. If the object is found in the collector, sets the index value. Returns true on successful set.


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