Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Attributes | List of all members
JLANG::JGroup< T > Struct Template Reference

Auxiliary class for a fixed group of objects. More...

#include <JGroup.hh>

Public Member Functions

const Toperator() (const int index) const
 Get object at given index in group. More...
 
int operator() (const T &object) const
 Get index of given objec in group. More...
 

Static Public Member Functions

static const JGroupgetInstance ()
 Get unique instance. More...
 

Static Public Attributes

static const int size = sizeof(JGroup::group) / sizeof(JGroup::group[0])
 Number of objects. More...
 

Private Member Functions

 JGroup ()
 Default constructor. More...
 

Static Private Attributes

static const T group []
 actual group More...
 

Detailed Description

template<class T>
struct JLANG::JGroup< T >

Auxiliary class for a fixed group of objects.

A group should be defined as follows:

  template<>
  const XXX JGroup<XXX>::group[]  =  {
    XXX(...),
    XXX(...),
    ...
    XXX(...)
  };

Definition at line 31 of file JGroup.hh.

Constructor & Destructor Documentation

template<class T >
JLANG::JGroup< T >::JGroup ( )
inlineprivate

Default constructor.

Definition at line 85 of file JGroup.hh.

86  {}

Member Function Documentation

template<class T >
static const JGroup& JLANG::JGroup< T >::getInstance ( )
inlinestatic

Get unique instance.

Definition at line 41 of file JGroup.hh.

42  {
43  static const JGroup object;
44 
45  return object;
46  }
Auxiliary class for a fixed group of objects.
Definition: JGroup.hh:31
template<class T >
const T& JLANG::JGroup< T >::operator() ( const int  index) const
inline

Get object at given index in group.

Parameters
indexindex
Returns
object

Definition at line 55 of file JGroup.hh.

56  {
57  if (index >= 0 && index < size)
58  return this->group[index];
59  else
60  THROW(JIndexOutOfRange, "JGroup::operator() " << index);
61  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
static const int size
Number of objects.
Definition: JGroup.hh:35
Exception for accessing an index in a collection that is outside of its range.
Definition: JException.hh:90
static const T group[]
actual group
Definition: JGroup.hh:88
template<class T >
int JLANG::JGroup< T >::operator() ( const T object) const
inline

Get index of given objec in group.

Parameters
objectobject
Returns
index (-1 if object not found)

Definition at line 70 of file JGroup.hh.

71  {
72  for (int i = 0; i != size; ++i) {
73  if (this->group[i] == object) {
74  return i;
75  }
76  }
77 
78  return -1;
79  }
static const int size
Number of objects.
Definition: JGroup.hh:35
static const T group[]
actual group
Definition: JGroup.hh:88

Member Data Documentation

template<class T >
const int JLANG::JGroup< T >::size = sizeof(JGroup::group) / sizeof(JGroup::group[0])
static

Number of objects.

Definition at line 35 of file JGroup.hh.

template<class T >
const T JLANG::JGroup< T >::group[]
staticprivate

actual group

Definition at line 88 of file JGroup.hh.


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