Jpp
 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 copy (const JRouter &router, const bool option=true)
 Copy 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 33 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 37 of file JRouter.hh.

Constructor & Destructor Documentation

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

Default constructor.

Definition at line 43 of file JRouter.hh.

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

Virtual destructor.

Definition at line 51 of file JRouter.hh.

52  {}

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 60 of file JRouter.hh.

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

Clear.

Definition at line 71 of file JRouter.hh.

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

Copy router.

Parameters
routerrouter
optioncopy addresses

Definition at line 85 of file JRouter.hh.

86  {
87  if (option) {
88 
89  *this = router;
90 
91  } else {
92 
93  this->resize(router.size());
94  this->first = router.first;
95  }
96  }
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 105 of file JRouter.hh.

106  {
107  if (this->empty()) {
108 
109  this->push_back(address);
110 
111  this->first = id;
112 
113  } else if (id < this->first) {
114 
115  this->insert(this->begin(), this->first - id, getDefaultAddress());
116 
117  this->first = id;
118 
119  this->at(0) = address;
120 
121  } else {
122 
123  const size_t index = (size_t) (id - this->first);
124 
125  if (index >= this->size()) {
126  this->resize(index + 1, getDefaultAddress());
127  }
128 
129  this->at(index) = address;
130  }
131  }
virtual const JAddress_t & getDefaultAddress() const
Get default address.
Definition: JRouter.hh:60
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 140 of file JRouter.hh.

141  {
142  return (id >= this->first && id < this->first + (int) this->size());
143  }
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 152 of file JRouter.hh.

153  {
154  return this->at(id - this->first);
155  }

Member Data Documentation

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

Definition at line 158 of file JRouter.hh.


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