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<T>::group) / sizeof(JGroup<T>::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 36 of file JGroup.hh.

37  {}

Member Function Documentation

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

Get unique instance.

Definition at line 51 of file JGroup.hh.

52  {
53  static const JGroup object;
54 
55  return object;
56  }
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 65 of file JGroup.hh.

66  {
67  if (index >= 0 && index < size)
68  return this->group[index];
69  else
70  THROW(JIndexOutOfRange, "JGroup::operator() " << index);
71  }
#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:45
static const T group[]
actual group
Definition: JGroup.hh:39
Exception for accessing an index in a collection that is outside of its range.
Definition: JException.hh:90
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 80 of file JGroup.hh.

81  {
82  for (int i = 0; i != size; ++i) {
83  if (this->group[i] == object) {
84  return i;
85  }
86  }
87 
88  return -1;
89  }
static const int size
Number of objects.
Definition: JGroup.hh:45
static const T group[]
actual group
Definition: JGroup.hh:39

Member Data Documentation

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

actual group

Actual group.

Definition at line 39 of file JGroup.hh.

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

Number of objects.

Definition at line 45 of file JGroup.hh.


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