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

List of clients. More...

#include <JClientList.hh>

Inheritance diagram for KM3NETDAQ::JClientList:
std::vector< JClient >

Classes

class  JComparator
 Auxiliary class for comparing clients. More...
 

Public Member Functions

 JClientList ()
 Default constructor.
 
std::pair< iterator, bool > insert (const JClient &client)
 Insert client.
 
iterator find (const JClient &client)
 Find client.
 
iterator find (const std::string &buffer)
 Find client by its full name.
 
void start ()
 Start processes.
 
void stop (const int signal=-9)
 Stop processes.
 
unsigned int count (const JClient::JMode mode) const
 Get number of clients with given mode.
 
unsigned int count () const
 Get number of active clients with born count exceeding died count.
 
unsigned int count (const CHSM::state &state) const
 Get number of active clients in given state.
 

Protected Attributes

const JComparator comparator
 

Detailed Description

List of clients.

Definition at line 22 of file JClientList.hh.

Constructor & Destructor Documentation

◆ JClientList()

KM3NETDAQ::JClientList::JClientList ( )
inline

Default constructor.

Definition at line 66 of file JClientList.hh.

66 :
69 {}
const JComparator comparator

Member Function Documentation

◆ insert()

std::pair< iterator, bool > KM3NETDAQ::JClientList::insert ( const JClient & client)
inline

Insert client.

Parameters
clientclient
Returns
iterator to client and true if inserted; else false

Definition at line 78 of file JClientList.hh.

79 {
80 iterator i = std::lower_bound(this->begin(), this->end(), client, comparator);
81
82 if (i == this->end() || comparator(client, *i)) {
83
84 i = std::vector<JClient>::insert(i, client);
85
86 return std::make_pair(i, true);
87
88 } else {
89
90 return std::make_pair(i, false);
91 }
92 }

◆ find() [1/2]

iterator KM3NETDAQ::JClientList::find ( const JClient & client)
inline

Find client.

Parameters
clientclient
Returns
iterator to client

Definition at line 101 of file JClientList.hh.

102 {
103 iterator i = std::lower_bound(this->begin(), this->end(), client, comparator);
104
105 if (i != this->end() && !comparator(*i, client))
106 return i;
107 else
108 return this->end();
109 }

◆ find() [2/2]

iterator KM3NETDAQ::JClientList::find ( const std::string & buffer)
inline

Find client by its full name.

Parameters
bufferfull name of client (possibly followed by more text)
Returns
position of client (or end)

Definition at line 118 of file JClientList.hh.

119 {
120 const std::string full_name = getFullName(buffer);
121
122 iterator i = std::lower_bound(this->begin(), this->end(), full_name, comparator);
123
124 if (i != this->end() && !comparator(*i, full_name))
125 return i;
126 else
127 return this->end();
128 }
std::string getFullName(const std::string &hostname, const std::string &name)
Get full name of run control client.

◆ start()

void KM3NETDAQ::JClientList::start ( )
inline

Start processes.

Definition at line 134 of file JClientList.hh.

135 {
136 for (iterator i = this->begin(); i != this->end(); ++i) {
137 if (i->getMode() == JClient::ACTIVE) {
138 i->start();
139 }
140 }
141 }

◆ stop()

void KM3NETDAQ::JClientList::stop ( const int signal = -9)
inline

Stop processes.

Parameters
signalsignal

Definition at line 149 of file JClientList.hh.

150 {
151 for (iterator i = this->begin(); i != this->end(); ++i) {
152 if (i->getBorn() > i->getDied()) {
153 i->stop(signal);
154 }
155 }
156 }

◆ count() [1/3]

unsigned int KM3NETDAQ::JClientList::count ( const JClient::JMode mode) const
inline

Get number of clients with given mode.

Parameters
modemode
Returns
number of clients

Definition at line 165 of file JClientList.hh.

166 {
167 unsigned int n = 0;
168
169 for (const_iterator i = this->begin(); i != this->end(); ++i) {
170 if (i->getMode() == mode) {
171 ++n;
172 }
173 }
174
175 return n;
176 }
const int n
Definition JPolint.hh:791

◆ count() [2/3]

unsigned int KM3NETDAQ::JClientList::count ( ) const
inline

Get number of active clients with born count exceeding died count.

Returns
number of clients

Definition at line 184 of file JClientList.hh.

185 {
186 unsigned int n = 0;
187
188 for (const_iterator i = this->begin(); i != this->end(); ++i) {
189 if (i->getMode() == JClient::ACTIVE && i->getBorn() > i->getDied()) {
190 ++n;
191 }
192 }
193
194 return n;
195 }

◆ count() [3/3]

unsigned int KM3NETDAQ::JClientList::count ( const CHSM::state & state) const
inline

Get number of active clients in given state.

Parameters
statestate
Returns
number of clients

Definition at line 204 of file JClientList.hh.

205 {
206 unsigned int n = 0;
207
208 for (const_iterator i = this->begin(); i != this->end(); ++i) {
209 if (i->getMode() == JClient::ACTIVE && i->getStatename() == getStateName(state.name())) {
210 ++n;
211 }
212 }
213
214 return n;
215 }
std::string getStateName(const std::string &name)
Get name of state.

Member Data Documentation

◆ comparator

const JComparator KM3NETDAQ::JClientList::comparator
protected

Definition at line 59 of file JClientList.hh.


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