Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
JEEP::JPropertiesElement Class Reference

The property value class. More...

#include <JProperties.hh>

Inheritance diagram for JEEP::JPropertiesElement:
JLANG::JSharedPointer< JClass_t, JMemory_t > JLANG::JSharedCounter JLANG::JStorage< JClass_t, JMemory_t > JLANG::JPointer< JClass_t > JLANG::JAbstractPointer< JClass_t > JLANG::JEquals< JAbstractPointer< JClass_t > >

Public Types

typedef JPointer< JClass_t > pointer_type
 
typedef JStorage< JClass_t,
JMemory_t > 
storage_type
 
typedef JMemory_t< JClass_t > memory_type
 

Public Member Functions

 JPropertiesElement ()
 Default constructor. More...
 
template<class T >
 JPropertiesElement (T &value)
 Constructor. More...
 
bool equals (const JPropertiesElement &element) const
 Equality between property elements. More...
 
template<class T >
JPropertiesElementoperator= (T &value)
 Assignment operator. More...
 
template<class T >
const T & getValue () const
 Get value. More...
 
template<class T >
T & getValue ()
 Get value. More...
 
template<class T >
void setValue (const T &value)
 Set value of this JPropertiesElement. More...
 
std::string toString () const
 Convert to string. More...
 
template<class T >
toValue () const
 Convert to template type. More...
 
template<class T >
 operator const T & () const
 Type conversion operator. More...
 
bool getEndMarker () const
 Get end marker. More...
 
void setEndMarker (const bool marker)
 Set end marker. More...
 
const JSharedPointergetSharedPointer () const
 Get shared pointer. More...
 
JSharedPointergetSharedPointer ()
 Get shared pointer. More...
 
void setSharedPointer (const JSharedPointer &object)
 Set shared pointer. More...
 
virtual void reset ()
 Reset pointer. More...
 
template<class T >
void reset (const JPointer< T > &pointer)
 Reset pointer. More...
 
void reset (JClass_t *p)
 Reset pointer. More...
 
template<class T >
void set (const JPointer< T > &pointer)
 Set pointer. More...
 
void initialise ()
 Initialise counter. More...
 
void attach (const JSharedCounter &object)
 Attach this counter to given shared counter object. More...
 
bool detach ()
 Detach. More...
 
void recreate ()
 Recreate object in memory. More...
 
void create ()
 Create object in memory. More...
 
void create (const unsigned int size)
 Create array of objects in memory. More...
 
virtual JClass_t * get () const
 Get pointer. More...
 
JClass_t *const & getReference () const
 Get rereference to internal pointer. More...
 
JClass_t *& getReference ()
 Get rereference to internal pointer. More...
 
virtual bool equals (const JAbstractPointer &object) const
 Equals. More...
 
bool is_valid () const
 Check validity of pointer. More...
 
JClass_t * operator-> () const
 Smart pointer operator. More...
 
 operator JClass_t * () const
 Type conversion operator. More...
 

Protected Member Functions

void set (const JSharedPointer &object)
 Set pointer. More...
 
virtual void set (JClass_t *p)
 Set pointer. More...
 
void release ()
 Release memory. More...
 

Protected Attributes

int * counter
 
JClass_t * __p
 pointer to object More...
 

Private Attributes

bool end_marker
 

Detailed Description

The property value class.

This class consists of a pointer to the JPropertiesElementInterface. This class implements the assignment and type conversion operators.

Definition at line 281 of file JProperties.hh.

Member Typedef Documentation

template<class JClass_t, template< class > class JMemory_t = JNew>
typedef JPointer<JClass_t> JLANG::JSharedPointer< JClass_t, JMemory_t >::pointer_type
inherited

Definition at line 34 of file JSharedPointer.hh.

template<class JClass_t, template< class > class JMemory_t = JNew>
typedef JStorage<JClass_t, JMemory_t> JLANG::JSharedPointer< JClass_t, JMemory_t >::storage_type
inherited

Definition at line 35 of file JSharedPointer.hh.

template<class JClass_t, template< class > class JMemory_t = JNew>
typedef JMemory_t<JClass_t> JLANG::JStorage< JClass_t, JMemory_t >::memory_type
inherited

Definition at line 33 of file JStorage.hh.

Constructor & Destructor Documentation

JEEP::JPropertiesElement::JPropertiesElement ( )
inline

Default constructor.

Definition at line 288 of file JProperties.hh.

288  :
289  end_marker(false)
290  {}
template<class T >
JEEP::JPropertiesElement::JPropertiesElement ( T &  value)
inline

Constructor.

Parameters
valuereference to template object

Definition at line 299 of file JProperties.hh.

299  :
300  end_marker(false)
301  {
303  }
Template class for I/O of properties element.
Definition: JProperties.hh:110
virtual void reset()
Reset pointer.

Member Function Documentation

bool JEEP::JPropertiesElement::equals ( const JPropertiesElement element) const
inline

Equality between property elements.

Parameters
elementproperties element
Returns
true if equal; else false

Definition at line 312 of file JProperties.hh.

313  {
314  return get()->equals(*element.get());
315  }
bool equals(const JPropertiesElement &element) const
Equality between property elements.
Definition: JProperties.hh:312
virtual JClass_t * get() const
Get pointer.
Definition: JPointer.hh:64
template<class T >
JPropertiesElement& JEEP::JPropertiesElement::operator= ( T &  value)
inline

Assignment operator.

Parameters
valuereference to template object
Returns
this JPropertiesElement

Definition at line 325 of file JProperties.hh.

326  {
328 
329  return *this;
330  }
Template class for I/O of properties element.
Definition: JProperties.hh:110
virtual void reset()
Reset pointer.
template<class T >
const T& JEEP::JPropertiesElement::getValue ( ) const
inline

Get value.

Returns
value of this JPropertiesElement

Definition at line 339 of file JProperties.hh.

340  {
341  const JPropertiesTemplateElement<T>* p = dynamic_cast<const JPropertiesTemplateElement<T>*>(this->get());
342 
343  if (p != NULL)
344  return p->object;
345  else
346  THROW(JPropertiesException, "Inconsistent data type.");
347  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:633
Template class for I/O of properties element.
Definition: JProperties.hh:110
template<class T >
T& JEEP::JPropertiesElement::getValue ( )
inline

Get value.

Returns
value of this JPropertiesElement

Definition at line 356 of file JProperties.hh.

357  {
358  JPropertiesTemplateElement<T>* p = dynamic_cast<JPropertiesTemplateElement<T>*>(this->get());
359 
360  if (p != NULL)
361  return p->object;
362  else
363  THROW(JPropertiesException, "Inconsistent data type.");
364  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:633
Template class for I/O of properties element.
Definition: JProperties.hh:110
template<class T >
void JEEP::JPropertiesElement::setValue ( const T &  value)
inline

Set value of this JPropertiesElement.

Parameters
valuevalue

Definition at line 374 of file JProperties.hh.

375  {
376  JPropertiesTemplateElement<T>* p = dynamic_cast<JPropertiesTemplateElement<T>*>(this->get());
377 
378  if (p != NULL)
379  p->object = value;
380  else
381  THROW(JPropertiesException, "Inconsistent data type.");
382  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:633
Template class for I/O of properties element.
Definition: JProperties.hh:110
std::string JEEP::JPropertiesElement::toString ( ) const
inline

Convert to string.

Returns
value of this JPropertiesElement

Definition at line 390 of file JProperties.hh.

391  {
392  std::ostringstream os;
393 
394  get()->write(os, "", '\0');
395 
396  return os.str();
397  }
template<class T >
T JEEP::JPropertiesElement::toValue ( ) const
inline

Convert to template type.

Returns
value of this JPropertiesElement

Definition at line 406 of file JProperties.hh.

407  {
408  T value;
409 
410  std::istringstream in(this->toString());
411 
412  in >> value;
413 
414  return value;
415  }
std::string toString() const
Convert to string.
Definition: JProperties.hh:390
template<class T >
JEEP::JPropertiesElement::operator const T & ( ) const
inline

Type conversion operator.

Returns
value of this JPropertiesElement

Definition at line 424 of file JProperties.hh.

425  {
426  return getValue<T>();
427  }
bool JEEP::JPropertiesElement::getEndMarker ( ) const
inline

Get end marker.

Returns
end marker

Definition at line 435 of file JProperties.hh.

436  {
437  return end_marker;
438  }
void JEEP::JPropertiesElement::setEndMarker ( const bool  marker)
inline

Set end marker.

Parameters
markerif true stop reading after this properties element, else continue

Definition at line 446 of file JProperties.hh.

447  {
448  end_marker = marker;
449  }
template<class JClass_t, template< class > class JMemory_t = JNew>
const JSharedPointer& JLANG::JSharedPointer< JClass_t, JMemory_t >::getSharedPointer ( ) const
inlineinherited

Get shared pointer.

Returns
this shared pointer

Definition at line 95 of file JSharedPointer.hh.

96  {
97  return static_cast<const JSharedPointer&>(*this);
98  }
The template JSharedPointer class can be used to share a pointer to an object.
template<class JClass_t, template< class > class JMemory_t = JNew>
JSharedPointer& JLANG::JSharedPointer< JClass_t, JMemory_t >::getSharedPointer ( )
inlineinherited

Get shared pointer.

Returns
this shared pointer

Definition at line 106 of file JSharedPointer.hh.

107  {
108  return static_cast<JSharedPointer&>(*this);
109  }
The template JSharedPointer class can be used to share a pointer to an object.
template<class JClass_t, template< class > class JMemory_t = JNew>
void JLANG::JSharedPointer< JClass_t, JMemory_t >::setSharedPointer ( const JSharedPointer< JClass_t, JMemory_t > &  object)
inlineinherited

Set shared pointer.

Parameters
objectshared pointer

Definition at line 117 of file JSharedPointer.hh.

118  {
119  if (this->get() != object.get()) {
120 
121  this->reset();
122 
123  if (object.is_valid()) {
124  this->set(object);
125  }
126  }
127  }
void set(const JSharedPointer &object)
Set pointer.
bool is_valid() const
Check validity of pointer.
virtual void reset()
Reset pointer.
template<class JClass_t, template< class > class JMemory_t = JNew>
virtual void JLANG::JSharedPointer< JClass_t, JMemory_t >::reset ( )
inlinevirtualinherited

Reset pointer.

The reference counter is decremented by one and the object pointed to previously is deleted when its reference counter is zero.

Reimplemented from JLANG::JStorage< JClass_t, JMemory_t >.

Definition at line 171 of file JSharedPointer.hh.

172  {
173  if (this->detach()) {
175  }
176 
178  }
virtual void reset()
Reset pointer.
Definition: JStorage.hh:42
virtual void reset()
Reset pointer.
Definition: JPointer.hh:84
bool detach()
Detach.
template<class JClass_t>
template<class T >
void JLANG::JPointer< JClass_t >::reset ( const JPointer< T > &  pointer)
inlineinherited

Reset pointer.

Parameters
pointerpointer to object

Definition at line 108 of file JPointer.hh.

109  {
110  this->reset(pointer.get());
111  }
virtual void reset()
Reset pointer.
Definition: JPointer.hh:84
virtual JClass_t * get() const
Get pointer.
Definition: JPointer.hh:64
template<class JClass_t>
void JLANG::JAbstractPointer< JClass_t >::reset ( JClass_t *  p)
inlineinherited

Reset pointer.

Parameters
ppointer to object

Definition at line 92 of file JAbstractPointer.hh.

93  {
94  if (this->get() != p) {
95 
96  this->reset();
97 
98  if (p != NULL) {
99  this->set(p);
100  }
101  }
102  }
virtual void reset()=0
Reset pointer.
virtual void set(JClass_t *p)=0
Set pointer.
template<class JClass_t, template< class > class JMemory_t = JNew>
void JLANG::JSharedPointer< JClass_t, JMemory_t >::set ( const JSharedPointer< JClass_t, JMemory_t > &  object)
inlineprotectedinherited

Set pointer.

The reference counter of the shared object pointed to is incremented by one.

Parameters
objectshared pointer

Definition at line 188 of file JSharedPointer.hh.

189  {
190  pointer_type::set(object.get());
191 
192  this->attach(object);
193  }
void attach(const JSharedCounter &object)
Attach this counter to given shared counter object.
virtual void set(JClass_t *p)
Set pointer.
Definition: JPointer.hh:75
template<class JClass_t, template< class > class JMemory_t = JNew>
virtual void JLANG::JSharedPointer< JClass_t, JMemory_t >::set ( JClass_t *  p)
inlineprotectedvirtualinherited

Set pointer.

The reference counter of the shared object pointed to is initialised to one.

Parameters
ppointer to derived class object

Reimplemented from JLANG::JPointer< JClass_t >.

Definition at line 202 of file JSharedPointer.hh.

203  {
205 
206  this->initialise();
207  }
void initialise()
Initialise counter.
virtual void set(JClass_t *p)
Set pointer.
Definition: JPointer.hh:75
template<class JClass_t>
template<class T >
void JLANG::JPointer< JClass_t >::set ( const JPointer< T > &  pointer)
inlineinherited

Set pointer.

Parameters
pointerpointer to object

Definition at line 96 of file JPointer.hh.

97  {
98  this->set(pointer.get());
99  }
virtual JClass_t * get() const
Get pointer.
Definition: JPointer.hh:64
virtual void set(JClass_t *p)
Set pointer.
Definition: JPointer.hh:75
void JLANG::JSharedCounter::initialise ( )
inlineinherited

Initialise counter.

Definition at line 32 of file JSharedCounter.hh.

33  {
34  detach();
35 
36  counter = new int(1);
37  }
bool detach()
Detach.
void JLANG::JSharedCounter::attach ( const JSharedCounter object)
inlineinherited

Attach this counter to given shared counter object.

Parameters
objectshared counter

Definition at line 45 of file JSharedCounter.hh.

46  {
47  detach();
48 
49  counter = object.counter;
50 
51  if (counter != NULL) {
52  ++(*counter);
53  }
54  }
bool detach()
Detach.
bool JLANG::JSharedCounter::detach ( )
inlineinherited

Detach.

Returns
true if counter at zero; else false

Definition at line 62 of file JSharedCounter.hh.

63  {
64  if (counter != NULL) {
65 
66  if (--(*counter) == 0) {
67 
68  delete counter;
69 
70  counter = NULL;
71 
72  return true;
73  }
74 
75  counter = NULL;
76  }
77 
78  return false;
79  }
template<class JClass_t, template< class > class JMemory_t = JNew>
void JLANG::JStorage< JClass_t, JMemory_t >::recreate ( )
inlineinherited

Recreate object in memory.

A new object is created if no memory is allocated yet, else the previously created object is maintained.

Definition at line 57 of file JStorage.hh.

58  {
59  if (!this->is_valid()) {
60  this->set(memory_type::create());
61  }
62  }
bool is_valid() const
Check validity of pointer.
virtual void set(JClass_t *p)
Set pointer.
Definition: JPointer.hh:75
template<class JClass_t, template< class > class JMemory_t = JNew>
void JLANG::JStorage< JClass_t, JMemory_t >::create ( )
inlineinherited

Create object in memory.

The memory allocated by a previously created object will be released.

Definition at line 69 of file JStorage.hh.

70  {
71  this->reset(memory_type::create());
72  }
virtual void reset()
Reset pointer.
Definition: JStorage.hh:42
template<class JClass_t, template< class > class JMemory_t = JNew>
void JLANG::JStorage< JClass_t, JMemory_t >::create ( const unsigned int  size)
inlineinherited

Create array of objects in memory.

The memory allocated by previously created objects will be released.

Parameters
sizenumber of elements

Definition at line 81 of file JStorage.hh.

82  {
83  this->reset(memory_type::create(size));
84  }
virtual void reset()
Reset pointer.
Definition: JStorage.hh:42
template<class JClass_t, template< class > class JMemory_t = JNew>
void JLANG::JStorage< JClass_t, JMemory_t >::release ( )
inlineprotectedinherited

Release memory.

Definition at line 91 of file JStorage.hh.

92  {
93  memory_type::release(this->get());
94  }
template<class JClass_t>
virtual JClass_t* JLANG::JPointer< JClass_t >::get ( ) const
inlinevirtualinherited
template<class JClass_t>
JClass_t* const& JLANG::JPointer< JClass_t >::getReference ( ) const
inlineinherited

Get rereference to internal pointer.

Returns
reference to internal pointer

Definition at line 119 of file JPointer.hh.

120  {
121  return __p;
122  }
JClass_t * __p
pointer to object
Definition: JPointer.hh:136
template<class JClass_t>
JClass_t* & JLANG::JPointer< JClass_t >::getReference ( )
inlineinherited

Get rereference to internal pointer.

Returns
reference to internal pointer

Definition at line 130 of file JPointer.hh.

131  {
132  return __p;
133  }
JClass_t * __p
pointer to object
Definition: JPointer.hh:136
template<class JClass_t>
virtual bool JLANG::JAbstractPointer< JClass_t >::equals ( const JAbstractPointer< JClass_t > &  object) const
inlinevirtualinherited

Equals.

The equality is evaluated by comparison of the internal pointers.

Parameters
objectabstract pointer
Returns
true if equals; else false

Definition at line 48 of file JAbstractPointer.hh.

49  {
50  return this->get() == object.get();
51  }
template<class JClass_t>
bool JLANG::JAbstractPointer< JClass_t >::is_valid ( ) const
inlineinherited

Check validity of pointer.

Returns
true if pointer not null; else false

Definition at line 81 of file JAbstractPointer.hh.

82  {
83  return this->get() != NULL;
84  }
template<class JClass_t>
JClass_t* JLANG::JAbstractPointer< JClass_t >::operator-> ( ) const
inlineinherited

Smart pointer operator.

Returns
pointer to object

Definition at line 110 of file JAbstractPointer.hh.

111  {
112  if (!is_valid())
113  throw JNullPointerException("JAbstractPointer::operator->()");
114  else
115  return this->get();
116  }
bool is_valid() const
Check validity of pointer.
Exception for null pointer operation.
Definition: JException.hh:198
template<class JClass_t>
JLANG::JAbstractPointer< JClass_t >::operator JClass_t * ( ) const
inlineinherited

Type conversion operator.

Returns
pointer to object

Definition at line 124 of file JAbstractPointer.hh.

125  {
126  return this->get();
127  }

Member Data Documentation

bool JEEP::JPropertiesElement::end_marker
private

Definition at line 453 of file JProperties.hh.

int* JLANG::JSharedCounter::counter
protectedinherited

Definition at line 82 of file JSharedCounter.hh.

template<class JClass_t>
JClass_t* JLANG::JPointer< JClass_t >::__p
protectedinherited

pointer to object

Definition at line 136 of file JPointer.hh.


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