Jpp  15.0.3
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Attributes | Private Types | List of all members
JTOOLS::JRouter< JAddress_t, false > Class Template Reference

Template specialisation of JRouter without default address comparison. More...

#include <JRouter.hh>

Inheritance diagram for JTOOLS::JRouter< JAddress_t, false >:
JTOOLS::JRouter< JAddress_t, true >

Public Member Functions

 JRouter ()
 Default constructor. More...
 
virtual ~JRouter ()
 Virtual destructor. More...
 
virtual const JAddress_t & getDefaultAddress () const
 Get default address. More...
 
void clear ()
 Clear. More...
 
void swap (JRouter &router)
 Swap router. More...
 
void align (const JRouter &router)
 Align router. More...
 
void put (const int id, argument_type address)
 Store address for given identifier. More...
 
bool in_range (const int id) const
 Check whether given identifier is in range of this router. More...
 
const JAddress_t & get (const int id) const
 Get address of given identifier. More...
 

Protected Attributes

int first
 

Private Types

typedef JLANG::JClass
< JAddress_t >::argument_type 
argument_type
 

Detailed Description

template<class JAddress_t>
class JTOOLS::JRouter< JAddress_t, false >

Template specialisation of JRouter without default address comparison.

Definition at line 34 of file JRouter.hh.

Member Typedef Documentation

template<class JAddress_t >
typedef JLANG::JClass<JAddress_t>::argument_type JTOOLS::JRouter< JAddress_t, false >::argument_type
private

Definition at line 38 of file JRouter.hh.

Constructor & Destructor Documentation

template<class JAddress_t >
JTOOLS::JRouter< JAddress_t, false >::JRouter ( )
inline

Default constructor.

Definition at line 44 of file JRouter.hh.

44  :
45  std::deque<JAddress_t>()
46  {}
template<class JAddress_t >
virtual JTOOLS::JRouter< JAddress_t, false >::~JRouter ( )
inlinevirtual

Virtual destructor.

Definition at line 52 of file JRouter.hh.

53  {}

Member Function Documentation

template<class JAddress_t >
virtual const JAddress_t& JTOOLS::JRouter< JAddress_t, false >::getDefaultAddress ( ) const
inlinevirtual

Get default address.

Returns
default address

Reimplemented in JTOOLS::JRouter< JAddress_t, true >.

Definition at line 61 of file JRouter.hh.

62  {
63  static JAddress_t address;
64 
65  return address;
66  }
template<class JAddress_t >
void JTOOLS::JRouter< JAddress_t, false >::clear ( )
inline

Clear.

Definition at line 72 of file JRouter.hh.

73  {
74  static_cast<std::deque<JAddress_t>&>(*this).clear();
75 
76  this->first = 0;
77  }
template<class JAddress_t >
void JTOOLS::JRouter< JAddress_t, false >::swap ( JRouter< JAddress_t, false > &  router)
inline

Swap router.

Parameters
routerrouter

Definition at line 85 of file JRouter.hh.

86  {
87  std::swap(this->first, router.first);
88 
89  static_cast<std::deque<JAddress_t>&>(*this).swap(router);
90  }
template<class JAddress_t >
void JTOOLS::JRouter< JAddress_t, false >::align ( const JRouter< JAddress_t, false > &  router)
inline

Align router.

Parameters
routerrouter

Definition at line 98 of file JRouter.hh.

99  {
100  this->first = router.first;
101 
102  if (router.size() > this->size()) {
103  this->resize(router.size());
104  }
105  }
template<class JAddress_t >
void JTOOLS::JRouter< JAddress_t, false >::put ( const int  id,
argument_type  address 
)
inline

Store address for given identifier.

Parameters
ididentifier
addressaddress

Definition at line 114 of file JRouter.hh.

115  {
116  if (this->empty()) {
117 
118  this->push_back(address);
119 
120  this->first = id;
121 
122  } else if (id < this->first) {
123 
124  this->insert(this->begin(), this->first - id, getDefaultAddress());
125 
126  this->first = id;
127 
128  this->at(0) = address;
129 
130  } else {
131 
132  const size_t index = (size_t) (id - this->first);
133 
134  if (index >= this->size()) {
135  this->resize(index + 1, getDefaultAddress());
136  }
137 
138  this->at(index) = address;
139  }
140  }
virtual const JAddress_t & getDefaultAddress() const
Get default address.
Definition: JRouter.hh:61
template<class JAddress_t >
bool JTOOLS::JRouter< JAddress_t, false >::in_range ( const int  id) const
inline

Check whether given identifier is in range of this router.

Parameters
ididentifier
Returns
true if in range; else false

Definition at line 149 of file JRouter.hh.

150  {
151  return (id >= this->first && id < this->first + (int) this->size());
152  }
template<class JAddress_t >
const JAddress_t& JTOOLS::JRouter< JAddress_t, false >::get ( const int  id) const
inline

Get address of given identifier.

Parameters
ididentifier
Returns
address

Definition at line 161 of file JRouter.hh.

162  {
163  return this->at(id - this->first);
164  }

Member Data Documentation

template<class JAddress_t >
int JTOOLS::JRouter< JAddress_t, false >::first
protected

Definition at line 167 of file JRouter.hh.


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