PandaTree
|
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_type & | operator= (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. | |
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.
|
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.
|
inline |
Accessor to container.
Throws a runtime_error if container is not valid.
|
inline |
Accessor to idx.
Throws a runtime_error if idx is not valid.
|
inline |
Accessor to idx.
Throws a runtime_error if idx is not valid.
|
inline |
Initializer.
Invalidates the index by setting it to 0xffffffff.
|
inline |
The dereference operator.
Throws an invalid_argument exception if the reference is invalid.
|
inline |
The arrow operator.
Returns a null pointer if the container is not set or the index points to an invalid location.
|
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.
|
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.
|
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.