Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JLANG::JTemplate< JType_t > Struct Template Reference

Auxiliary class for managing multiple objects. More...

#include <JTemplate.hh>

Inheritance diagram for JLANG::JTemplate< JType_t >:
JSUPPORT::JTreeSampler< T, JSampler_t >

Public Types

typedef JTemplate< JType_t > template_type
 

Public Member Functions

 JTemplate ()
 Default constructor.
 
 JTemplate (const JType_t &value)
 Constructor.
 
 operator const JType_t & () const
 Type conversion.
 
 operator JType_t & ()
 Type conversion.
 
const JType_t * operator-> () const
 Smart pointer operator.
 
JType_t * operator-> ()
 Smart pointer operator.
 
template<class T , bool use_polymorphism = false>
const T & get () const
 Get reference to object.
 
template<class T , bool use_polymorphism = false>
T & get ()
 Get reference to object.
 
template_typeset (const JType_t &value)
 Set value.
 
template<bool use_polymorphism, class T >
template_typeset (const T &value)
 Set value.
 

Protected Member Functions

const JType_t & c_get (JBool< true > option) const
 Get reference to object.
 
JType_t & c_get (JBool< true > option)
 Get reference to object.
 
template<class T >
template_typec_set (const T &value, JBool< true > option)
 Set value.
 

Protected Attributes

JType_t object
 object
 

Friends

std::istream & operator>> (std::istream &in, JTemplate< JType_t > &object)
 Read object from input.
 
std::ostream & operator<< (std::ostream &out, const JTemplate< JType_t > &object)
 Write object to output.
 

Detailed Description

template<class JType_t>
struct JLANG::JTemplate< JType_t >

Auxiliary class for managing multiple objects.

This class can be used to replace regular base classes by corresponding data members. The various operators and methods facilitate the access to these data members.

The template value use_polymorfism in methods get and set applies to the given template parameter of these methods. If false, only exact type matches are allowed. If true, method get will return a reference to the first data member of which the type derives from the specified class and method set will assign the given value to the first data member for which a matching constructor exists.

Definition at line 40 of file JTemplate.hh.

Member Typedef Documentation

◆ template_type

template<class JType_t >
JTemplate<JType_t> JLANG::JTemplate< JType_t >::template_type

Definition at line 42 of file JTemplate.hh.

Constructor & Destructor Documentation

◆ JTemplate() [1/2]

template<class JType_t >
JLANG::JTemplate< JType_t >::JTemplate ( )
inline

Default constructor.

Definition at line 48 of file JTemplate.hh.

48 :
49 object()
50 {}
JType_t object
object
Definition JTemplate.hh:222

◆ JTemplate() [2/2]

template<class JType_t >
JLANG::JTemplate< JType_t >::JTemplate ( const JType_t & value)
inline

Constructor.

Parameters
valuevalue

Definition at line 58 of file JTemplate.hh.

58 :
59 object(value)
60 {}

Member Function Documentation

◆ operator const JType_t &()

template<class JType_t >
JLANG::JTemplate< JType_t >::operator const JType_t & ( ) const
inline

Type conversion.

Returns
reference to object

Definition at line 68 of file JTemplate.hh.

69 {
70 return object;
71 }

◆ operator JType_t &()

template<class JType_t >
JLANG::JTemplate< JType_t >::operator JType_t & ( )
inline

Type conversion.

Returns
reference to object

Definition at line 79 of file JTemplate.hh.

80 {
81 return object;
82 }

◆ operator->() [1/2]

template<class JType_t >
const JType_t * JLANG::JTemplate< JType_t >::operator-> ( ) const
inline

Smart pointer operator.

Returns
pointer to object

Definition at line 90 of file JTemplate.hh.

91 {
92 return &object;
93 }

◆ operator->() [2/2]

template<class JType_t >
JType_t * JLANG::JTemplate< JType_t >::operator-> ( )
inline

Smart pointer operator.

Returns
pointer to object

Definition at line 101 of file JTemplate.hh.

102 {
103 return &object;
104 }

◆ get() [1/2]

template<class JType_t >
template<class T , bool use_polymorphism = false>
const T & JLANG::JTemplate< JType_t >::get ( ) const
inline

Get reference to object.

Returns
reference to object

Definition at line 113 of file JTemplate.hh.

114 {
115 return this->c_get(JBool<use_polymorphism>().template c_switch<JConversion<JType_t, T>::is_derived, JConversion<JType_t, T>::is_same>());
116 }
static const bool is_same
true, if JDerived_t is equal to JBase_t
static const bool is_derived
true, if JDerived_t derives from JBase_t
const JType_t & c_get(JBool< true > option) const
Get reference to object.
Definition JTemplate.hh:188

◆ get() [2/2]

template<class JType_t >
template<class T , bool use_polymorphism = false>
T & JLANG::JTemplate< JType_t >::get ( )
inline

Get reference to object.

Returns
reference to object

Definition at line 125 of file JTemplate.hh.

126 {
127 return this->c_get(JBool<use_polymorphism>().template c_switch<JConversion<JType_t, T>::is_derived, JConversion<JType_t, T>::is_same>());
128 }

◆ set() [1/2]

template<class JType_t >
template_type & JLANG::JTemplate< JType_t >::set ( const JType_t & value)
inline

Set value.

Parameters
valuevalue
Returns
this object

Definition at line 137 of file JTemplate.hh.

138 {
139 return c_set(value, JBool<true>());
140 }
template_type & c_set(const T &value, JBool< true > option)
Set value.
Definition JTemplate.hh:214

◆ set() [2/2]

template<class JType_t >
template<bool use_polymorphism, class T >
template_type & JLANG::JTemplate< JType_t >::set ( const T & value)
inline

Set value.

Parameters
valuevalue
Returns
this object

Definition at line 150 of file JTemplate.hh.

151 {
152 return this->c_set(value, JBool<use_polymorphism>::template c_switch<JConstructor<JType_t, T>::has_constructor, JConversion<JType_t, T>::is_same>());
153 }
static const bool has_constructor
true if JType_t can be constructed from JArgument_t; else false

◆ c_get() [1/2]

template<class JType_t >
const JType_t & JLANG::JTemplate< JType_t >::c_get ( JBool< true > option) const
inlineprotected

Get reference to object.

Parameters
optiontrue
Returns
reference to object

Definition at line 188 of file JTemplate.hh.

189 {
190 return object;
191 }

◆ c_get() [2/2]

template<class JType_t >
JType_t & JLANG::JTemplate< JType_t >::c_get ( JBool< true > option)
inlineprotected

Get reference to object.

Parameters
optiontrue
Returns
reference to object

Definition at line 200 of file JTemplate.hh.

201 {
202 return object;
203 }

◆ c_set()

template<class JType_t >
template<class T >
template_type & JLANG::JTemplate< JType_t >::c_set ( const T & value,
JBool< true > option )
inlineprotected

Set value.

Parameters
valuevalue
optiontrue
Returns
this object

Definition at line 214 of file JTemplate.hh.

215 {
216 object = value;
217
218 return *this;
219 }

Friends And Related Symbol Documentation

◆ operator>>

template<class JType_t >
std::istream & operator>> ( std::istream & in,
JTemplate< JType_t > & object )
friend

Read object from input.

Parameters
ininput stream
objectobject
Returns
input stream

Definition at line 163 of file JTemplate.hh.

164 {
165 return in >> object.object;
166 }

◆ operator<<

template<class JType_t >
std::ostream & operator<< ( std::ostream & out,
const JTemplate< JType_t > & object )
friend

Write object to output.

Parameters
outoutput stream
objectobject
Returns
output stream

Definition at line 176 of file JTemplate.hh.

177 {
178 return out << object.object;
179 }

Member Data Documentation

◆ object

template<class JType_t >
JType_t JLANG::JTemplate< JType_t >::object
protected

object

Definition at line 222 of file JTemplate.hh.


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