Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members | Related Pages

VectorIterator< Row > Class Template Reference

#include <VectorIterator.h>

Inheritance diagram for VectorIterator< Row >:

Inheritance graph
[legend]
Collaboration diagram for VectorIterator< Row >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<class Row>
class VectorIterator< Row >

An iterator over a vector with row type Row.

If we have a vector with a row type Row, e.g. vector<FooBar>, then a VectorFloatFun allows to iterate over all elements of the vector and return the value of one data member.

Let's assume we have a class FooBar defined like this:

 class FooBar {
   public:
     float foo;
     int bar;
     float foobar() const { return foo*bar; }
 };
and our DataLoop (derived from EventLoop, of course) has a data member foobarvector:
 class DataLoop: public EventLoop {
   public:
     DataLoop();
     ~DataLoop();
     void loop();
   private:
     vector<FooBar> foobarvector;
 };
We can for instance fill foobarvector in DataLoop:loop():
 void DataLoop::loop() {
   // fill foobarvector here
   foobarvector[xxx] = yyy;
   // Now fill the self-filling histos:
   EventLoop::loop();
 }
Now, to access the contents of foobarvector, we can do things like this:
 void DataLoop::DataLoop() {
   VectorIterator<FooBar>& foobar_it = 
       *new VectorIterator<FooBar> (foobarvector);
   FloatFun& foo_fun = foobar_it.Float (&FooBar::foo);
   FloatFun& bar_fun = foobar_it.Float (&FooBar::bar);
   FloatFun& foobar_fun = foobar_it.Float (&FooBar::foobar);
 }
These FloatFun objects will return the value of data members (foo or bar), or even the result of an access method like foobar(). This is achieved by creating objects of type VectorFloatFun (for access to data members) or VectorFloatFunFun (for access to member methods).

The notation &FooBar::foo is probably unfamiliar. Such a thing is called a member pointer. Essentially it is a kind of offset that describes where within an object a data member is stored. For more information, see any good C++ text book.

Author: Benno List, Jenny Böhme

Date
2006/09/12 09:24:48
Author
zimmerto

Definition at line 533 of file VectorIterator.h.

Public Member Functions

 VectorIterator (const std::vector< Row > &theVector_, const char *name_="?")
 Constructor.

virtual int operator() () const
 Returns iterator value, starting at 0.

virtual bool next ()
 Increments iterator; returns false if iterator cannot be incremented.

virtual bool reset ()
 Resets iterator; returns false if iterator value range is empty.

virtual bool isValid () const
 Returns whether current value of iterator is valid.

template<class Member> VectorFloatFun< Row, Member > & Float (Member Row::*p_mem, const char *name_="?") const
 Returns a FloatFun that returns a data member of T.

template<class Member> VectorFloatFunFun< Row, Member > & Float (Member(Row::*p_mem)() const, const char *name_="?") const
 Returns a FloatFun that returns the result of a member method of T.

template<class Member, class Arg> VectorFloatFunFunArg< Row,
Member, Arg > & 
Float (Member(Row::*p_mem)(Arg) const, Arg arg_, const char *name_="?") const
 Returns a FloatFun that returns the result of a member method of T that takes an argument.

template<class Member> VectorIntFun< Row, Member > & Int (Member Row::*p_mem, const char *name_="?") const
 Returns a IntFun that returns a data member of T.

template<class Member> VectorIntFunFun< Row, Member > & Int (Member(Row::*p_mem)() const, const char *name_="?") const
 Returns a IntFun that returns the result of a member method of T.

template<class Member, class Arg> VectorIntFunFunArg< Row, Member,
Arg > & 
Int (Member(Row::*p_mem)(Arg) const, Arg arg_, const char *name_="?") const
 Returns a IntFun that returns the result of a member method of T that takes an argument.

template<class Member> VectorBaseCut< Row, Member > & Bool (Member Row::*p_mem, const char *name_="?") const
 Returns a BaseCut that returns a data member of T.

template<class Member> VectorBaseCutFun< Row, Member > & Bool (Member(Row::*p_mem)() const, const char *name_="?") const
 Returns a BaseCut that returns the result of a member method of T.

template<class Member, class Arg> VectorBaseCutFunArg< Row,
Member, Arg > & 
Bool (Member(Row::*p_mem)(Arg) const, Arg arg_, const char *name_="?") const
 Returns a BaseCut that returns the result of a member method of T with an argument.


Protected Member Functions

virtual ~VectorIterator ()
 Protected destructor ensures creation on the heap.


Protected Attributes

const std::vector< Row > & theVector
 The vector.

unsigned int index
 The iterator index.


Constructor & Destructor Documentation

template<class Row>
VectorIterator< Row >::VectorIterator const std::vector< Row > &  theVector_,
const char *  name_ = "?"
[inline, explicit]
 

Constructor.

Parameters:
theVector_  the vector
name_  The variable name

Definition at line 536 of file VectorIterator.h.

References NamedO::getName(), VectorIterator< Row >::index, and VectorIterator< Row >::theVector.


Member Function Documentation

template<class Row>
template<class Member>
VectorFloatFun<Row, Member>& VectorIterator< Row >::Float Member Row::*  p_mem,
const char *  name_ = "?"
const [inline]
 

Returns a FloatFun that returns a data member of T.

class Member (Type of Member) must be a type that can be converted to a float, such as float, double, or int.

Definition at line 575 of file VectorIterator.h.

References VectorIterator< Row >::theVector.

template<class Row>
template<class Member>
VectorFloatFunFun<Row, Member>& VectorIterator< Row >::Float Member(Row::*  p_mem)() const,
const char *  name_ = "?"
const [inline]
 

Returns a FloatFun that returns the result of a member method of T.

class Member (Type of Member) must be a type that can be converted to a float, such as float, double, or int. The access method itself must be declared as Member foobar() const; (the const is important!).

Definition at line 590 of file VectorIterator.h.

References VectorIterator< Row >::theVector.

template<class Row>
template<class Member, class Arg>
VectorFloatFunFunArg<Row, Member, Arg>& VectorIterator< Row >::Float Member(Row::*  p_mem)(Arg) const,
Arg  arg_,
const char *  name_ = "?"
const [inline]
 

Returns a FloatFun that returns the result of a member method of T that takes an argument.

class Member (Type of Member) must be a type that can be converted to a float, such as float, double, or int. The access method itself must be declared as Member foobar(Arg) const; (the const is important!), where A is the type of the argument. A must have a copy constructor!

Definition at line 606 of file VectorIterator.h.

References VectorIterator< Row >::theVector.

template<class Row>
template<class Member>
VectorIntFun<Row, Member>& VectorIterator< Row >::Int Member Row::*  p_mem,
const char *  name_ = "?"
const [inline]
 

Returns a IntFun that returns a data member of T.

class Member (Type of Member) must be a type that can be converted to a int, such as float, double, or int.

Definition at line 619 of file VectorIterator.h.

References VectorIterator< Row >::theVector.

template<class Row>
template<class Member>
VectorIntFunFun<Row, Member>& VectorIterator< Row >::Int Member(Row::*  p_mem)() const,
const char *  name_ = "?"
const [inline]
 

Returns a IntFun that returns the result of a member method of T.

class Member (Type of Member) must be a type that can be converted to a int, such as float, double, or int. The access method itself must be declared as Member foobar() const; (the const is important!).

Definition at line 634 of file VectorIterator.h.

References VectorIterator< Row >::theVector.

template<class Row>
template<class Member, class Arg>
VectorIntFunFunArg<Row, Member, Arg>& VectorIterator< Row >::Int Member(Row::*  p_mem)(Arg) const,
Arg  arg_,
const char *  name_ = "?"
const [inline]
 

Returns a IntFun that returns the result of a member method of T that takes an argument.

class Member (Type of Member) must be a type that can be converted to a int, such as float, double, or int. The access method itself must be declared as Member foobar(Arg) const; (the const is important!), where A is the type of the argument. A must have a copy constructor!

Definition at line 650 of file VectorIterator.h.

References VectorIterator< Row >::theVector.

template<class Row>
template<class Member>
VectorBaseCut<Row, Member>& VectorIterator< Row >::Bool Member Row::*  p_mem,
const char *  name_ = "?"
const [inline]
 

Returns a BaseCut that returns a data member of T.

class Member (Type of Member) must be a type that can be converted to a bool, such as bool, float, double, or int.

Definition at line 663 of file VectorIterator.h.

References VectorIterator< Row >::theVector.

template<class Row>
template<class Member>
VectorBaseCutFun<Row, Member>& VectorIterator< Row >::Bool Member(Row::*  p_mem)() const,
const char *  name_ = "?"
const [inline]
 

Returns a BaseCut that returns the result of a member method of T.

class Member (Type of Member) must be a type that can be converted to a bool, such as bool, float, double, or int. The access method itself must be declared as Member foobar() const; (the const is important!).

Definition at line 678 of file VectorIterator.h.

References VectorIterator< Row >::theVector.

template<class Row>
template<class Member, class Arg>
VectorBaseCutFunArg<Row, Member, Arg>& VectorIterator< Row >::Bool Member(Row::*  p_mem)(Arg) const,
Arg  arg_,
const char *  name_ = "?"
const [inline]
 

Returns a BaseCut that returns the result of a member method of T with an argument.

class Member (Type of Member) must be a type that can be converted to a bool, such as bool, float, double, or int. The access method itself must be declared as Member foobar(Arg) const; (the const is important!)., where A is the type of the argument. A must have a copy constructor!

Definition at line 693 of file VectorIterator.h.

References VectorIterator< Row >::theVector.


The documentation for this class was generated from the following file:
Generated on Thu Oct 26 12:55:26 2006 for SFH by doxygen 1.3.2