Jpp
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 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

◆ argument_type

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

◆ JRouter()

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  {}

◆ ~JRouter()

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

◆ getDefaultAddress()

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  }

◆ put()

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

75  {
76  if (this->empty()) {
77 
78  this->push_back(address);
79 
80  this->first = id;
81 
82  } else {
83 
84  for ( ; id < this->first; --(this->first)) {
85  this->push_front(getDefaultAddress());
86  }
87 
88  const unsigned int index = (unsigned int) (id - this->first);
89 
90  while (index >= this->size()) {
91  this->push_back(getDefaultAddress());
92  }
93 
94  this->at(index) = address;
95  }
96  }

◆ in_range()

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

106  {
107  return (id >= this->first && id < this->first + (int) this->size());
108  }

◆ get()

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

118  {
119  return this->at(id - this->first);
120  }

Member Data Documentation

◆ first

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

Definition at line 123 of file JRouter.hh.


The documentation for this class was generated from the following file:
JTOOLS::JRouter< JAddress_t, false >::getDefaultAddress
virtual const JAddress_t & getDefaultAddress() const
Get default address.
Definition: JRouter.hh:60
JTOOLS::JRouter< JAddress_t, false >::first
int first
Definition: JRouter.hh:123