Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JNET::JTag Class Reference

ControlHost tag. More...

#include <JTag.hh>

Inheritance diagram for JNET::JTag:
JNET::JControlHostObjectOutput< JHead_t > JNET::JControlHostObjectOutput< JTail_t > JNET::JControlHostObjectOutput< T > JNET::JPrefix JNET::JSubscription JNET::JControlHostObjectOutput< JTypeList< JHead_t, JNullType > > JNET::JControlHostObjectOutput< JTypeList< JHead_t, JTail_t > > JNET::JControlHostObjectOutput< JTypeList< JHead_t, JTail_t > > JNET::JDispatch JNET::JSubscriptionAll JNET::JSubscriptionAny

Public Member Functions

 JTag ()
 Default constructor.
 
 JTag (const JTag &tag)
 Copy constructor.
 
 JTag (const std::string &tag)
 Constructor.
 
 JTag (const JTag_t id)
 Constructor.
 
const JTaggetTag () const
 Get tag.
 
JTaggetTag ()
 Get tag.
 
void setTag (const JTag &tag)
 Set tag.
 
void setTag (const std::string &tag)
 Set tag.
 
void setTag (const JTag_t id)
 Set tag.
 
JTag_t getID () const
 Get identifier.
 
std::string toString () const
 Convert tag to string.
 
 operator std::string () const
 Type conversion operators.
 
const char * c_str () const
 C-string.
 
const char operator[] (int i) const
 Get character.
 

Protected Attributes

JTag_t id
 

Friends

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

Detailed Description

ControlHost tag.

Definition at line 38 of file JTag.hh.

Constructor & Destructor Documentation

◆ JTag() [1/4]

JNET::JTag::JTag ( )
inline

Default constructor.

Definition at line 43 of file JTag.hh.

43 :
44 id(0)
45 {}
JTag_t id
Definition JTag.hh:254

◆ JTag() [2/4]

JNET::JTag::JTag ( const JTag & tag)
inline

Copy constructor.

Parameters
tagtag

Definition at line 53 of file JTag.hh.

54 {
55 setTag(tag);
56 }
void setTag(const JTag &tag)
Set tag.
Definition JTag.hh:108

◆ JTag() [3/4]

JNET::JTag::JTag ( const std::string & tag)
inline

Constructor.

Parameters
tagtag

Definition at line 64 of file JTag.hh.

65 {
66 setTag(tag);
67 }

◆ JTag() [4/4]

JNET::JTag::JTag ( const JTag_t id)
inline

Constructor.

Parameters
ididentifier

Definition at line 75 of file JTag.hh.

76 {
77 setTag(id);
78 }

Member Function Documentation

◆ getTag() [1/2]

const JTag & JNET::JTag::getTag ( ) const
inline

Get tag.

Returns
tag

Definition at line 86 of file JTag.hh.

87 {
88 return static_cast<const JTag&>(*this);
89 }

◆ getTag() [2/2]

JTag & JNET::JTag::getTag ( )
inline

Get tag.

Returns
tag

Definition at line 97 of file JTag.hh.

98 {
99 return static_cast<JTag&>(*this);
100 }

◆ setTag() [1/3]

void JNET::JTag::setTag ( const JTag & tag)
inline

Set tag.

Parameters
tagtag

Definition at line 108 of file JTag.hh.

109 {
110 id = tag.getID();
111 }

◆ setTag() [2/3]

void JNET::JTag::setTag ( const std::string & tag)
inline

Set tag.

This method may throw an exception.

Parameters
tagtag

Definition at line 121 of file JTag.hh.

122 {
123 if (!tag.empty() && tag.size() <= TAGSIZE) {
124
125 char* __p = (char*) &(this->id);
126
127 size_t i = 0;
128
129 for ( ; i != tag.size(); ++i) {
130 __p[i] = tag[i];
131 }
132
133 for ( ; i != TAGSIZE; ++i) {
134 __p[i] = '\0';
135 }
136
137 } else {
138
139 THROW(JControlHostException, "Invalid tag length <" << tag << "> " << tag.size());
140 }
141 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
static const size_t TAGSIZE
Size of ControlHost tag.
Definition JTag.hh:32

◆ setTag() [3/3]

void JNET::JTag::setTag ( const JTag_t id)
inline

Set tag.

Parameters
ididentifier

Definition at line 149 of file JTag.hh.

150 {
151 this->id = id;
152 }

◆ getID()

JTag_t JNET::JTag::getID ( ) const
inline

Get identifier.

Returns
identifier

Definition at line 160 of file JTag.hh.

161 {
162 return id;
163 }

◆ toString()

std::string JNET::JTag::toString ( ) const
inline

Convert tag to string.

Returns
tag

Definition at line 171 of file JTag.hh.

172 {
173 int pos = TAGSIZE;
174
175 const char* __p = (const char*) &(this->id);
176
177 while (pos != 0 && __p[pos-1] == '\0') {
178 --pos;
179 }
180
181 return std::string(__p, pos);
182 }

◆ operator std::string()

JNET::JTag::operator std::string ( ) const
inline

Type conversion operators.

Returns
tag

Definition at line 190 of file JTag.hh.

191 {
192 return toString();
193 }
std::string toString() const
Convert tag to string.
Definition JTag.hh:171

◆ c_str()

const char * JNET::JTag::c_str ( ) const
inline

C-string.

Returns
tag

Definition at line 201 of file JTag.hh.

202 {
203 return (const char*) &(this->id);
204 }

◆ operator[]()

const char JNET::JTag::operator[] ( int i) const
inline

Get character.

Parameters
iindex
Returns
character at index

Definition at line 213 of file JTag.hh.

214 {
215 const char* __p = (const char*) &(this->id);
216
217 return __p[i];
218 }

Friends And Related Symbol Documentation

◆ operator>>

std::istream & operator>> ( std::istream & in,
JTag & object )
friend

Read JTag from input stream.

Parameters
ininput stream
objectJTag
Returns
input stream

Definition at line 228 of file JTag.hh.

229 {
230 std::string buffer;
231
232 if (in >> buffer) {
233 object.setTag(buffer);
234 }
235
236 return in;
237 }

◆ operator<<

std::ostream & operator<< ( std::ostream & out,
const JTag & object )
friend

Write JTag to output stream.

Parameters
outoutput stream
objectJTag
Returns
output stream

Definition at line 247 of file JTag.hh.

248 {
249 return out << object.toString();
250 }

Member Data Documentation

◆ id

JTag_t JNET::JTag::id
protected

Definition at line 254 of file JTag.hh.


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