Teonet library  0.4.7
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
teo::Teonet Class Reference

Teonet class. More...

#include <teonet.hpp>

Inherited by MyTeonet, MyTeonet, MyTeonet, MyTeonet, and MyTeonet.

Data Structures

class  CQue
 Teonet CQue callback function. More...
 
class  LogReader
 
class  TeoDB
 

Public Types

typedef void(* teoEventsCb )(Teonet &teo, teoEvents event, void *data, size_t data_len, void *user_data)
 Teonet event callback. More...
 
typedef ksnCQueData cqueData
 
typedef ksnCQueCallback cqueCallback
 Teonet CQue data structure. More...
 

Public Member Functions

ksnetEvMgrClassgetKe () const
 Teonet class version. More...
 
 Teonet (int argc, char **argv, teoEventsCb event_cb=NULL, int options=READ_ALL, int port=0, void *user_data=NULL)
 Teonet constructor. More...
 
virtual ~Teonet ()
 Teonet simple destructor. More...
 
void setAppType (const char *type)
 Set Teonet application type. More...
 
void setAppVersion (const char *version)
 Set Teonet application version. More...
 
int run ()
 Start Teonet Event Manager and network communication. More...
 
void BroadcastSend (const char *to, uint8_t cmd, void *data, size_t data_len) const
 Send command by name to peer. More...
 
ksnet_arp_data * sendTo (const char *to, uint8_t cmd, void *data, size_t data_len) const
 
ksnet_arp_data * sendTo (const char *to, uint8_t cmd, const std::string &data) const
 
void sendToA (const char *to, uint8_t cmd, void *data, size_t data_len) const
 Send command by name to peer(asynchronously) More...
 
void sendToA (const char *to, uint8_t cmd, const std::string &data) const
 
void sendAnswerTo (teo::teoPacket *rd, const char *name, void *data, size_t data_len) const
 Sent teonet command to peer or l0 client depend of input rd. More...
 
void sendAnswerTo (teo::teoPacket *rd, const char *name, const std::string &data) const
 
void sendAnswerToA (teo::teoPacket *rd, uint8_t cmd, void *data, size_t data_len) const
 Sent teonet command to peer or l0 client depend of input rd (asynchronously) More...
 
void sendAnswerToA (teo::teoPacket *rd, uint8_t cmd, const std::string &data) const
 
int sendEchoTo (const char *to, void *data=NULL, size_t data_len=0) const
 Send ECHO command to peer. More...
 
int sendToL0 (const char *addr, int port, const char *cname, size_t cname_length, uint8_t cmd, void *data, size_t data_len) const
 Send data to L0 client. More...
 
int sendToL0 (const char *addr, int port, const std::string &cname, uint8_t cmd, void *data, size_t data_len) const
 
int sendToL0 (const char *addr, int port, const std::string &cname, uint8_t cmd, const std::string &data) const
 
int sendToL0 (teoL0Client *l0cli, uint8_t cmd, void *data, size_t data_len) const
 Send data to L0 client with the teoL0Client structure. More...
 
void sendToL0A (const char *addr, int port, const char *cname, size_t cname_length, uint8_t cmd, void *data, size_t data_len) const
 Send data to L0 client. More...
 
int sendEchoToL0 (const char *addr, int port, const char *cname, size_t cname_length, void *data, size_t data_len) const
 Send ECHO command to L0 client. More...
 
int sendEchoToL0A (const char *addr, int port, const char *cname, size_t cname_length, void *data, size_t data_len) const
 
int sendEchoToL0 (teoL0Client *l0cli, void *data, size_t data_len) const
 Send ECHO command to L0 client with teoL0Client structure. More...
 
int sendEchoToL0A (teoL0Client *l0cli, void *data, size_t data_len) const
 
void subscribe (const char *peer_name, uint16_t ev) const
 
void subscribeA (const char *peer_name, uint16_t ev) const
 
void sendToSscr (uint16_t ev, void *data, size_t data_length, uint8_t cmd=0) const
 
void sendToSscr (uint16_t ev, const std::string &data, uint8_t cmd=0) const
 
void sendToSscrA (uint16_t ev, const std::string &data, uint8_t cmd=0) const
 
void setCustomTimer (double time_interval=2.00)
 Set custom timer interval. More...
 
const char * getClassVersion () const
 Get this class version. More...
 
const char * getHostName () const
 Return host name. More...
 
const char * getParam (int parm_number) const
 Get additional application command line parameter defined in teoAppParam. More...
 
double getTime () const
 Get KSNet event manager time. More...
 
const std::string getPath ()
 Get path to teonet data folder. More...
 
void stop ()
 Stop Teonet event manager. More...
 
teo::teoPacketgetPacket (void *data) const
 Cast data to teo::teoPacket. More...
 
void metricCounter (const std::string &name, int value)
 Send counter metric. More...
 
void metricCounter (const std::string &name, double value)
 Send counter metric. More...
 
void metricMs (const std::string &name, double value)
 Send time(ms) metric. More...
 
void metricGauge (const std::string &name, int value)
 Send gauge metric. More...
 
void metricGauge (const std::string &name, double value)
 Send gauge metric. More...
 
virtual void eventCb (teo::teoEvents event, void *data, size_t data_len, void *user_data)
 Virtual Teonet event callback. More...
 
virtual void cqueueCb (uint32_t id, int type, void *data)
 
template<typename... Arguments>
std::string formatMessage (const char *format, const Arguments &...args)
 
CQue::cquePtr getCQueP ()
 CQue class factory(maker) More...
 
CQuegetCQueR ()
 CQue class factory(maker) More...
 
template<typename T >
getCQue ()
 CQue class factory(maker) More...
 

Static Public Member Functions

static const char * getTeonetVersion ()
 Get Teonet library version. More...
 
static teo::teoAppParamappParam (std::vector< const char * > params, std::vector< const char * > params_description)
 Create Application parameters. More...
 

Detailed Description

Teonet class.

This is Teonet L0 client C++ wrapper

Examples:
teocquecpp.cpp.

Member Typedef Documentation

typedef void(* teo::Teonet::teoEventsCb)(Teonet &teo, teoEvents event, void *data, size_t data_len, void *user_data)

Teonet event callback.

Constructor & Destructor Documentation

teo::Teonet::Teonet ( int  argc,
char **  argv,
teoEventsCb  event_cb = NULL,
int  options = READ_ALL,
int  port = 0,
void *  user_data = NULL 
)
inline

Teonet constructor.

Initialize KSNet Event Manager and network and set new default port

Parameters
argcNumber of applications arguments (from main)
argvApplications arguments array (from main)
event_cbEvents callback function called when an event happens
optionsOptions set:
READ_OPTIONS - read options from command line parameters;
READ_CONFIGURATION - read options from configuration file
portSet default port number if non 0
user_dataPointer to user data or NULL if absent

References data, eventCb(), ksnetEvMgrInitPort(), and ksnetEvMgrClass::teo_class.

virtual teo::Teonet::~Teonet ( )
inlinevirtual

Teonet simple destructor.

Member Function Documentation

static teo::teoAppParam* teo::Teonet::appParam ( std::vector< const char * >  params,
std::vector< const char * >  params_description 
)
inlinestatic

Create Application parameters.

Parameters
params
params_description
Returns

References ksnetEvMgrAppParam::app_argc, ksnetEvMgrAppParam::app_argv, and ksnetEvMgrAppParam::app_descr.

void teo::Teonet::BroadcastSend ( const char *  to,
uint8_t  cmd,
void *  data,
size_t  data_len 
) const
inline

Send command by name to peer.

Parameters
kcPointer to ksnCoreClass
toPeer name to send to
cmdCommand
dataCommands data
data_lenCommands data length
Returns
Pointer to ksnet_arp_data or NULL if to peer is absent

References ksnetEvMgrClass::kc, and teoBroadcastSend().

virtual void teo::Teonet::cqueueCb ( uint32_t  id,
int  type,
void *  data 
)
inlinevirtual
virtual void teo::Teonet::eventCb ( teo::teoEvents  event,
void *  data,
size_t  data_len,
void *  user_data 
)
inlinevirtual

Virtual Teonet event callback.

Parameters
event
data
data_len
user_data

Referenced by Teonet().

template<typename... Arguments>
std::string teo::Teonet::formatMessage ( const char *  format,
const Arguments &...  args 
)
inline

References free(), and ksnet_formatMessage().

const char* teo::Teonet::getClassVersion ( ) const
inline

Get this class version.

Returns
template<typename T >
T teo::Teonet::getCQue ( )
inline

CQue class factory(maker)

Returns
T
CQue::cquePtr teo::Teonet::getCQueP ( )
inline

CQue class factory(maker)

Returns
Unique pointer to CQue object

Referenced by getCQueR().

CQue& teo::Teonet::getCQueR ( )
inline

CQue class factory(maker)

Returns
Reference to CQue object
Examples:
teocquecpp.cpp.

References getCQueP().

Referenced by event_cb().

const char* teo::Teonet::getHostName ( ) const
inline

Return host name.

Returns

References ksnetEvMgrGetHostName().

ksnetEvMgrClass* teo::Teonet::getKe ( ) const
inline
teo::teoPacket* teo::Teonet::getPacket ( void *  data) const
inline

Cast data to teo::teoPacket.

Parameters
dataPointer to data
Returns
Pointer to teo::teoPacket

References data.

Referenced by event_cb(), and teo::Teonet::TeoDB::process().

const char* teo::Teonet::getParam ( int  parm_number) const
inline

Get additional application command line parameter defined in teoAppParam.

Parameters
parm_numberNumber of application parameter (started from 1)
Returns

References teonet_cfg::app_argv, getKe(), and ksnetEvMgrClass::teo_cfg.

const std::string teo::Teonet::getPath ( )
inline

Get path to teonet data folder.

Returns
Null terminated static string

References free(), and getDataPath().

static const char* teo::Teonet::getTeonetVersion ( )
inlinestatic

Get Teonet library version.

Returns

References teoGetLibteonetVersion().

double teo::Teonet::getTime ( ) const
inline

Get KSNet event manager time.

Parameters
kePointer to ksnetEvMgrClass
Returns

References ksnetEvMgrGetTime().

void teo::Teonet::metricCounter ( const std::string &  name,
int  value 
)
inline

Send counter metric.

Parameters
nameMetric name
valueMetric counter value

References teoMetricCounter(), and ksnetEvMgrClass::tm.

void teo::Teonet::metricCounter ( const std::string &  name,
double  value 
)
inline

Send counter metric.

Parameters
nameMetric name
valueMetric counter value

References teoMetricCounterf(), and ksnetEvMgrClass::tm.

void teo::Teonet::metricGauge ( const std::string &  name,
int  value 
)
inline

Send gauge metric.

Parameters
nameMetric name
valueMetric gauge value

References teoMetricGauge(), and ksnetEvMgrClass::tm.

void teo::Teonet::metricGauge ( const std::string &  name,
double  value 
)
inline

Send gauge metric.

Parameters
nameMetric name
valueMetric gauge value

References teoMetricGaugef(), and ksnetEvMgrClass::tm.

void teo::Teonet::metricMs ( const std::string &  name,
double  value 
)
inline

Send time(ms) metric.

Parameters
nameMetric name
valueMetric ms value

References teoMetricMs(), and ksnetEvMgrClass::tm.

int teo::Teonet::run ( )
inline

Start Teonet Event Manager and network communication.

Returns
Always 0
Examples:
teocquecpp.cpp.

References ksnetEvMgrRun().

void teo::Teonet::sendAnswerTo ( teo::teoPacket rd,
const char *  name,
void *  data,
size_t  data_len 
) const
inline

Sent teonet command to peer or l0 client depend of input rd.

Parameters
kePointer to ksnetEvMgrClass
rdPointer to rd
nameName to send to
data
data_len
Returns

References sendCmdAnswerTo.

Referenced by sendAnswerTo().

void teo::Teonet::sendAnswerTo ( teo::teoPacket rd,
const char *  name,
const std::string &  data 
) const
inline

References sendAnswerTo().

void teo::Teonet::sendAnswerToA ( teo::teoPacket rd,
uint8_t  cmd,
void *  data,
size_t  data_len 
) const
inline

Sent teonet command to peer or l0 client depend of input rd (asynchronously)

Parameters
kePointer to ksnetEvMgrClass
rdPointer to rd
nameName to send to
data
data_len
Returns

References sendCmdAnswerToBinaryA().

void teo::Teonet::sendAnswerToA ( teo::teoPacket rd,
uint8_t  cmd,
const std::string &  data 
) const
inline
int teo::Teonet::sendEchoTo ( const char *  to,
void *  data = NULL,
size_t  data_len = 0 
) const
inline

Send ECHO command to peer.

Parameters
toPeer name to send to
cmdCommand
dataCommands data
data_lenCommands data length
Returns
True at success

References data, ksnetEvMgrClass::kc, ksnCoreClass::kco, and ksnCommandSendCmdEcho().

int teo::Teonet::sendEchoToL0 ( const char *  addr,
int  port,
const char *  cname,
size_t  cname_length,
void *  data,
size_t  data_len 
) const
inline

Send ECHO command to L0 client.

Parameters
addrIP address of remote peer
portPort of remote peer
cnameL0 client name (include trailing zero)
cname_lengthLength of the L0 client name
cmdCommand
dataData
data_lenData length
Returns
Return 0 if success; -1 if data length is too lage (more than 32319)

References ksnLNullSendEchoToL0().

Referenced by sendEchoToL0().

int teo::Teonet::sendEchoToL0 ( teoL0Client l0cli,
void *  data,
size_t  data_len 
) const
inline

Send ECHO command to L0 client with teoL0Client structure.

Parameters
l0cliPointer to teoL0Client
dataData
data_lenData length
Returns
Return 0 if success; -1 if data length is too lage (more than 32319)

References teo::teoL0Client::addr, teo::teoL0Client::name, teo::teoL0Client::name_len, teo::teoL0Client::port, and sendEchoToL0().

int teo::Teonet::sendEchoToL0A ( const char *  addr,
int  port,
const char *  cname,
size_t  cname_length,
void *  data,
size_t  data_len 
) const
inline

References ksnLNullSendEchoToL0A().

Referenced by sendEchoToL0A().

int teo::Teonet::sendEchoToL0A ( teoL0Client l0cli,
void *  data,
size_t  data_len 
) const
inline
ksnet_arp_data* teo::Teonet::sendTo ( const char *  to,
uint8_t  cmd,
void *  data,
size_t  data_len 
) const
inline

References ksnetEvMgrClass::kc, and ksnCoreSendCmdto().

Referenced by sendTo().

ksnet_arp_data* teo::Teonet::sendTo ( const char *  to,
uint8_t  cmd,
const std::string &  data 
) const
inline

References sendTo().

void teo::Teonet::sendToA ( const char *  to,
uint8_t  cmd,
void *  data,
size_t  data_len 
) const
inline

Send command by name to peer(asynchronously)

Parameters
kcPointer to ksnCoreClass
toPeer name to send to
cmdCommand
dataCommands data
data_lenCommands data length

References ksnCoreSendCmdtoA().

Referenced by sendToA().

void teo::Teonet::sendToA ( const char *  to,
uint8_t  cmd,
const std::string &  data 
) const
inline

References sendToA().

int teo::Teonet::sendToL0 ( const char *  addr,
int  port,
const char *  cname,
size_t  cname_length,
uint8_t  cmd,
void *  data,
size_t  data_len 
) const
inline

Send data to L0 client.

Usually it is an answer to request from L0 client

Parameters
addrIP address of remote peer
portPort of remote peer
cnameL0 client name (include trailing zero)
cname_lengthLength of the L0 client name
cmdCommand
dataData
data_lenData length
Returns
Return 0 if success; -1 if data length is too lage (more than 32319)

References ksnLNullSendToL0().

Referenced by sendToL0().

int teo::Teonet::sendToL0 ( const char *  addr,
int  port,
const std::string &  cname,
uint8_t  cmd,
void *  data,
size_t  data_len 
) const
inline

References data, and sendToL0().

int teo::Teonet::sendToL0 ( const char *  addr,
int  port,
const std::string &  cname,
uint8_t  cmd,
const std::string &  data 
) const
inline

References sendToL0().

int teo::Teonet::sendToL0 ( teoL0Client l0cli,
uint8_t  cmd,
void *  data,
size_t  data_len 
) const
inline

Send data to L0 client with the teoL0Client structure.

Parameters
l0cliPointer to teoL0Client
cmdCommand
dataData
data_lenData length
Returns
Return 0 if success; -1 if data length is too lage (more than 32319)

References teo::teoL0Client::addr, teo::teoL0Client::name, teo::teoL0Client::name_len, teo::teoL0Client::port, and sendToL0().

void teo::Teonet::sendToL0A ( const char *  addr,
int  port,
const char *  cname,
size_t  cname_length,
uint8_t  cmd,
void *  data,
size_t  data_len 
) const
inline

Send data to L0 client.

Usually it is an answer to request from L0 client(asynchronously)

Parameters
addrIP address of remote peer
portPort of remote peer
cnameL0 client name (include trailing zero)
cname_lengthLength of the L0 client name
cmdCommand
dataData
data_lenData length

References ksnCorePacketData::addr, ksnCorePacketData::from, ksnCorePacketData::from_len, ksnCorePacketData::l0_f, ksnCorePacketData::port, rd, and sendCmdAnswerToBinaryA().

void teo::Teonet::sendToSscr ( uint16_t  ev,
void *  data,
size_t  data_length,
uint8_t  cmd = 0 
) const
inline
void teo::Teonet::sendToSscr ( uint16_t  ev,
const std::string &  data,
uint8_t  cmd = 0 
) const
inline

References sendToSscr().

void teo::Teonet::sendToSscrA ( uint16_t  ev,
const std::string &  data,
uint8_t  cmd = 0 
) const
inline

References teoSScrSendA().

void teo::Teonet::setAppType ( const char *  type)
inline

Set Teonet application type.

Parameters
typeApplication type string

References teoSetAppType().

void teo::Teonet::setAppVersion ( const char *  version)
inline

Set Teonet application version.

Parameters
versionApplication version string

References teoSetAppVersion().

void teo::Teonet::setCustomTimer ( double  time_interval = 2.00)
inline

Set custom timer interval.

Parameters
time_interval
Examples:
teocquecpp.cpp.

References ksnetEvMgrSetCustomTimer().

void teo::Teonet::stop ( )
inline

Stop Teonet event manager.

Examples:
teocquecpp.cpp.

References ksnetEvMgrStop().

Referenced by event_cb().

void teo::Teonet::subscribe ( const char *  peer_name,
uint16_t  ev 
) const
inline
void teo::Teonet::subscribeA ( const char *  peer_name,
uint16_t  ev 
) const
inline

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