Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
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 >:
std::vector< JAddress_t > JTOOLS::JRouter< JAddress_t, true >

Public Member Functions

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

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

◆ argument_type

template<class JAddress_t >
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

◆ JRouter()

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

Default constructor.

Definition at line 44 of file JRouter.hh.

◆ ~JRouter()

template<class JAddress_t >
virtual JTOOLS::JRouter< JAddress_t, false >::~JRouter ( )
inlinevirtual

Virtual destructor.

Definition at line 53 of file JRouter.hh.

54 {}

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

63 {
64 static JAddress_t address;
65
66 return address;
67 }

◆ clear()

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

Clear.

Definition at line 73 of file JRouter.hh.

74 {
75 static_cast<std::vector<JAddress_t>&>(*this).clear();
76
77 this->first = 0;
78 }

◆ swap()

template<class JAddress_t >
void JTOOLS::JRouter< JAddress_t, false >::swap ( JRouter< JAddress_t, false > & router)
inline

Swap router.

Parameters
routerrouter

Definition at line 86 of file JRouter.hh.

87 {
88 std::swap(this->first, router.first);
89
90 static_cast<std::vector<JAddress_t>&>(*this).swap(router);
91 }

◆ align()

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

100 {
101 this->first = router.first;
102
103 if (router.size() > this->size()) {
104 this->resize(router.size());
105 }
106 }

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

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

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

151 {
152 return (id >= this->first && id < this->first + (int) this->size());
153 }

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

163 {
164 return (*this)[id - this->first];
165 }

Member Data Documentation

◆ first

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

Definition at line 168 of file JRouter.hh.


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