Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Attributes | Friends | List of all members
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. More...
 
 JTag (const JTag &tag)
 Copy constructor. More...
 
 JTag (const std::string &tag)
 Constructor. More...
 
 JTag (const JTag_t id)
 Constructor. More...
 
const JTaggetTag () const
 Get tag. More...
 
JTaggetTag ()
 Get tag. More...
 
void setTag (const JTag &tag)
 Set tag. More...
 
void setTag (const std::string &tag)
 Set tag. More...
 
JTag_t getID () const
 Get identifier. More...
 
bool setID (const JTag_t id)
 Set identifier. More...
 
std::string toString () const
 Convert tag to string. More...
 
 operator std::string () const
 Type conversion operators. More...
 
const char * c_str () const
 C-string. More...
 
const char operator[] (int i) const
 Get character. More...
 

Protected Attributes

union {
   char   tag [TAGSIZE]
 
   JTag_t   id
 
}; 
 

Friends

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

Detailed Description

ControlHost tag.

Definition at line 35 of file JTag.hh.

Constructor & Destructor Documentation

JNET::JTag::JTag ( )
inline

Default constructor.

Definition at line 40 of file JTag.hh.

41  {}
JNET::JTag::JTag ( const JTag tag)
inline

Copy constructor.

Parameters
tagtag

Definition at line 49 of file JTag.hh.

50  {
51  id = tag.getID();
52  }
JTag_t getID() const
Get identifier.
Definition: JTag.hh:143
JNET::JTag::JTag ( const std::string &  tag)
inline

Constructor.

Parameters
tagtag

Definition at line 60 of file JTag.hh.

61  {
62  setTag(tag);
63  }
char tag[TAGSIZE]
Definition: JTag.hh:247
void setTag(const JTag &tag)
Set tag.
Definition: JTag.hh:105
JNET::JTag::JTag ( const JTag_t  id)
inline

Constructor.

Parameters
ididentifier

Definition at line 71 of file JTag.hh.

72  {
73  setID(id);
74  }
bool setID(const JTag_t id)
Set identifier.
Definition: JTag.hh:154

Member Function Documentation

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

Get tag.

Returns
tag

Definition at line 82 of file JTag.hh.

83  {
84  return static_cast<const JTag&>(*this);
85  }
ControlHost tag.
Definition: JTag.hh:35
JTag& JNET::JTag::getTag ( )
inline

Get tag.

Returns
tag

Definition at line 93 of file JTag.hh.

94  {
95  return static_cast<JTag&>(*this);
96  }
ControlHost tag.
Definition: JTag.hh:35
void JNET::JTag::setTag ( const JTag tag)
inline

Set tag.

Parameters
tagtag
Returns
true if OK; else false

Definition at line 105 of file JTag.hh.

106  {
107  id = tag.getID();
108  }
JTag_t getID() const
Get identifier.
Definition: JTag.hh:143
void JNET::JTag::setTag ( const std::string &  tag)
inline

Set tag.

Parameters
tagtag
Returns
true if OK; else false

Definition at line 117 of file JTag.hh.

118  {
119  if (!tag.empty() && tag.size() <= TAGSIZE) {
120 
121  size_t i = 0;
122 
123  for ( ; i < tag.size(); ++i) {
124  this->tag[i] = tag[i];
125  }
126 
127  for ( ; i < TAGSIZE; ++i) {
128  this->tag[i] = '\0';
129  }
130 
131  } else {
132 
133  return throw(JControlHostException("JTag::setTag() invalid tag length."));
134  }
135  }
char tag[TAGSIZE]
Definition: JTag.hh:247
static const size_t TAGSIZE
Definition: JTag.hh:29
JTag_t JNET::JTag::getID ( ) const
inline

Get identifier.

Returns
identifier

Definition at line 143 of file JTag.hh.

144  {
145  return id;
146  }
JTag_t id
Definition: JTag.hh:248
bool JNET::JTag::setID ( const JTag_t  id)
inline

Set identifier.

Returns
identifier

Definition at line 154 of file JTag.hh.

155  {
156  this->id = id;
157 
158  return true;
159  }
JTag_t id
Definition: JTag.hh:248
std::string JNET::JTag::toString ( ) const
inline

Convert tag to string.

Returns
tag

Definition at line 167 of file JTag.hh.

168  {
169  int pos = TAGSIZE;
170 
171  while (pos != 0 && tag[pos-1] == '\0') {
172  --pos;
173  }
174 
175  return std::string(tag, pos);
176  }
char tag[TAGSIZE]
Definition: JTag.hh:247
static const size_t TAGSIZE
Definition: JTag.hh:29
JNET::JTag::operator std::string ( ) const
inline

Type conversion operators.

Returns
tag

Definition at line 184 of file JTag.hh.

185  {
186  return toString();
187  }
std::string toString() const
Convert tag to string.
Definition: JTag.hh:167
const char* JNET::JTag::c_str ( ) const
inline

C-string.

Returns
tag

Definition at line 195 of file JTag.hh.

196  {
197  return tag;
198  }
char tag[TAGSIZE]
Definition: JTag.hh:247
const char JNET::JTag::operator[] ( int  i) const
inline

Get character.

Parameters
iindex
Returns
character at index

Definition at line 207 of file JTag.hh.

208  {
209  return tag[i];
210  }
char tag[TAGSIZE]
Definition: JTag.hh:247

Friends And Related Function Documentation

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

Read JTag from input stream.

Parameters
ininput stream
objectJTag
Returns
input stream

Definition at line 220 of file JTag.hh.

221  {
222  std::string buffer;
223 
224  if (in >> buffer) {
225  object.setTag(buffer);
226  }
227 
228  return in;
229  }
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 239 of file JTag.hh.

240  {
241  return out << object.toString();
242  }

Member Data Documentation

char JNET::JTag::tag[TAGSIZE]

Definition at line 247 of file JTag.hh.

JTag_t JNET::JTag::id

Definition at line 248 of file JTag.hh.

union { ... }

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