Jpp  17.3.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
JNET::JLigierObjectIterator< T > Class Template Reference

Object iteration through ControlHost server. More...

#include <JLigierObjectIterator.hh>

Inheritance diagram for JNET::JLigierObjectIterator< T >:
JNET::JServerSocket JLANG::JAbstractObjectIterator< T > std::vector< JSocketInputChannel_t > JNET::JTCPSocket JLANG::JObjectIterator< T > JNET::JSocket JLANG::JFile JNET::JSocketAddress JLANG::JAbstractFile JLANG::JBinaryInput JLANG::JBinaryOutput JLANG::JComparable< JAbstractFile >

Public Types

typedef JObjectIterator< T >
::pointer_type 
pointer_type
 

Public Member Functions

 JLigierObjectIterator (const int port, const int backlog, const int buffer_size=262144, const int timeout_us=10)
 Constructor. More...
 
virtual bool setObject (T &object) override
 Set object. More...
 
void setNonBlocking (const bool on)
 Set non-blocking of I/O. More...
 
bool getNonBlocking () const
 Get non-blocking of I/O. More...
 
void setKeepIdle (const int t_s)
 Set the TCP idle time. More...
 
void setKeepCnt (const int count)
 Set the TCP idle count. More...
 
void setKeepIntvl (const int t_s)
 Set the TCP interval time. More...
 
void setTcpNoDelay (const bool on)
 Set TCP no-delay. More...
 
bool getTcpNoDelay () const
 Get TCP no-delay. More...
 
void accept (const int server)
 Accept connection from a server. More...
 
void connect (const int port)
 Connect to port on local host. More...
 
void connect (const JHostname &hostname)
 Connect to port on specified host. More...
 
void connect (const std::string &hostname, const int port)
 Connect to port on specified host. More...
 
void connect (const int ip_number, const int port)
 Connect to port on specified host. More...
 
int shutdown ()
 Shut down socket. More...
 
void setKeepAlive (const bool on)
 Set keep alive of socket. More...
 
bool getKeepAlive () const
 Get keep alive of socket. More...
 
void setReuseAddress (const bool on)
 Set reuse address. More...
 
bool getReuseAddress () const
 Get reuse address. More...
 
void setReceiveBufferSize (const int size)
 Set receive buffer size. More...
 
int getReceiveBufferSize () const
 Set receive buffer size. More...
 
void setSendBufferSize (const int size)
 Set send buffer size. More...
 
int getSendBufferSize () const
 Get send buffer size. More...
 
virtual int read (char *buffer, const int length) override
 Read data from socket. More...
 
virtual int write (const char *buffer, const int length) override
 Write data to socket. More...
 
void close ()
 Close file. More...
 
bool in_avail (JTimeval timeout=JTimeval::min()) const
 Check availability of input. More...
 
bool out_avail (JTimeval timeout=JTimeval::min()) const
 Check availability of output. More...
 
virtual bool good () const
 Check status. More...
 
virtual bool fail () const
 Check status. More...
 
virtual bool bad () const
 Check status. More...
 
virtual bool eof () const
 Check end of file. More...
 
bool less (const JAbstractFile &file) const
 Less than operation. More...
 
int getFileDescriptor () const
 Get file descriptor. More...
 
void setFileDescriptor (const int file)
 Set file descriptor. More...
 
bool is_open () const
 Get open status. More...
 
const sockaddr * getSockaddr () const
 Get sockaddr. More...
 
sockaddr * getSockaddr ()
 Get sockaddr. More...
 
int getFamily () const
 Get family. More...
 
void setFamily (const int family)
 Set family. More...
 
std::string getHostname () const
 Get host name. More...
 
int getIPnumber () const
 Get IP number. More...
 
void setIPnumber (const int ip_number)
 Set IP number. More...
 
void setIPnumber ()
 Set any IP number. More...
 
int getPort () const
 Get port number. More...
 
void setPort (const int port)
 Set port number. More...
 
virtual bool hasNext () override
 Check availability of next element. More...
 
virtual const pointer_typenext () override
 Get next element. More...
 
virtual skip_type skip (const skip_type ns)
 Skip items. More...
 

Static Public Member Functions

static int sizeOf ()
 Get size of object. More...
 

Static Public Attributes

static const int FILE_CLOSED = -1
 

Protected Member Functions

template<class T >
void setOption (const int level, const int option, const T value)
 Set socket option. More...
 
template<class T >
T getOption (const int level, const int option) const
 Get socket option. More...
 

Protected Attributes

int fileDescriptor
 
T object
 object More...
 
bool has_next
 status More...
 

Private Attributes

JSelectReader select
 
int buffer_size
 
int timeout_us
 

Detailed Description

template<class T>
class JNET::JLigierObjectIterator< T >

Object iteration through ControlHost server.

This class implements the JLANG::JObjectIterator interface.

Definition at line 46 of file JLigierObjectIterator.hh.

Member Typedef Documentation

template<class T>
typedef JObjectIterator<T>::pointer_type JLANG::JAbstractObjectIterator< T >::pointer_type
inherited

Definition at line 39 of file JAbstractObjectIterator.hh.

Constructor & Destructor Documentation

template<class T>
JNET::JLigierObjectIterator< T >::JLigierObjectIterator ( const int  port,
const int  backlog,
const int  buffer_size = 262144,
const int  timeout_us = 10 
)
inline

Constructor.

Parameters
portserver port
backlogserver backlog
buffer_sizesocket buffer size
timeout_ustimeout [us]

Definition at line 61 of file JLigierObjectIterator.hh.

64  :
65  JServerSocket(port,backlog),
68  {}
JServerSocket(const int port, const int backlog)
Constructor.

Member Function Documentation

template<class T>
virtual bool JNET::JLigierObjectIterator< T >::setObject ( T object)
inlineoverridevirtual

Set object.

Parameters
objectreference to object to be set
Returns
true if set; else false

Implements JLANG::JAbstractObjectIterator< T >.

Definition at line 77 of file JLigierObjectIterator.hh.

78  {
79  using namespace std;
80 
81  for ( ; ; ) {
82 
83  select.reset();
85 
86  for (const_iterator channel = this->begin(); channel != this->end(); ++channel) {
87  if (!channel->isReady()) {
88  select.setReaderMask(channel->getFileDescriptor());
89  }
90  }
91 
92  if (select(timeout_us) > 0) {
93 
94  for (iterator channel = this->begin(); channel != this->end(); ) {
95 
96  if (select.hasReaderMask(*channel)) {
97 
98  try {
99 
100  channel->read();
101 
102  if (channel->isReady()) {
103 
104  if (channel->prefix.getTag() == getTag<T>()) {
105 
106  channel->seekg(sizeof(JPrefix));
107 
108  *channel >> object; // read object
109 
110  channel->reset();
111 
112  return true;
113 
114  } else {
115 
116  channel->reset(); // skip data
117  }
118  }
119  }
120  catch(const exception& error) {
121 
122  channel->shutdown();
123 
124  channel = this->erase(channel);
125 
126  continue;
127  }
128  }
129 
130  ++channel;
131  }
132 
133  if (select.hasReaderMask(*this)) {
134 
135  JTCPSocket socket;
136 
137  socket.accept(this->getFileDescriptor());
138 
139  //socket.setSendBufferSize (buffer_size);
141 
142  socket.setKeepAlive (true);
143  socket.setNonBlocking(true);
144 
145  this->push_back(JSocketInputChannel_t(socket));
146  }
147  }
148  }
149 
150  return false;
151  }
ControlHost prefix.
Definition: JPrefix.hh:31
void setReaderMask(const JAbstractFile &file)
Set reader mask.
int getFileDescriptor() const
Get file descriptor.
void accept(const int server)
Accept connection from a server.
Definition: JTCPSocket.hh:139
void setReceiveBufferSize(const int size)
Set receive buffer size.
Definition: JSocket.hh:131
void reset()
Reset.
TCP socket.
Definition: JTCPSocket.hh:25
void setNonBlocking(const bool on)
Set non-blocking of I/O.
Definition: JTCPSocket.hh:42
JSocketInputChannel< JPrefix_t > JSocketInputChannel_t
Definition: JLigier.cc:30
void setKeepAlive(const bool on)
Set keep alive of socket.
Definition: JSocket.hh:87
bool hasReaderMask(const JAbstractFile &file) const
Has reader file.
void JNET::JTCPSocket::setNonBlocking ( const bool  on)
inlineinherited

Set non-blocking of I/O.

Parameters
ontrue to enable non-blocking; false to disable

Definition at line 42 of file JTCPSocket.hh.

43  {
44  const int flags = fcntl(getFileDescriptor(), F_GETFL, -1);
45  const int mask = FNDELAY;
46 
47  if (flags == -1) {
48  THROW(JSocketException, "Get socket option failed " << errno);
49  }
50 
51  if (((flags & mask) != mask && on) ||
52  ((flags & mask) != 0 && !on) ) {
53 
54  if (fcntl(getFileDescriptor(), F_SETFL, flags ^ mask) < 0) {
55  THROW(JSocketException, "Set socket option failed " << errno);
56  }
57  }
58  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
int getFileDescriptor() const
Get file descriptor.
bool JNET::JTCPSocket::getNonBlocking ( ) const
inlineinherited

Get non-blocking of I/O.

Returns
true if enabled non-blocking; else false

Definition at line 66 of file JTCPSocket.hh.

67  {
68  const int flags = fcntl(getFileDescriptor(), F_GETFL, -1);
69  const int mask = FNDELAY;
70 
71  if (flags == -1) {
72  THROW(JSocketException, "Get socket option failed " << errno);
73  }
74 
75  return ((flags & mask) != 0);
76  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
int getFileDescriptor() const
Get file descriptor.
void JNET::JTCPSocket::setKeepIdle ( const int  t_s)
inlineinherited

Set the TCP idle time.

Parameters
t_stime [s]

Definition at line 84 of file JTCPSocket.hh.

85  {
86  setOption(IPROTO_TCP, TCP_KEEPIDLE, t_s);
87  }
#define IPROTO_TCP
Definition: JTCPSocket.hh:11
void setOption(const int level, const int option, const T value)
Set socket option.
Definition: JSocket.hh:257
void JNET::JTCPSocket::setKeepCnt ( const int  count)
inlineinherited

Set the TCP idle count.

Parameters
countcount

Definition at line 95 of file JTCPSocket.hh.

96  {
97  setOption(IPROTO_TCP, TCP_KEEPCNT, count);
98  }
#define IPROTO_TCP
Definition: JTCPSocket.hh:11
void setOption(const int level, const int option, const T value)
Set socket option.
Definition: JSocket.hh:257
void JNET::JTCPSocket::setKeepIntvl ( const int  t_s)
inlineinherited

Set the TCP interval time.

Parameters
t_stime [s]

Definition at line 106 of file JTCPSocket.hh.

107  {
108  setOption(IPROTO_TCP, TCP_KEEPINTVL, t_s);
109  }
#define IPROTO_TCP
Definition: JTCPSocket.hh:11
void setOption(const int level, const int option, const T value)
Set socket option.
Definition: JSocket.hh:257
void JNET::JTCPSocket::setTcpNoDelay ( const bool  on)
inlineinherited

Set TCP no-delay.

Parameters
ontrue to set TCP no-delay; false to disable

Definition at line 117 of file JTCPSocket.hh.

118  {
119  setOption(IPPROTO_TCP, TCP_NODELAY, int(on ? 1 : 0));
120  }
void setOption(const int level, const int option, const T value)
Set socket option.
Definition: JSocket.hh:257
bool JNET::JTCPSocket::getTcpNoDelay ( ) const
inlineinherited

Get TCP no-delay.

Returns
true if TCP no-delay; else false

Definition at line 128 of file JTCPSocket.hh.

129  {
130  return (getOption<int>(IPPROTO_TCP, TCP_NODELAY) == 1);
131  }
void JNET::JTCPSocket::accept ( const int  server)
inlineinherited

Accept connection from a server.

Parameters
serverfile descriptor of server socket

Definition at line 139 of file JTCPSocket.hh.

140  {
141  socklen_t size = sizeof(sockaddr_in);
142 
143  fileDescriptor = ::accept(server, getSockaddr(), &size);
144  }
const sockaddr * getSockaddr() const
Get sockaddr.
void accept(const int server)
Accept connection from a server.
Definition: JTCPSocket.hh:139
void JNET::JTCPSocket::connect ( const int  port)
inlineinherited

Connect to port on local host.

Parameters
portport number

Definition at line 152 of file JTCPSocket.hh.

153  {
154  connect(INADDR_ANY, port);
155  }
void connect(const int port)
Connect to port on local host.
Definition: JTCPSocket.hh:152
void JNET::JTCPSocket::connect ( const JHostname hostname)
inlineinherited

Connect to port on specified host.

Parameters
hostnamehost name

Definition at line 163 of file JTCPSocket.hh.

164  {
165  connect(hostname.hostname, hostname.port);
166  }
std::string hostname
Definition: JHostname.hh:154
void connect(const int port)
Connect to port on local host.
Definition: JTCPSocket.hh:152
void JNET::JTCPSocket::connect ( const std::string hostname,
const int  port 
)
inlineinherited

Connect to port on specified host.

Parameters
hostnamehost name
portport number

Definition at line 175 of file JTCPSocket.hh.

176  {
177  connect(JSYSTEM::getIPnumber(hostname), port);
178  }
int getIPnumber(const std::string &host_name)
Get IP number.
Definition: JNetwork.hh:117
void connect(const int port)
Connect to port on local host.
Definition: JTCPSocket.hh:152
void JNET::JTCPSocket::connect ( const int  ip_number,
const int  port 
)
inlineinherited

Connect to port on specified host.

Parameters
ip_numberIP number
portport number

Definition at line 187 of file JTCPSocket.hh.

188  {
189  setIPnumber(ip_number);
190  setPort(port);
191 
192  if (::connect(getFileDescriptor(), getSockaddr(), sizeof(sockaddr_in)) < 0) {
193  THROW(JSocketException, "Socket connection failed " << JSYSTEM::getIPaddress(ip_number) << ":" << port << " / " << getFileDescriptor() << " " << errno);
194  }
195  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
std::string getIPaddress(const int ip)
Get IP address (decimal-dot notation).
Definition: JNetwork.hh:154
void setIPnumber()
Set any IP number.
const sockaddr * getSockaddr() const
Get sockaddr.
int getFileDescriptor() const
Get file descriptor.
void setPort(const int port)
Set port number.
void connect(const int port)
Connect to port on local host.
Definition: JTCPSocket.hh:152
int JNET::JSocket::shutdown ( )
inlineinherited

Shut down socket.

Definition at line 72 of file JSocket.hh.

73  {
74  const int value = ::shutdown(getFileDescriptor(), SHUT_RDWR);
75 
76  close();
77 
78  return value;
79  }
void close()
Close file.
Definition: JFile.hh:55
int getFileDescriptor() const
Get file descriptor.
int shutdown()
Shut down socket.
Definition: JSocket.hh:72
void JNET::JSocket::setKeepAlive ( const bool  on)
inlineinherited

Set keep alive of socket.

Parameters
ontrue to enable keep alive; false to disable

Definition at line 87 of file JSocket.hh.

88  {
89  setOption(SOL_SOCKET, SO_KEEPALIVE, int(on ? 1 : 0));
90  }
void setOption(const int level, const int option, const T value)
Set socket option.
Definition: JSocket.hh:257
bool JNET::JSocket::getKeepAlive ( ) const
inlineinherited

Get keep alive of socket.

Returns
true if keep alive; else false

Definition at line 98 of file JSocket.hh.

99  {
100  return (getOption<int>(SOL_SOCKET, SO_KEEPALIVE) == 1);
101  }
void JNET::JSocket::setReuseAddress ( const bool  on)
inlineinherited

Set reuse address.

Parameters
ontrue to enable reuse address; false to disable

Definition at line 109 of file JSocket.hh.

110  {
111  setOption(SOL_SOCKET, SO_REUSEADDR, int(on ? 1 : 0));
112  }
void setOption(const int level, const int option, const T value)
Set socket option.
Definition: JSocket.hh:257
bool JNET::JSocket::getReuseAddress ( ) const
inlineinherited

Get reuse address.

Returns
true if enable reuse address; else false

Definition at line 120 of file JSocket.hh.

121  {
122  return (getOption<int>(SOL_SOCKET, SO_REUSEADDR) == 1);
123  }
void JNET::JSocket::setReceiveBufferSize ( const int  size)
inlineinherited

Set receive buffer size.

Parameters
sizenumber of bytes

Definition at line 131 of file JSocket.hh.

132  {
133  setOption(SOL_SOCKET, SO_RCVBUF, int(size));
134  }
void setOption(const int level, const int option, const T value)
Set socket option.
Definition: JSocket.hh:257
int JNET::JSocket::getReceiveBufferSize ( ) const
inlineinherited

Set receive buffer size.

Returns
number of bytes

Definition at line 142 of file JSocket.hh.

143  {
144  return getOption<int>(SOL_SOCKET, SO_RCVBUF);
145  }
void JNET::JSocket::setSendBufferSize ( const int  size)
inlineinherited

Set send buffer size.

Parameters
sizenumber of bytes

Definition at line 153 of file JSocket.hh.

154  {
155  setOption(SOL_SOCKET, SO_SNDBUF, int(size));
156  }
void setOption(const int level, const int option, const T value)
Set socket option.
Definition: JSocket.hh:257
int JNET::JSocket::getSendBufferSize ( ) const
inlineinherited

Get send buffer size.

Returns
number of bytes

Definition at line 164 of file JSocket.hh.

165  {
166  return getOption<int>(SOL_SOCKET, SO_SNDBUF);
167  }
virtual int JNET::JSocket::read ( char *  buffer,
const int  length 
)
inlineoverridevirtualinherited

Read data from socket.

This method handles I/O errors in such a way that:

  1. the return value is set to zero if no data are read;
  2. an exception is thrown in case of a fatal error;
Parameters
bufferbuffer
lengthnumber of bytes to read
Returns
number of bytes actually read

Reimplemented from JLANG::JFile.

Reimplemented in JNET::JUDPSocket, and JNET::JSocketBlocking.

Definition at line 181 of file JSocket.hh.

182  {
183  int pos = JFile::read(buffer, length);
184 
185  if (pos == 0) {
186 
187  THROW(JSocketException, "Socket read failed " << errno);
188 
189  } else if (pos < 0) {
190 
191  switch (errno) {
192 
193  case EINTR:
194  case EWOULDBLOCK:
195  //case EAGAIN:
196  break;
197 
198  default:
199  THROW(JSocketException, "Socket read error " << errno);
200  }
201 
202  pos = 0;
203  }
204 
205  return pos;
206  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
virtual int read(char *buffer, const int length)
Read data from file.
Definition: JFile.hh:74
virtual int JNET::JSocket::write ( const char *  buffer,
const int  length 
)
inlineoverridevirtualinherited

Write data to socket.

This method handles I/O errors in such a way that:

  1. the return value is set to zero if no data are written;
  2. an exception is thrown in case of a fatal error;
Parameters
bufferbuffer
lengthnumber of bytes to write
Returns
number of bytes actually written

Reimplemented from JLANG::JFile.

Reimplemented in JNET::JUDPSocket, and JNET::JSocketBlocking.

Definition at line 220 of file JSocket.hh.

221  {
222  int pos = JFile::write(buffer, length);
223 
224  if (pos == 0) {
225 
226  THROW(JSocketException, "Socket write failed " << errno);
227 
228  } else if (pos < 0) {
229 
230  switch (errno) {
231 
232  case EINTR:
233  case EWOULDBLOCK:
234  //case EAGAIN:
235  break;
236 
237  default:
238  THROW(JSocketException, "Socket write error " << errno);
239  }
240 
241  pos = 0;
242  }
243 
244  return pos;
245  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
virtual int write(const char *buffer, const int length)
Write data to file.
Definition: JFile.hh:87
template<class T >
void JNET::JSocket::setOption ( const int  level,
const int  option,
const T  value 
)
inlineprotectedinherited

Set socket option.

Parameters
levellevel
optionoption
valuevalue

Definition at line 257 of file JSocket.hh.

258  {
259  socklen_t size = sizeof(T);
260 
261  if (setsockopt(getFileDescriptor(), level, option, &value, size) < 0) {
262  THROW(JSocketException, "Set socket option failed " << errno);
263  }
264  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
int getFileDescriptor() const
Get file descriptor.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
template<class T >
T JNET::JSocket::getOption ( const int  level,
const int  option 
) const
inlineprotectedinherited

Get socket option.

Parameters
levellevel
optionoption
Returns
value

Definition at line 275 of file JSocket.hh.

276  {
277  T value;
278  socklen_t size = sizeof(T);
279 
280  if (getsockopt(getFileDescriptor(), level, option, &value, &size) < 0) {
281  THROW(JSocketException, "Get socket option failed " << errno);
282  }
283 
284  return value;
285  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
int getFileDescriptor() const
Get file descriptor.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
void JLANG::JFile::close ( )
inlineinherited

Close file.

Definition at line 55 of file JFile.hh.

56  {
57  if (fileDescriptor != FILE_CLOSED) {
58 
60 
62  result = 0;
63  }
64  }
void close()
Close file.
Definition: JFile.hh:55
static const int FILE_CLOSED
int result
Definition: JFile.hh:164
bool JLANG::JFile::in_avail ( JTimeval  timeout = JTimeval::min()) const
inlineinherited

Check availability of input.

This method returns true if at least one byte can be read without blocking.

Parameters
timeouttimeout
Returns
true if ready to read; else false

Definition at line 100 of file JFile.hh.

101  {
102  return JFileDescriptorMask(*this).in_avail(timeout);
103  }
Auxiliary class for method select.
bool in_avail(JTimeval timeout=JTimeval::min())
Check availability of input.
bool JLANG::JFile::out_avail ( JTimeval  timeout = JTimeval::min()) const
inlineinherited

Check availability of output.

This method returns true if at least one byte can be written without blocking.

Parameters
timeouttimeout
Returns
true if ready to write; else false

Definition at line 113 of file JFile.hh.

114  {
115  return JFileDescriptorMask(*this).out_avail(timeout);
116  }
bool out_avail(JTimeval timeout=JTimeval::min())
Check availability of output.
Auxiliary class for method select.
virtual bool JLANG::JFile::good ( ) const
inlinevirtualinherited

Check status.

Returns
true if last I/O operation successful; else false

Definition at line 124 of file JFile.hh.

125  {
126  return is_open() && !eof() && !bad();
127  }
virtual bool eof() const
Check end of file.
Definition: JFile.hh:157
bool is_open() const
Get open status.
virtual bool bad() const
Check status.
Definition: JFile.hh:146
virtual bool JLANG::JFile::fail ( ) const
inlinevirtualinherited

Check status.

Returns
true if last I/O operation caused logical error; else false

Definition at line 135 of file JFile.hh.

136  {
137  return result == 0;
138  }
int result
Definition: JFile.hh:164
virtual bool JLANG::JFile::bad ( ) const
inlinevirtualinherited

Check status.

Returns
true if last I/O operation caused read/write error; else false

Definition at line 146 of file JFile.hh.

147  {
148  return fail();
149  }
virtual bool fail() const
Check status.
Definition: JFile.hh:135
virtual bool JLANG::JFile::eof ( ) const
inlinevirtualinherited

Check end of file.

Returns
true if end of file; else false

Definition at line 157 of file JFile.hh.

158  {
159  return result == EOF;
160  }
int result
Definition: JFile.hh:164
bool JLANG::JAbstractFile::less ( const JAbstractFile file) const
inlineinherited

Less than operation.

Parameters
fileJAbstractFile to be compared
Returns
true if this file descriptor is less; else false

Definition at line 64 of file JAbstractFile.hh.

65  {
66  return getFileDescriptor() < file.getFileDescriptor();
67  }
int getFileDescriptor() const
Get file descriptor.
int JLANG::JAbstractFile::getFileDescriptor ( ) const
inlineinherited

Get file descriptor.

Returns
file descriptor

Definition at line 75 of file JAbstractFile.hh.

76  {
77  return fileDescriptor;
78  }
void JLANG::JAbstractFile::setFileDescriptor ( const int  file)
inlineinherited

Set file descriptor.

Parameters
filefile descriptor

Definition at line 86 of file JAbstractFile.hh.

87  {
89  }
then usage $script[< detector identifier >< run range >]< QA/QCfile > nExample script to produce data quality plots nWhen a detector identifier and run range are data are downloaded from the database nand subsequently stored in the given QA QC file
Definition: JDataQuality.sh:19
bool JLANG::JAbstractFile::is_open ( ) const
inlineinherited

Get open status.

Definition at line 95 of file JAbstractFile.hh.

96  {
97  return fileDescriptor != FILE_CLOSED;
98  }
static const int FILE_CLOSED
const sockaddr* JNET::JSocketAddress::getSockaddr ( ) const
inlineinherited

Get sockaddr.

Returns
pointer to sockaddr structure

Definition at line 44 of file JSocketAddress.hh.

45  {
46  return (const sockaddr*) static_cast<const sockaddr_in*>(this);
47  }
sockaddr* JNET::JSocketAddress::getSockaddr ( )
inlineinherited

Get sockaddr.

Returns
pointer to sockaddr structure

Definition at line 55 of file JSocketAddress.hh.

56  {
57  return (sockaddr*) static_cast<sockaddr_in*>(this);
58  }
int JNET::JSocketAddress::getFamily ( ) const
inlineinherited

Get family.

Returns
family

Definition at line 66 of file JSocketAddress.hh.

67  {
68  return sin_family;
69  }
void JNET::JSocketAddress::setFamily ( const int  family)
inlineinherited

Set family.

Parameters
familyfamily

Definition at line 77 of file JSocketAddress.hh.

78  {
79  sin_family = family;
80  }
std::string JNET::JSocketAddress::getHostname ( ) const
inlineinherited

Get host name.

Returns
host name

Definition at line 88 of file JSocketAddress.hh.

89  {
90  return JSYSTEM::getHostname(this->getIPnumber());
91  }
int getIPnumber() const
Get IP number.
std::string getHostname()
Get host name.
Definition: JNetwork.hh:77
int JNET::JSocketAddress::getIPnumber ( ) const
inlineinherited

Get IP number.

Returns
IP number

Definition at line 99 of file JSocketAddress.hh.

100  {
101  return sin_addr.s_addr;
102  }
void JNET::JSocketAddress::setIPnumber ( const int  ip_number)
inlineinherited

Set IP number.

Parameters
ip_numberIP number

Definition at line 110 of file JSocketAddress.hh.

111  {
112  sin_addr.s_addr = ip_number;
113  }
void JNET::JSocketAddress::setIPnumber ( )
inlineinherited

Set any IP number.

Definition at line 119 of file JSocketAddress.hh.

120  {
121  sin_addr.s_addr = htonl(INADDR_ANY);
122  }
int JNET::JSocketAddress::getPort ( ) const
inlineinherited

Get port number.

Returns
port number

Definition at line 130 of file JSocketAddress.hh.

131  {
132  return ntohs(this->sin_port);
133  }
void JNET::JSocketAddress::setPort ( const int  port)
inlineinherited

Set port number.

Parameters
portport number

Definition at line 141 of file JSocketAddress.hh.

142  {
143  if (port >= 0 && port <= std::numeric_limits<u_short>::max())
144  sin_port = htons((u_short) port);
145  else
146  THROW(JCastException, "JSocketAddress::setPort() illegal value.");
147  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
static int JNET::JSocketAddress::sizeOf ( )
inlinestaticinherited

Get size of object.

Returns
number of bytes

Definition at line 155 of file JSocketAddress.hh.

156  {
157  return sizeof(sockaddr_in);
158  }
template<class T>
virtual bool JLANG::JAbstractObjectIterator< T >::hasNext ( )
inlineoverridevirtualinherited

Check availability of next element.

Returns
true if the iteration has more elements; else false

Implements JLANG::JObjectIterator< T >.

Definition at line 56 of file JAbstractObjectIterator.hh.

57  {
58  if (!has_next) {
59  has_next = this->setObject(object);
60  }
61 
62  return has_next;
63  }
virtual bool setObject(T &object)=0
Set object.
template<class T>
virtual const pointer_type& JLANG::JAbstractObjectIterator< T >::next ( )
inlineoverridevirtualinherited

Get next element.

Returns
pointer to element

Implements JLANG::JObjectIterator< T >.

Definition at line 71 of file JAbstractObjectIterator.hh.

72  {
73  if (has_next)
74  ps.reset(&this->object);
75  else
76  ps.reset(NULL);
77 
78  has_next = false;
79 
80  return ps;
81  }
virtual void reset() override
Reset pointer.
Definition: JPointer.hh:84
template<class T>
virtual skip_type JLANG::JObjectIterator< T >::skip ( const skip_type  ns)
inlinevirtualinherited

Skip items.

Parameters
nsnumber of items to skip
Returns
number of items skipped

Reimplemented in JLANG::JPipe< T >, JLANG::JPipe< JTail_t >, JLANG::JPipe< JHead_t >, JLANG::JSTDObjectIterator< T >, JLANG::JAbstractObjectReader< T >, JLANG::JAbstractObjectReader< JNullType >, JLANG::JAbstractObjectReader< const T >, JLANG::JAbstractObjectReader< JTail_t >, JLANG::JAbstractObjectReader< JHead_t >, JLANG::JAbstractObjectReader< KM3NETDAQ::KM3NETDAQ::JDAQEvent >, and JLANG::JAbstractObjectReader< JDAQSummaryslice >.

Definition at line 90 of file JObjectIterator.hh.

91  {
92  skip_type i = 0;
93 
94  for ( ; i != ns && hasNext(); ++i) {
95  next();
96  }
97 
98  return i;
99  }
unsigned int skip_type
Type definition for number of objects to skip.
std::vector< size_t > ns
virtual const pointer_type & next()=0
Get next element.
virtual bool hasNext()=0
Check availability of next element.

Member Data Documentation

template<class T>
JSelectReader JNET::JLigierObjectIterator< T >::select
private

Definition at line 154 of file JLigierObjectIterator.hh.

template<class T>
int JNET::JLigierObjectIterator< T >::buffer_size
private

Definition at line 155 of file JLigierObjectIterator.hh.

template<class T>
int JNET::JLigierObjectIterator< T >::timeout_us
private

Definition at line 156 of file JLigierObjectIterator.hh.

const int JLANG::JAbstractFile::FILE_CLOSED = -1
staticinherited

Definition at line 27 of file JAbstractFile.hh.

int JLANG::JAbstractFile::fileDescriptor
protectedinherited

Definition at line 102 of file JAbstractFile.hh.

template<class T>
T JLANG::JAbstractObjectIterator< T >::object
protectedinherited

object

Definition at line 34 of file JAbstractObjectIterator.hh.

template<class T>
bool JLANG::JAbstractObjectIterator< T >::has_next
protectedinherited

status

Definition at line 35 of file JAbstractObjectIterator.hh.


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