Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
KM3NETDAQ::JDAQProcess Class Reference

Auxiliary class for itemization of process list. More...

#include <JRuncontrolToolkit.hh>

Inheritance diagram for KM3NETDAQ::JDAQProcess:
JNET::JHostname JLANG::JEquals< JHostname >

Public Member Functions

 JDAQProcess ()
 Default constructor.
 
 JDAQProcess (const JHostname &hostname, const std::string &key="")
 Constructor.
 
JTag getUniqueTag () const
 Get unique tag.
 
bool equals (const JTag &tag) const
 Test whether given tag equals.
 
bool equals (int port) const
 Test whether given port equals.
 
bool equals (const JHostname &hostname) const
 Test whether given host name equals.
 
void set (const std::string &buffer)
 Set hostname and port number.
 

Public Attributes

std::string index
 index in process list
 
std::string hostname
 
int port
 

Static Public Attributes

static const char SEPARATOR = ':'
 Separation character between hostname and port number.
 

Friends

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

Detailed Description

Auxiliary class for itemization of process list.

Definition at line 341 of file JRuncontrolToolkit.hh.

Constructor & Destructor Documentation

◆ JDAQProcess() [1/2]

KM3NETDAQ::JDAQProcess::JDAQProcess ( )
inline

Default constructor.

Definition at line 348 of file JRuncontrolToolkit.hh.

348 :
349 JHostname(),
350 index ()
351 {}
std::string index
index in process list
JHostname()
Default constructor.
Definition JHostname.hh:45

◆ JDAQProcess() [2/2]

KM3NETDAQ::JDAQProcess::JDAQProcess ( const JHostname & hostname,
const std::string & key = "" )
inline

Constructor.

Parameters
hostnamehost name
keyindex

Definition at line 360 of file JRuncontrolToolkit.hh.

361 :
362 JHostname(),
363 index (key)
364 {}

Member Function Documentation

◆ getUniqueTag()

JTag KM3NETDAQ::JDAQProcess::getUniqueTag ( ) const
inline

Get unique tag.

Returns
tag

Definition at line 372 of file JRuncontrolToolkit.hh.

373 {
374 using namespace std;
375 using namespace JSYSTEM;
376
377 ostringstream os;
378
379 os << hex << getSubaddress(getIPnumber(this->hostname)) << this->index;
380
381 return JTag(os.str());
382 }
Auxiliary classes and methods for operating system calls.
int getIPnumber()
Get IP number.
Definition JNetwork.hh:142
unsigned short getSubaddress()
Get host identifier within network.
Definition JNetwork.hh:205
std::string hostname
Definition JHostname.hh:171

◆ equals() [1/3]

bool KM3NETDAQ::JDAQProcess::equals ( const JTag & tag) const
inline

Test whether given tag equals.

The comparison is based on the unique tag.

Parameters
tagtag
Returns
true if match; else false

Definition at line 392 of file JRuncontrolToolkit.hh.

393 {
394 return this->getUniqueTag() == tag;
395 }
JTag getUniqueTag() const
Get unique tag.

◆ equals() [2/3]

bool KM3NETDAQ::JDAQProcess::equals ( int port) const
inline

Test whether given port equals.

The comparison is based on the IP number and port number.

Parameters
portport
Returns
true if match; else false

Definition at line 405 of file JRuncontrolToolkit.hh.

406 {
407 return (JSYSTEM::getIPnumber() == JSYSTEM::getIPnumber(this->hostname) && port == this->port);
408 }

◆ equals() [3/3]

bool KM3NETDAQ::JDAQProcess::equals ( const JHostname & hostname) const
inline

Test whether given host name equals.

The comparison is based on the IP number and port number.

Parameters
hostnamehost name
Returns
true if match; else false

Definition at line 418 of file JRuncontrolToolkit.hh.

419 {
420 return (JSYSTEM::getIPnumber(hostname.hostname) == JSYSTEM::getIPnumber(this->hostname) && hostname.port == this->port);
421 }

◆ set()

void JNET::JHostname::set ( const std::string & buffer)
inlineinherited

Set hostname and port number.

The argument correponds to the hostname and an optional port number of the server.
The syntax is hostname[:port]. The default port number is DISPATCH_PORT.
If the complete buffer corresponds to an integer value, it is interpreted as the port number.

Parameters
bufferhost name and optional port number

Definition at line 104 of file JHostname.hh.

105 {
106 using namespace std;
107
108 const string::size_type pos = buffer.find(SEPARATOR);
109
110 if (pos != string::npos) {
111
112 this->hostname = buffer.substr(0, pos);
113
114 istringstream(buffer.substr(pos + 1)) >> this->port;
115
116 } else {
117
118 bool is_number = true;
119
120 for (string::const_iterator i = buffer.begin(); is_number && i != buffer.end(); ++i) {
121 is_number &= isdigit(*i);
122 }
123
124 if (is_number) {
125
126 this->hostname = "";
127
128 istringstream(buffer) >> this->port;
129
130 } else {
131
132 this->hostname = buffer;
133 this->port = DISPATCH_PORT;
134 }
135 }
136 }
static const int DISPATCH_PORT
Default ControlHost port.
Definition JHostname.hh:27
static const char SEPARATOR
Separation character between hostname and port number.
Definition JHostname.hh:39

Friends And Related Symbol Documentation

◆ operator>>

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

Read process from input stream.

Parameters
ininput stream
objectprocess
Returns
input stream

Definition at line 431 of file JRuncontrolToolkit.hh.

432 {
433 in >> object.index;
434 in >> static_cast<JHostname&>(object);
435
436 return in;
437 }

◆ operator<<

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

Write process to output stream.

Parameters
outoutput stream
objectprocess
Returns
output stream

Definition at line 447 of file JRuncontrolToolkit.hh.

448 {
449 out << object.index;
450 out << ' ';
451 out << static_cast<const JHostname&>(object);
452
453 return out;
454 }

Member Data Documentation

◆ index

std::string KM3NETDAQ::JDAQProcess::index

index in process list

Definition at line 457 of file JRuncontrolToolkit.hh.

◆ SEPARATOR

const char JNET::JHostname::SEPARATOR = ':'
staticinherited

Separation character between hostname and port number.

Definition at line 39 of file JHostname.hh.

◆ hostname

std::string JNET::JHostname::hostname
inherited

Definition at line 171 of file JHostname.hh.

◆ port

int JNET::JHostname::port
inherited

Definition at line 172 of file JHostname.hh.


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