1 #ifndef __JNET__JCONTROLHOST__ 
    2 #define __JNET__JCONTROLHOST__ 
   24 namespace JPP { 
using namespace JNET; }
 
  133     public JMath<JSubscriptionList>
 
  179       if (p != this->end() && p->getID() == subscription.
getID()) {
 
  188       this->insert(subscription);
 
  220         buffer += 
' ' + i->toString();
 
  250     public JThrow<JControlHost>
 
  271       return tag[0] == 
'_';
 
  384     int MyId(
const std::string& nick_name)
 
  424         JPrefix __prefix__(tag, length);
 
  429           write((
char*) buffer, (
int) length);
 
  435         return Throw(error, -1);
 
  448     int PutFullData(
const std::string& tag, 
const void* buffer, 
const long long int length)
 
  454         return Throw(error, -1);
 
  457         return Throw(error, -2);
 
  470                       const std::string& buffer)
 
  484                       const std::string& buffer)
 
  486       return PutFullData(tag, buffer.c_str(), buffer.size());
 
  518         return Throw(error, -1);
 
  530     int WaitHead(std::string& tag, 
long long int& length)
 
  566         return Throw(error, -1);
 
  579     int CheckHead(std::string& tag, 
long long int& length, 
const int timeout_us = 0)
 
  581       const int rvalue = 
CheckHead(this->prefix, timeout_us);
 
  584         tag    = this->prefix.
getTag();
 
  585         length = this->prefix.
getSize();
 
  603         read((
char*) buffer, (
int) length);
 
  608         return Throw(error, -1);
 
  621       buffer.resize(this->prefix.
getSize());
 
  623       return GetFullData((
char*) buffer.data(), buffer.size());
 
  635     static int WhereIs(
const std::string& host_name,
 
  636                        const std::string& nick_name, 
 
  648         long long int length;
 
  656         return Throw(error, -1);
 
  680         return Throw(error, -1);
 
Base class for data structures with artithmetic capabilities.
 
Vec operator+(const Vec &a, const Vec &b)
Add two vectors.
 
Exception for ControlHost.
 
bool in_avail(JTimeval timeout=JTimeval::min()) const
Check availability of input.
 
Auxiliary base class for controling the throwing of exceptions.
 
static void Throw(const bool option)
Enable/disable throw option.
 
Auxiliary class for time values.
 
static JTimeval min()
Get minimal time value.
 
int MyId(const std::string &nick_name)
Identify.
 
JControlHost(const std::string &server, const int port)
Constructor.
 
int PutFullString(const JTag &tag, const std::string &buffer)
Send string.
 
static int WhereIs(const std::string &host_name, const std::string &nick_name, std::string &answer)
Locate ControlHost client(s).
 
int GetFullString(std::string &buffer)
Receive string.
 
JControlHost(const JHostname &server)
Constructor.
 
int WaitHead(std::string &tag, long long int &length)
Wait for header.
 
JControlHost(JControlHost &&)
 
int WaitHead(JPrefix &prefix)
Wait for header.
 
int CheckHead(JPrefix &prefix, JTimeval timeout=JTimeval::min())
Check for header, without waiting.
 
JControlHost()
Default constructor.
 
int configure()
Configure socket (factory reset).
 
int GetFullData(void *buffer, long long int length)
Receive data.
 
JControlHost & operator=(const JControlHost &)
 
int SendMeAlways()
Tell server to send messages forever.
 
static bool maybe_special(const JTag &tag)
Check special ControlHost tags.
 
int Subscribe(const JSubscriptionList &subscription)
Subscribe to list of tags.
 
int PutFullData(const std::string &tag, const void *buffer, const long long int length)
Send data.
 
JControlHost(const JControlHost &)
 
JControlHost(const JTCPSocket &socket)
Constructor.
 
static bool is_valid(const char c)
Check validity of subscription specifier.
 
int SendMeNext()
Tell server to send next message.
 
~JControlHost()
Destructor.
 
int PutFullData(const JTag &tag, const void *buffer, const long long int length)
Send data.
 
JControlHost & operator=(JControlHost &&)
 
int PutFullString(const std::string &tag, const std::string &buffer)
Send string.
 
JControlHost(const int ip_number, const int port=DISPATCH_PORT)
Constructor.
 
int CheckHead(std::string &tag, long long int &length, const int timeout_us=0)
Check for header, without waiting.
 
int Subscribe(const JSubscription &subscription)
Subscribe to single tag.
 
int Connected()
Send version.
 
int getSize() const
Get size.
 
int read(char *buffer, const int length) override
Read data from socket.
 
int write(const char *buffer, const int length) override
Write data to socket.
 
void setReceiveBufferSize(const int size)
Set receive buffer size.
 
int shutdown()
Shut down socket.
 
void setReuseAddress(const bool on)
Set reuse address.
 
void setKeepAlive(const bool on)
Set keep alive of socket.
 
void setSendBufferSize(const int size)
Set send buffer size.
 
JSubscriptionList & add(const JSubscriptionList &subscription)
Add subscription.
 
const std::set< JSubscription > * operator->() const
Smart pointer.
 
std::string toString() const
Convert subscription list to string.
 
JSubscriptionList(const JSubscription &subscription)
Copy constructor.
 
std::set< JSubscription >::const_iterator const_iterator
 
JSubscriptionList & add(const JSubscription &subscription)
Add subscription.
 
JSubscriptionList()
Default constructor.
 
std::set< JSubscription >::const_reverse_iterator const_reverse_iterator
 
ControlHost subscription.
 
JSubscription_t subscription
 
JSubscription_t getSubscription() const
Get subscription type.
 
std::string toString() const
Convert subscription to string.
 
JSubscription(const JSubscription_t sub, const JTag &tag)
Constructor.
 
void connect(const int port)
Connect to port on local host.
 
void setNonBlocking(const bool on)
Set non-blocking of I/O.
 
void setTcpNoDelay(const bool on)
Set TCP no-delay.
 
const char * c_str() const
C-string.
 
std::string toString() const
Convert tag to string.
 
const JTag & getTag() const
Get tag.
 
JTag_t getID() const
Get identifier.
 
static const JTag DISPTAG_Always("_Always")
 
static const JTag DISPTAG_Gime("_Gime")
 
JSubscription_t
ControlHost subscription types.
 
static const JTag DISPTAG_Version("_Version")
 
static const int DISPATCH_PORT
Default ControlHost port.
 
static const JTag DISPTAG_WhereIs("_WhereIs")
 
static const JTag DISPTAG_MyId("_MyId")
 
static const JTag DISPTAG_Subscribe("_Subscri")
Special ControlHost tags.
 
JControlHost ControlHost
Match name.
 
static const std::string CHOO_VERSION
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
JSubscriptionList getSubscription(const JEventTable &event_table)
Convert event table to ControlHost subscription.
 
Auxiliary base class for aritmetic operations of derived class types.
 
Auxiliary data structure for hostname and port number.
 
Auxiliary class for all subscription.
 
JSubscriptionAll(const JTag &tag)
Constructor.
 
Auxiliary class for any subscription.
 
JSubscriptionAny(const JTag &tag)
Constructor.