Three bugs related to misplaced memory deallocation were fixed.
Several "smells" were addressed in message, messaging, config
and json source.
Issue-ID: RIC-629
Signed-off-by: E. Scott Daniels <daniels@research.att.com>
Change-Id: Ib2e7d51c96f3b4f88761af6b3058fc32d0005321
19 files changed:
# squished to one.
release = Cherry
# squished to one.
release = Cherry
+2020 20 August; version 2.3.0
+ Address sonar flagged "bugs" in the config class (RIC-629).
+
2020 13 August; version 2.2.2
Correct potential memory leaks in xapp class (RIC-629)
2020 13 August; version 2.2.2
Correct potential memory leaks in xapp class (RIC-629)
cmake_minimum_required( VERSION 3.5 )
set( major_version "2" ) # should be automatically populated from git tag later, but until CI process sets a tag we use this
cmake_minimum_required( VERSION 3.5 )
set( major_version "2" ) # should be automatically populated from git tag later, but until CI process sets a tag we use this
-set( minor_version "2" )
-set( patch_level "2" )
+set( minor_version "3" )
+set( patch_level "0" )
set( install_root "${CMAKE_INSTALL_PREFIX}" )
set( install_inc "include/ricxfcpp" )
set( install_root "${CMAKE_INSTALL_PREFIX}" )
set( install_inc "include/ricxfcpp" )
#include <rmr/RIC_message_types.h>
#ifndef RIC_ALARM
#include <rmr/RIC_message_types.h>
#ifndef RIC_ALARM
+ // this _should_ come from the message types header, but if not ensure we have something
+ constexpr int ric_alarm_value = 110;
+ #define RIC_ALARM ric_alarm_value
#endif
#include <iostream>
#endif
#include <iostream>
#include "message.hpp"
#include "alarm.hpp"
#include "message.hpp"
#include "alarm.hpp"
-extern char* __progname; // runtime lib supplied since we don't get argv[0]
+extern const char* __progname; // runtime lib supplied since we don't get argv[0]
then we assume 4560 (the defacto RMR listen port).
*/
static std::string endpoint_addr( ) {
then we assume 4560 (the defacto RMR listen port).
*/
static std::string endpoint_addr( ) {
- char* et; // environment token
+ const char* et; // environment token
std::string addr = "localhost";
std::string port = "4560";
std::string addr = "localhost";
std::string port = "4560";
Returns the length of the payload inserted.
*/
int xapp::Alarm::build_alarm( int action_id, xapp::Msg_component payload, int payload_len ) {
Returns the length of the payload inserted.
*/
int xapp::Alarm::build_alarm( int action_id, xapp::Msg_component payload, int payload_len ) {
- //char wbuf[4096];
- std::string action;
+ std::string maction; // message action is a text string
int used;
if( app_id.compare( "" ) == 0 ) {
int used;
if( app_id.compare( "" ) == 0 ) {
switch( action_id ) {
case Alarm::ACT_CLEAR:
switch( action_id ) {
case Alarm::ACT_CLEAR:
break;
case Alarm::ACT_CLEAR_ALL:
break;
case Alarm::ACT_CLEAR_ALL:
- //memset( wbuf, 0, sizeof( wbuf ) );
- //snprintf( wbuf, sizeof( wbuf ),
used = snprintf( (char *) payload.get(), payload_len,
"{ "
"\"managedObjectId\": \"%s\", "
used = snprintf( (char *) payload.get(), payload_len,
"{ "
"\"managedObjectId\": \"%s\", "
severity.c_str(),
info.c_str(),
add_info.c_str(),
severity.c_str(),
info.c_str(),
add_info.c_str(),
*/
xapp::Alarm::Alarm( std::shared_ptr<Message> msg ) :
msg( msg ),
*/
xapp::Alarm::Alarm( std::shared_ptr<Message> msg ) :
msg( msg ),
- endpoint( endpoint_addr() ),
- whid( -1 ),
- app_id( "" ),
- me_id( "" ),
- problem_id( -1 ),
- info( "" ),
- add_info( "" ),
- action( "" )
+ endpoint( endpoint_addr() )
{ /* empty body */ }
/*
Parameterised constructor (avoids calling setters after creation).
*/
{ /* empty body */ }
/*
Parameterised constructor (avoids calling setters after creation).
*/
-xapp::Alarm::Alarm( std::shared_ptr<Message> msg, int prob_id, std::string meid ) :
+xapp::Alarm::Alarm( std::shared_ptr<Message> msg, int prob_id, const std::string& meid ) :
msg( msg ),
endpoint( endpoint_addr() ),
msg( msg ),
endpoint( endpoint_addr() ),
- whid( -1 ),
- app_id( "" ),
- problem_id( prob_id ),
- info( "" ),
- add_info( "" ),
- action( "" )
-xapp::Alarm::Alarm( std::shared_ptr<Message> msg, std::string meid ) :
+xapp::Alarm::Alarm( std::shared_ptr<Message> msg, const std::string& meid ) :
msg( msg ),
endpoint( endpoint_addr() ),
msg( msg ),
endpoint( endpoint_addr() ),
- whid( -1 ),
- app_id( "" ),
- me_id( meid ),
- problem_id( -1 ),
- info( "" ),
- add_info( "" ),
- action( "" )
Copy builder. Given a source object instance (soi), create a copy.
Creating a copy should be avoided as it can be SLOW!
*/
Copy builder. Given a source object instance (soi), create a copy.
Creating a copy should be avoided as it can be SLOW!
*/
-xapp::Alarm::Alarm( const Alarm& soi ) {
- msg = soi.msg;
- endpoint = soi.endpoint;
- whid = soi.whid;
-
- me_id = soi.me_id; // user stuff
- app_id = soi.app_id;
- problem_id = soi.problem_id;
- severity = soi.severity;
- info = soi.info;
- add_info = soi.add_info;
-}
+xapp::Alarm::Alarm( const Alarm& soi ) :
+ msg( soi.msg ),
+ endpoint( soi.endpoint ),
+ whid( soi.whid ),
+
+ me_id( soi.me_id ), // user stuff
+ app_id( soi.app_id ),
+ problem_id( soi.problem_id ),
+ severity( soi.severity ),
+ info( soi.info ),
+ add_info( soi.add_info )
+{ /* empty body */ }
/*
Assignment operator. Simiolar to the copycat, but "this" object exists and
/*
Assignment operator. Simiolar to the copycat, but "this" object exists and
msg = soi.msg;
endpoint = soi.endpoint;
whid = soi.whid;
msg = soi.msg;
endpoint = soi.endpoint;
whid = soi.whid;
me_id = soi.me_id;
app_id = soi.app_id;
problem_id = soi.problem_id;
me_id = soi.me_id;
app_id = soi.app_id;
problem_id = soi.problem_id;
the soi ensuring that the destriction of the soi doesn't trash things from
under us.
*/
the soi ensuring that the destriction of the soi doesn't trash things from
under us.
*/
-xapp::Alarm::Alarm( Alarm&& soi ) {
- msg = soi.msg; // capture pointers and copy data before setting soruce things to nil
- endpoint = soi.endpoint;
- whid = soi.whid;
-
- me_id = soi.me_id;
- app_id = soi.app_id;
- problem_id = soi.problem_id;
- severity = soi.severity;
- info = soi.info;
- add_info = soi.add_info;
+xapp::Alarm::Alarm( Alarm&& soi ) :
+ msg( soi.msg ), // order must match .hpp else sonar complains
+ endpoint( soi.endpoint ),
+ whid( soi.whid ),
+ me_id( soi.me_id ),
+ app_id( soi.app_id ),
+ problem_id( soi.problem_id ),
+ severity( soi.severity ),
+ info( soi.info ),
+ add_info( soi.add_info )
+{
soi.msg = NULL; // prevent closing of RMR stuff on soi destroy
}
soi.msg = NULL; // prevent closing of RMR stuff on soi destroy
}
// ---- setters -------------------------------------------------
// ---- setters -------------------------------------------------
-void xapp::Alarm::Set_meid( std::string new_meid ) {
+void xapp::Alarm::Set_meid( const std::string& new_meid ) {
-void xapp::Alarm::Set_appid( std::string new_id ) {
+void xapp::Alarm::Set_appid( const std::string& new_id ) {
-void xapp::Alarm::Set_info( std::string new_info ) {
+void xapp::Alarm::Set_info( const std::string& new_info ) {
-void xapp::Alarm::Set_additional( std::string new_info ) {
+void xapp::Alarm::Set_additional( const std::string& new_info ) {
-void xapp::Alarm::Dump() {
+const void xapp::Alarm::Dump() {
fprintf( stderr, "Alarm: prob id: %d\n", problem_id );
fprintf( stderr, "Alarm: meid: %s\n", me_id.c_str() );
fprintf( stderr, "Alarm: app: %s\n", app_id.c_str() );
fprintf( stderr, "Alarm: prob id: %d\n", problem_id );
fprintf( stderr, "Alarm: meid: %s\n", me_id.c_str() );
fprintf( stderr, "Alarm: app: %s\n", app_id.c_str() );
/*
Return the enpoint address string we have.
*/
/*
Return the enpoint address string we have.
*/
-std::string xapp::Alarm::Get_endpoint( ) {
+const std::string xapp::Alarm::Get_endpoint( ) {
problem ID. Info and addional_info are user supplied data that is just passed
through.
*/
problem ID. Info and addional_info are user supplied data that is just passed
through.
*/
-bool xapp::Alarm::Raise( int severity, int problem, std::string info ) {
- this->severity = severity;
+bool xapp::Alarm::Raise( int new_severity, int problem, const std::string& info ) {
+ Set_severity( new_severity );
problem_id = problem;
this->info = info;
Raise();
}
problem_id = problem;
this->info = info;
Raise();
}
-bool xapp::Alarm::Raise( int severity, int problem, std::string info, std::string additional_info ) {
- this->severity = severity;
+bool xapp::Alarm::Raise( int new_severity, int problem, const std::string& info, const std::string& additional_info ) {
+ Set_severity( new_severity );
problem_id = problem;
this->info = info;
this->add_info = additional_info;
problem_id = problem;
this->info = info;
this->add_info = additional_info;
problem ID. Info and addional_info are user supplied data that is just passed
through.
*/
problem ID. Info and addional_info are user supplied data that is just passed
through.
*/
-bool xapp::Alarm::Clear( int severity, int problem, std::string info ) {
- this->severity = severity;
+bool xapp::Alarm::Clear( int new_severity, int problem, const std::string& info ) {
+ Set_severity( new_severity );
problem_id = problem;
this->info = info;
Clear();
}
problem_id = problem;
this->info = info;
Clear();
}
-bool xapp::Alarm::Clear( int severity, int problem, std::string info, std::string additional_info ) {
- this->severity = severity;
+bool xapp::Alarm::Clear( int new_severity, int problem, const std::string& info, const std::string& additional_info ) {
+ Set_severity( new_severity );
problem_id = problem;
this->info = info;
this->add_info = additional_info;
problem_id = problem;
this->info = info;
this->add_info = additional_info;
private:
std::shared_ptr<Message> msg; // message to send
std::shared_ptr<char> psp; // shared pointer to the payload to give out
private:
std::shared_ptr<Message> msg; // message to send
std::shared_ptr<char> psp; // shared pointer to the payload to give out
- std::string endpoint; // the ip:port addr:port of the alarm collector
- int whid;
+ std::string endpoint = ""; // the ip:port addr:port of the alarm collector
+ int whid = -1;
- std::string me_id; // managed element ID
- std::string app_id; // application ID
- int problem_id; // problem ID (specific problem)
- std::string severity; // SEV_* constants
- std::string action; // ACT_* constants
- std::string info; // info string supplied by user
- std::string add_info; // additional information supplied by user
+ std::string me_id = ""; // managed element ID
+ std::string app_id = ""; // application ID
+ int problem_id = -1; // problem ID (specific problem)
+ std::string severity = ""; // set_sev() xlates from SEV_* consts to collector's string values
+ int action = 0; // ACT_* constants
+ std::string info = ""; // info string supplied by user
+ std::string add_info = ""; // additional information supplied by user
int build_alarm( int action_id, xapp::Msg_component payload, int payload_len );
int build_alarm( int action_id, xapp::Msg_component payload, int payload_len );
static const int ACT_CLEAR_ALL = 3;
Alarm( std::shared_ptr<Message> msg ); // builders
static const int ACT_CLEAR_ALL = 3;
Alarm( std::shared_ptr<Message> msg ); // builders
- Alarm( std::shared_ptr<Message> msg, std::string meid );
- Alarm( std::shared_ptr<Message> msg, int prob_id, std::string meid );
+ Alarm( std::shared_ptr<Message> msg, const std::string& meid );
+ Alarm( std::shared_ptr<Message> msg, int prob_id, const std::string& meid );
Alarm( const Alarm& soi ); // copy to newly created instance
Alarm& operator=( const Alarm& soi ); // copy operator
Alarm( const Alarm& soi ); // copy to newly created instance
Alarm& operator=( const Alarm& soi ); // copy operator
- std::string Get_endpoint( );
+ const std::string Get_endpoint( );
- void Set_additional( std::string new_info );
- void Set_appid( std::string new_id );
- void Set_info( std::string new_info );
- void Set_meid( std::string new_meid );
+ void Set_additional( const std::string& new_info );
+ void Set_appid( const std::string& new_id );
+ void Set_info( const std::string& new_info );
+ void Set_meid( const std::string& new_meid );
void Set_problem( int new_id );
void Set_severity( int new_sev );
void Set_whid( int whid );
bool Raise( );
void Set_problem( int new_id );
void Set_severity( int new_sev );
void Set_whid( int whid );
bool Raise( );
- bool Raise( int severity, int problem, std::string info );
- bool Raise( int severity, int problem, std::string info, std::string addional_info );
+ bool Raise( int severity, int problem, const std::string& info );
+ bool Raise( int severity, int problem, const std::string& info, const std::string& additional_info );
bool Raise_again( );
bool Clear( );
bool Raise_again( );
bool Clear( );
- bool Clear( int severity, int problem, std::string info );
- bool Clear( int severity, int problem, std::string info, std::string addional_info );
+ bool Clear( int severity, int problem, const std::string& info );
+ bool Clear( int severity, int problem, const std::string& info, const std::string& additional_info );
and not directory entries.
*/
void xapp::Config::Listener( ) {
and not directory entries.
*/
void xapp::Config::Listener( ) {
- struct inotify_event* ie; // event that popped
+ const struct inotify_event* ie; // event that popped
int ifd; // the inotify file des
int wfd; // the watched file des
int ifd; // the inotify file des
int wfd; // the watched file des
char rbuf[4096]; // large read buffer as the event is var len
char* dname; // directory name
char* bname; // basename
char rbuf[4096]; // large read buffer as the event is var len
char* dname; // directory name
char* bname; // basename
bname = strdup( fname.c_str() );
}
bname = strdup( fname.c_str() );
}
- wfd = inotify_add_watch( ifd, (char *) dname, IN_MOVED_TO | IN_CLOSE_WRITE ); // we only care about close write changes
+ wfd = inotify_add_watch( ifd, dname, IN_MOVED_TO | IN_CLOSE_WRITE ); // we only care about close write changes
+ free( dname );
if( wfd < 0 ) {
fprintf( stderr, "<XFCPP> ### ERR ### unable to add watch on config file %s: %s\n", fname.c_str(), strerror( errno ) );
if( wfd < 0 ) {
fprintf( stderr, "<XFCPP> ### ERR ### unable to add watch on config file %s: %s\n", fname.c_str(), strerror( errno ) );
ie = (inotify_event *) rbuf;
if( ie->len > 0 && strcmp( bname, ie->name ) == 0 ) {
ie = (inotify_event *) rbuf;
if( ie->len > 0 && strcmp( bname, ie->name ) == 0 ) {
auto njh = jparse( fname ); // reparse the file
auto njh = jparse( fname ); // reparse the file
if( njh != NULL && cb != NULL ) { // good parse, save and drive user callback
jh = njh;
if( njh != NULL && cb != NULL ) { // good parse, save and drive user callback
jh = njh;
-
- free( dname );
- free( bname );
if it's a directory name or not if it comes to it.
*/
std::shared_ptr<xapp::Jhash> xapp::Config::jparse( ) {
if it's a directory name or not if it comes to it.
*/
std::shared_ptr<xapp::Jhash> xapp::Config::jparse( ) {
- if( (data = getenv( (char *) "XAPP_DESCRIPTOR_PATH" )) == NULL ) {
- data = (char *) "./config-file.json";
+ if( (data = getenv( (const char *) "XAPP_DESCRIPTOR_PATH" )) == NULL ) {
+ data = (const char *) "./config-file.json";
}
return jparse( std::string( data ) );
}
return jparse( std::string( data ) );
the common things should be fairly painless to extract from the json goop.
*/
xapp::Config::Config() :
the common things should be fairly painless to extract from the json goop.
*/
xapp::Config::Config() :
- jh( jparse() ),
- listener( NULL )
{ /* empty body */ }
/*
Similar, except that it allows the xAPP to supply the filename (testing?)
*/
{ /* empty body */ }
/*
Similar, except that it allows the xAPP to supply the filename (testing?)
*/
-xapp::Config::Config( std::string fname) :
- jh( jparse( fname ) ),
- listener( NULL )
+xapp::Config::Config( const std::string& fname) :
+ jh( jparse( fname ) )
Read and return the raw file blob as a single string. User can parse, or do
whatever they need (allows non-json things if necessary).
*/
Read and return the raw file blob as a single string. User can parse, or do
whatever they need (allows non-json things if necessary).
*/
-std::string xapp::Config::Get_contents( ) {
+std::string xapp::Config::Get_contents( ) const {
std::string rv = "";
if( ! fname.empty() ) {
std::string rv = "";
if( ! fname.empty() ) {
Suss out the port for the named "interface". The interface is likely the application
name.
*/
Suss out the port for the named "interface". The interface is likely the application
name.
*/
-std::string xapp::Config::Get_port( std::string name ) {
+std::string xapp::Config::Get_port( const std::string& name ) const {
int i;
int nele = 0;
double value;
int i;
int nele = 0;
double value;
- if( jh->Set_blob( (char *) "messaging" ) ) {
- nele = jh->Array_len( (char *) "ports" );
+ if( jh->Set_blob( (const char *) "messaging" ) ) {
+ nele = jh->Array_len( (const char *) "ports" );
for( i = 0; i < nele; i++ ) {
for( i = 0; i < nele; i++ ) {
- if( jh->Set_blob_ele( (char *) "ports", i ) ) {
- pname = jh->String( (char *) "name" );
+ if( jh->Set_blob_ele( (const char *) "ports", i ) ) {
+ pname = jh->String( (const char *) "name" );
if( pname.compare( name ) == 0 ) { // this element matches the name passed in
if( pname.compare( name ) == 0 ) { // this element matches the name passed in
- value = jh->Value( (char *) "port" );
+ value = jh->Value( (const char *) "port" );
rv = std::to_string( (int) value );
jh->Unset_blob( ); // leave hash in a known state
return rv;
rv = std::to_string( (int) value );
jh->Unset_blob( ); // leave hash in a known state
return rv;
}
jh->Unset_blob( ); // Jhash requires bump to root, and array reselct to move to next ele
}
jh->Unset_blob( ); // Jhash requires bump to root, and array reselct to move to next ele
- jh->Set_blob( (char *) "messaging" );
+ jh->Set_blob( (const char *) "messaging" );
Suss out the named string from the controls object. If the resulting value is
missing or "", then the default is returned.
*/
Suss out the named string from the controls object. If the resulting value is
missing or "", then the default is returned.
*/
-std::string xapp::Config::Get_control_str( std::string name, std::string defval ) {
+std::string xapp::Config::Get_control_str( const std::string& name, const std::string& defval ) const {
std::string value;
std::string rv; // result value
std::string value;
std::string rv; // result value
- if( jh->Set_blob( (char *) "controls" ) ) {
+ if( jh->Set_blob( (const char *) "controls" ) ) {
if( jh->Exists( name.c_str() ) ) {
value = jh->String( name.c_str() );
if( value.compare( "" ) != 0 ) {
if( jh->Exists( name.c_str() ) ) {
value = jh->String( name.c_str() );
if( value.compare( "" ) != 0 ) {
Convenience funciton without default. "" returned if not found.
No default value; returns "" if not set.
*/
Convenience funciton without default. "" returned if not found.
No default value; returns "" if not set.
*/
-std::string xapp::Config::Get_control_str( std::string name ) {
+std::string xapp::Config::Get_control_str( const std::string& name ) const {
return Get_control_str( name, "" );
}
return Get_control_str( name, "" );
}
Suss out the named field from the controls object with the assumption that it is a boolean.
If the resulting value is missing then the defval is used.
*/
Suss out the named field from the controls object with the assumption that it is a boolean.
If the resulting value is missing then the defval is used.
*/
-bool xapp::Config::Get_control_bool( std::string name, bool defval ) {
- bool value;
+bool xapp::Config::Get_control_bool( const std::string& name, bool defval ) const {
bool rv; // result value
rv = defval;
bool rv; // result value
rv = defval;
- if( jh->Set_blob( (char *) "controls" ) ) {
- if( jh->Exists( name.c_str() ) ) {
- rv = jh->Bool( name.c_str() );
- }
+ if( jh->Set_blob( (const char *) "controls" ) && jh->Exists( name.c_str() ) ) {
+ rv = jh->Bool( name.c_str() );
/*
Convenience function without default.
*/
/*
Convenience function without default.
*/
-bool xapp::Config::Get_control_bool( std::string name ) {
+bool xapp::Config::Get_control_bool( const std::string& name ) const {
return Get_control_bool( name, false );
}
return Get_control_bool( name, false );
}
Suss out the named field from the controls object with the assumption that it is a value (float/int).
If the resulting value is missing then the defval is used.
*/
Suss out the named field from the controls object with the assumption that it is a value (float/int).
If the resulting value is missing then the defval is used.
*/
-double xapp::Config::Get_control_value( std::string name, double defval ) {
- double value;
+double xapp::Config::Get_control_value( const std::string& name, double defval ) const {
auto rv = defval; // return value; set to default
if( jh == NULL ) {
auto rv = defval; // return value; set to default
if( jh == NULL ) {
- if( jh->Set_blob( (char *) "controls" ) ) {
- if( jh->Exists( name.c_str() ) ) {
- rv = jh->Value( name.c_str() );
- }
+ if( jh->Set_blob( (const char *) "controls" ) && jh->Exists( name.c_str() ) ) {
+ rv = jh->Value( name.c_str() );
/*
Convenience function. If value is undefined, then 0 is returned.
*/
/*
Convenience function. If value is undefined, then 0 is returned.
*/
-double xapp::Config::Get_control_value( std::string name ) {
+double xapp::Config::Get_control_value( const std::string& name ) const {
return Get_control_value( name, 0.0 );
}
return Get_control_value( name, 0.0 );
}
#define MAX_PFNAME (4096 + 256) // max path name and max filname + nil for buffer allocation
class Config {
#define MAX_PFNAME (4096 + 256) // max path name and max filname + nil for buffer allocation
class Config {
- std::string fname; // the file name that we'll listen to
- std::thread* listener; // listener thread info
+ std::string fname = ""; // the file name that we'll listen to
+ std::thread* listener = NULL; // listener thread info
- std::shared_ptr<Jhash> jh; // the currently parsed json from the config
- std::unique_ptr<Config_cb> cb; // info needed to drive user code when config change noticed
- void* user_cb_data; // data that the caller wants passed on notification callback
+ std::shared_ptr<Jhash> jh = NULL; // the currently parsed json from the config
+ std::unique_ptr<Config_cb> cb = NULL; // info needed to drive user code when config change noticed
+ void* user_cb_data = NULL; // data that the caller wants passed on notification callback
// -----------------------------------------------------------------------
private:
// -----------------------------------------------------------------------
private:
public:
Config(); // builders
public:
Config(); // builders
- Config( std::string fname);
+ Config( const std::string& fname);
- bool Get_control_bool( std::string name, bool defval );
- bool Get_control_bool( std::string name );
+ bool Get_control_bool( const std::string& name, bool defval ) const;
+ bool Get_control_bool( const std::string& name ) const;
- std::string Get_contents( );
+ std::string Get_contents( ) const;
- std::string Get_control_str( std::string name, std::string defval );
- std::string Get_control_str( std::string name );
+ std::string Get_control_str( const std::string& name, const std::string& defval ) const;
+ std::string Get_control_str( const std::string& name ) const;
- double Get_control_value( std::string name, double defval );
- double Get_control_value( std::string name );
+ double Get_control_value( const std::string& name, double defval ) const;
+ double Get_control_value( const std::string& name ) const;
- std::string Get_port( std::string name );
+ std::string Get_port( const std::string& name ) const;
void Set_callback( notify_callback usr_func, void* usr_data );
};
void Set_callback( notify_callback usr_func, void* usr_data );
};
-Config_cb::Config_cb( notify_callback ufun, void* udata ) :
+Config_cb::Config_cb( notify_callback ufun, void* user_data ) :
/*
Drive_cb will invoke the callback and pass along the stuff passed here.
/*
Drive_cb will invoke the callback and pass along the stuff passed here.
+ User_data may be nil which causes the data registered with the callback
+ to be used.
-void xapp::Config_cb::Drive_cb( xapp::Config& c, void* udata ) {
+void xapp::Config_cb::Drive_cb( xapp::Config& c, void* user_data ) const {
+ user_fun( c, user_data == NULL ? udata : user_data );
public:
Config_cb( notify_callback cbfun, void* user_data ); // builder
public:
Config_cb( notify_callback cbfun, void* user_data ); // builder
- void Drive_cb( xapp::Config& c, void* udata ); // invoker
+ void Drive_cb( xapp::Config& c, void* user_data ) const; // invokers
suss out the values.
*/
xapp::Jhash::Jhash( const char* jbuf ) :
suss out the values.
*/
xapp::Jhash::Jhash( const char* jbuf ) :
st( jw_new( jbuf ) )
{ /* empty body */ }
st( jw_new( jbuf ) )
{ /* empty body */ }
-Jhash::Jhash( Jhash&& soi ) {
- master_st = soi.master_st;
- st = soi.st;
-
+Jhash::Jhash( Jhash&& soi ) :
+ master_st( soi.master_st ),
+ st( soi.st )
+{
soi.st = NULL; // prevent closing of RMR stuff on soi destroy
soi.master_st = NULL;
}
soi.st = NULL; // prevent closing of RMR stuff on soi destroy
soi.master_st = NULL;
}
Right now we don't have much to work with other than checking for a
nil table.
*/
Right now we don't have much to work with other than checking for a
nil table.
*/
-bool xapp::Jhash::Parse_errors( ) {
+const bool xapp::Jhash::Parse_errors( ) {
*/
std::string xapp::Jhash::String( const char* name ) {
std::string rv = "";
*/
std::string xapp::Jhash::String( const char* name ) {
std::string rv = "";
if( (hashv = jw_string( st, name )) != NULL ) {
rv = std::string( hashv );
if( (hashv = jw_string( st, name )) != NULL ) {
rv = std::string( hashv );
*/
std::string xapp::Jhash::String_ele( const char* name, int eidx ) {
std::string rv = "";
*/
std::string xapp::Jhash::String_ele( const char* name, int eidx ) {
std::string rv = "";
if( (hashv = jw_string_ele( st, name, eidx )) != NULL ) {
rv = std::string( hashv );
if( (hashv = jw_string_ele( st, name, eidx )) != NULL ) {
rv = std::string( hashv );
- void* st; // the resulting symbol table generated by parse
- void* master_st; // if user switches to a sub-blob; this tracks the original root st
+ void* st = NULL; // the resulting symbol table generated by parse
+ void* master_st = NULL; // if user switches to a sub-blob; this tracks the original root st
Jhash& operator=( const Jhash& soi ); // jhashes cannot be copied because of underlying symbol table goo
Jhash( const Jhash& soi );
Jhash& operator=( const Jhash& soi ); // jhashes cannot be copied because of underlying symbol table goo
Jhash( const Jhash& soi );
void Unset_blob( );
bool Set_blob_ele( const char* name, int eidx ); // set from an array element
void Unset_blob( );
bool Set_blob_ele( const char* name, int eidx ); // set from an array element
+ const bool Parse_errors( );
void Dump();
std::string String( const char* name ); // value fetching
void Dump();
std::string String( const char* name ); // value fetching
we don't create a bunch of small buffers that must be found and freed; we
can just release the json string and we'll be done (read won't leak).
*/
we don't create a bunch of small buffers that must be found and freed; we
can just release the json string and we'll be done (read won't leak).
*/
-static char* extract( char* buf, jsmntok_t *jtoken ) {
+static char* extract( char* buf, const jsmntok_t *jtoken ) {
buf[jtoken->end] = 0;
return &buf[jtoken->start];
}
buf[jtoken->end] = 0;
return &buf[jtoken->start];
}
if( (jtp = suss_array( st, name )) != NULL // have pointer
&& idx >= 0 // and in range
&& idx < jtp->nele
if( (jtp = suss_array( st, name )) != NULL // have pointer
&& idx >= 0 // and in range
&& idx < jtp->nele
- && (jarray = jtp->v.pv) != NULL ) { // and exists
-
+ && jtp->v.pv != NULL ) { // and exists
+ jarray = jtp->v.pv;
Only the element passed is used, but this is a prototype which is required by
the RMR symtab implementaion, so we play games in the code to keep sonar quiet.
Only the element passed is used, but this is a prototype which is required by
the RMR symtab implementaion, so we play games in the code to keep sonar quiet.
+
+
+ Sonar will grumble aobut the parms needing to be marked const. Until RMR changes
+ the signature we can't and sonar will just have to unbunch its knickers.
*/
static void nix_things( void* st, void* se, const char* name, void* ele, void *data ) {
jthing_t* j;
*/
static void nix_things( void* st, void* se, const char* name, void* ele, void *data ) {
jthing_t* j;
Silly games played to keep sonar from complaining. This is driven by RMR
symtab code which defines the set of params and we use what we need.
Silly games played to keep sonar from complaining. This is driven by RMR
symtab code which defines the set of params and we use what we need.
+
+ Sonar will grumble aobut the parms needing to be marked const. Until RMR changes
+ the signature we can't and sonar will just have to unbunch its knickers.
*/
static void nix_mgt( void* st, void* se, const char* name, void* ele, void *data ) {
*/
static void nix_mgt( void* st, void* se, const char* name, void* ele, void *data ) {
/*
Invoked for each thing and prints what we can to stderr.
Most parms ignored, but symtab code in RMR defines the prototype so they are required.
/*
Invoked for each thing and prints what we can to stderr.
Most parms ignored, but symtab code in RMR defines the prototype so they are required.
+
+ Sonar will grumble aobut the parms needing to be marked const. Until RMR changes
+ the signature we can't and sonar will just have to unbunch its knickers.
*/
static void dump_things( void* st, void* se, const char* name, void* ele, void *data ) {
const jthing_t* j;
*/
static void dump_things( void* st, void* se, const char* name, void* ele, void *data ) {
const jthing_t* j;
char *data; // data string from the json
jthing_t* jarray; // array of jthings we'll coonstruct
int size;
char *data; // data string from the json
jthing_t* jarray; // array of jthings we'll coonstruct
int size;
int njtokens; // tokens actually sussed out
jsmn_parser jp; // 'parser' object
jsmntok_t *jtokens; // pointer to tokens returned by the parser
char pname[1024]; // name with prefix
int njtokens; // tokens actually sussed out
jsmn_parser jp; // 'parser' object
jsmntok_t *jtokens; // pointer to tokens returned by the parser
char pname[1024]; // name with prefix
- char wbuf[256]; // temp buf to build a working name in
char* dstr; // dup'd string
int step = 0; // parsing step value to skip tokens picked up
int data_idx; // index into tokens for the next bit of data
char* dstr; // dup'd string
int step = 0; // parsing step value to skip tokens picked up
int data_idx; // index into tokens for the next bit of data
case JSMN_OBJECT: // save object in two ways: as an object 'blob' and in the current symtab using name as a base (original)
if( DEBUG ) fprintf( stderr, "<DBUG> [%d] %s (object) has %d things\n", data_idx, name, jtokens[data_idx].size );
case JSMN_OBJECT: // save object in two ways: as an object 'blob' and in the current symtab using name as a base (original)
if( DEBUG ) fprintf( stderr, "<DBUG> [%d] %s (object) has %d things\n", data_idx, name, jtokens[data_idx].size );
- if( (jtp = mk_thing( st, name, jtokens[data_idx].type )) != NULL && // create thing and reference it in current symtab
- (jtp->v.pv = (void *) rmr_sym_alloc( 255 ) ) != NULL ) { // object is just a blob
+ if( (jtp = mk_thing( st, name, jtokens[data_idx].type )) != NULL ) { // create thing and reference it
+ jtp->v.pv = rmr_sym_alloc( 255 ); // object is just a blob; make it
+ }
+ if( jtp != NULL && jtp->v.pv != NULL ) { // double check allows for better coverage and keeps sonar happy
dstr = strdup( extract( json, &jtokens[data_idx] ) );
rmr_sym_put( jtp->v.pv, JSON_SYM_NAME, MGT_SPACE, dstr ); // must stash json so it is freed during nuke()
parse_jobject( jtp->v.pv, dstr, "" ); // recurse across the object and build a new symtab
dstr = strdup( extract( json, &jtokens[data_idx] ) );
rmr_sym_put( jtp->v.pv, JSON_SYM_NAME, MGT_SPACE, dstr ); // must stash json so it is freed during nuke()
parse_jobject( jtp->v.pv, dstr, "" ); // recurse across the object and build a new symtab
switch( jtokens[data_idx].type ) {
case JSMN_OBJECT:
switch( jtokens[data_idx].type ) {
case JSMN_OBJECT:
- jarray[n].v.pv = (void *) rmr_sym_alloc( 255 );
+ jarray[n].v.pv = rmr_sym_alloc( 255 );
if( DEBUG ) fprintf( stderr, "<DBUG> %s[%d] is object size=%d\n", name, n, jtokens[data_idx].size );
if( jarray[n].v.pv != NULL ) {
jarray[n].jsmn_type = JSMN_OBJECT;
if( DEBUG ) fprintf( stderr, "<DBUG> %s[%d] is object size=%d\n", name, n, jtokens[data_idx].size );
if( jarray[n].v.pv != NULL ) {
jarray[n].jsmn_type = JSMN_OBJECT;
-Callback::Callback( user_callback ufun, void* data ) { // builder
- user_fun = ufun;
- udata = data;
-}
+Callback::Callback( user_callback ufun, void* data ) : // builder
+ user_fun( ufun ),
+ udata( data )
+{ /* empty body */ }
/*
there is nothing to be done from a destruction perspective, so no
/*
there is nothing to be done from a destruction perspective, so no
*/
void xapp::Callback::Drive_cb( Message& m ) {
if( user_fun != NULL ) {
*/
void xapp::Callback::Drive_cb( Message& m ) {
if( user_fun != NULL ) {
- user_fun( m, m.Get_mtype(), m.Get_subid(), m.Get_len(), m.Get_payload(), udata );
+ user_fun( m, m.Get_mtype(), m.Get_subid(), m.Get_len(), m.Get_payload(), udata );
void* udata; // user data
public:
void* udata; // user data
public:
- Callback( user_callback, void* data ); // builder
- void Drive_cb( Message& m ); // invoker
+ Callback( user_callback, void* data ); // builder
+ void Drive_cb( Message& m ); // invoker
The mr paramter is obviously ignored, but to add this as a callback
the function sig must match.
The mr paramter is obviously ignored, but to add this as a callback
the function sig must match.
+
+ This is a callback function; sonar will complain that we don't use payload or
+ data -- we don't, but this is a standard function proto so we cannot just
+ drop them.
*/
void Health_ck_cb( Message& mbuf, int mtype, int sid, int len, Msg_component payload, void* data ) {
unsigned char response[128];
*/
void Health_ck_cb( Message& mbuf, int mtype, int sid, int len, Msg_component payload, void* data ) {
unsigned char response[128];
+ if( len < 0 || mtype < 0 ) {
+ return;
+ }
+
snprintf( (char* ) response, sizeof( response ), "OK\n" );
mbuf.Send_response( RIC_HEALTH_CHECK_RESP, sid, strlen( (char *) response )+1, response );
}
snprintf( (char* ) response, sizeof( response ), "OK\n" );
mbuf.Send_response( RIC_HEALTH_CHECK_RESP, sid, strlen( (char *) response )+1, response );
}
/*
Create a new message wrapper for an existing RMR msg buffer.
*/
/*
Create a new message wrapper for an existing RMR msg buffer.
*/
-xapp::Message::Message( rmr_mbuf_t* mbuf, void* mrc ) {
- this->mrc = mrc; // the message router context for sends
- this->mbuf = mbuf;
-}
-
-xapp::Message::Message( void* mrc, int payload_len ) {
- this->mrc = mrc;
- this->mbuf = rmr_alloc_msg( mrc, payload_len );
-}
+xapp::Message::Message( rmr_mbuf_t* mbuf, void* mrc ) :
+ mrc( mrc ), // the message router context for sends
+ mbuf( mbuf )
+{ /* empty body */ }
+
+xapp::Message::Message( void* mrctx, int payload_len ) :
+ mrc( mrctx ), // the message router context for sends
+ mbuf( rmr_alloc_msg( mrc, payload_len ) )
+{ /* empty body */ }
+// this->mrc = mrc;
+ //this->mbuf = rmr_alloc_msg( mrc, payload_len );
/*
Copy builder. Given a source object instance (soi), create a copy.
Creating a copy should be avoided as it can be SLOW!
*/
/*
Copy builder. Given a source object instance (soi), create a copy.
Creating a copy should be avoided as it can be SLOW!
*/
-xapp::Message::Message( const Message& soi ) {
+xapp::Message::Message( const Message& soi ) :
+ mrc( soi.mrc )
+{
payload_size = rmr_payload_size( soi.mbuf ); // rmr can handle a nil pointer
mbuf = rmr_realloc_payload( soi.mbuf, payload_size, RMR_COPY, RMR_CLONE );
}
payload_size = rmr_payload_size( soi.mbuf ); // rmr can handle a nil pointer
mbuf = rmr_realloc_payload( soi.mbuf, payload_size, RMR_COPY, RMR_CLONE );
}
the soi ensuring that the destriction of the soi doesn't trash things from
under us.
*/
the soi ensuring that the destriction of the soi doesn't trash things from
under us.
*/
-xapp::Message::Message( Message&& soi ) {
- mrc = soi.mrc;
- mbuf = soi.mbuf;
-
+xapp::Message::Message( Message&& soi ) :
+ mrc( soi.mrc ),
+ mbuf( soi.mbuf )
+{
soi.mrc = NULL; // prevent closing of RMR stuff on soi destroy
soi.mbuf = NULL;
}
soi.mrc = NULL; // prevent closing of RMR stuff on soi destroy
soi.mbuf = NULL;
}
/*
Makes a copy of the MEID and returns a smart pointer to it.
*/
/*
Makes a copy of the MEID and returns a smart pointer to it.
*/
-std::unique_ptr<unsigned char> xapp::Message::Get_meid(){
+std::unique_ptr<unsigned char> xapp::Message::Get_meid() const {
unsigned char* m = NULL;
m = (unsigned char *) malloc( sizeof( unsigned char ) * RMR_MAX_MEID );
unsigned char* m = NULL;
m = (unsigned char *) malloc( sizeof( unsigned char ) * RMR_MAX_MEID );
If mbuf isn't valid (nil, or message has a broken header) the return
will be -1.
*/
If mbuf isn't valid (nil, or message has a broken header) the return
will be -1.
*/
-int xapp::Message::Get_available_size(){
+int xapp::Message::Get_available_size() const {
return rmr_payload_size( mbuf ); // rmr can handle a nil pointer
}
return rmr_payload_size( mbuf ); // rmr can handle a nil pointer
}
-int xapp::Message::Get_mtype(){
+int xapp::Message::Get_mtype() const {
int rval = INVALID_MTYPE;
if( mbuf != NULL ) {
int rval = INVALID_MTYPE;
if( mbuf != NULL ) {
/*
Makes a copy of the source field and returns a smart pointer to it.
*/
/*
Makes a copy of the source field and returns a smart pointer to it.
*/
-std::unique_ptr<unsigned char> xapp::Message::Get_src(){
- unsigned char* m = new unsigned char[RMR_MAX_SRC];
+std::unique_ptr<unsigned char> xapp::Message::Get_src() const {
+ unsigned char* m = new unsigned char[RMR_MAX_SRC];
if( m != NULL ) {
rmr_get_src( mbuf, m );
if( m != NULL ) {
rmr_get_src( mbuf, m );
return std::unique_ptr<unsigned char>( m );
}
return std::unique_ptr<unsigned char>( m );
}
-int xapp::Message::Get_state( ){
+int xapp::Message::Get_state( ) const {
int state = INVALID_STATUS;
if( mbuf != NULL ) {
int state = INVALID_STATUS;
if( mbuf != NULL ) {
-int xapp::Message::Get_subid(){
+int xapp::Message::Get_subid() const {
int rval = INVALID_SUBID;
if( mbuf != NULL ) {
int rval = INVALID_SUBID;
if( mbuf != NULL ) {
Return the amount of the payload (bytes) which is used. See
Get_available_size() to get the total usable space in the payload.
*/
Return the amount of the payload (bytes) which is used. See
Get_available_size() to get the total usable space in the payload.
*/
-int xapp::Message::Get_len(){
+int xapp::Message::Get_len() const {
int rval = 0;
if( mbuf != NULL ) {
int rval = 0;
if( mbuf != NULL ) {
length by calling Message:Get_available_size(), and ensuring that
writing beyond the indicated size does not happen.
*/
length by calling Message:Get_available_size(), and ensuring that
writing beyond the indicated size does not happen.
*/
-Msg_component xapp::Message::Get_payload(){
+Msg_component xapp::Message::Get_payload() const {
if( mbuf != NULL ) {
return std::unique_ptr<unsigned char, unfreeable>( mbuf->payload );
}
if( mbuf != NULL ) {
return std::unique_ptr<unsigned char, unfreeable>( mbuf->payload );
}
void xapp::Message::Set_meid( std::shared_ptr<unsigned char> new_meid ) {
if( mbuf != NULL ) {
void xapp::Message::Set_meid( std::shared_ptr<unsigned char> new_meid ) {
if( mbuf != NULL ) {
- rmr_str2meid( mbuf, (unsigned char *) new_meid.get() );
+ rmr_str2meid( mbuf, new_meid.get() );
case WORMHOLE_MSG:
mbuf = rmr_wh_send_msg( mrc, whid, mbuf );
break;
case WORMHOLE_MSG:
mbuf = rmr_wh_send_msg( mrc, whid, mbuf );
break;
+
+ default:
+ break; // because sonar doesn't like defaultless switches even when there is no work :(
}
state = mbuf->state == RMR_OK;
}
state = mbuf->state == RMR_OK;
std::unique_ptr<unsigned char> Copy_payload( ); // copy the payload; deletable smart pointer
std::unique_ptr<unsigned char> Copy_payload( ); // copy the payload; deletable smart pointer
- std::unique_ptr<unsigned char> Get_meid(); // returns a copy of the meid bytes
- int Get_available_size();
- int Get_len();
- int Get_mtype();
- Msg_component Get_payload();
- std::unique_ptr<unsigned char> Get_src();
- int Get_state( );
- int Get_subid();
+ std::unique_ptr<unsigned char> Get_meid() const; // returns a copy of the meid bytes
+ int Get_available_size() const;
+ int Get_len() const;
+ int Get_mtype() const;
+ Msg_component Get_payload() const;
+ std::unique_ptr<unsigned char> Get_src() const;
+ int Get_state( ) const;
+ int Get_subid() const;
void Set_meid( std::shared_ptr<unsigned char> new_meid );
void Set_mtype( int new_type );
void Set_meid( std::shared_ptr<unsigned char> new_meid );
void Set_mtype( int new_type );
the new object, and then DELETE what was moved so that when the
user frees the soi, it doesn't destroy what we snarfed.
*/
the new object, and then DELETE what was moved so that when the
user frees the soi, it doesn't destroy what we snarfed.
*/
-xapp::Messenger::Messenger( Messenger&& soi ) {
- mrc = soi.mrc;
- listen_port = soi.listen_port;
- ok_2_run = soi.ok_2_run;
- gate = soi.gate;
- cb_hash = soi.cb_hash; // this seems dodgy
-
+xapp::Messenger::Messenger( Messenger&& soi ) :
+ mrc( soi.mrc ),
+ listen_port( soi.listen_port ),
+ ok_2_run( soi.ok_2_run ),
+ gate( soi.gate ),
+ cb_hash( soi.cb_hash ) // this seems dodgy
+{
soi.gate = NULL;
soi.listen_port = NULL;
soi.mrc = NULL;
soi.gate = NULL;
soi.listen_port = NULL;
soi.mrc = NULL;
rmr_close( mrc );
}
if( listen_port != NULL ) {
rmr_close( mrc );
}
if( listen_port != NULL ) {
}
if( listen_port != NULL ) {
}
if( listen_port != NULL ) {
message is received. The user may pass an optional data pointer which
will be passed to the function when it is called. The function signature
must be:
message is received. The user may pass an optional data pointer which
will be passed to the function when it is called. The function signature
must be:
- void fun( Messenger* mr, rmr_mbuf_t* mbuf, void* data );
+ void fun( Messenger* mr, rmr_mbuf_t* mbuf, void* data )
The user can also invoke this function to set the "default" callback by
passing Messenger::DEFAULT_CALLBACK as the mtype. If no other callback
The user can also invoke this function to set the "default" callback by
passing Messenger::DEFAULT_CALLBACK as the mtype. If no other callback
just a message, but to avoid having the user pass the framework
object in, we'll just supply a "factory" function.
*/
just a message, but to avoid having the user pass the framework
object in, we'll just supply a "factory" function.
*/
-std::unique_ptr<xapp::Alarm> xapp::Messenger::Alloc_alarm( int prob_id, std::string meid ) {
+std::unique_ptr<xapp::Alarm> xapp::Messenger::Alloc_alarm( int prob_id, const std::string& meid ) {
std::shared_ptr<Message> m;
Alarm* a;
std::shared_ptr<Message> m;
Alarm* a;
return std::unique_ptr<Alarm>( a );
}
return std::unique_ptr<Alarm>( a );
}
-std::unique_ptr<xapp::Alarm> xapp::Messenger::Alloc_alarm( std::string meid ) {
+std::unique_ptr<xapp::Alarm> xapp::Messenger::Alloc_alarm( const std::string& meid ) {
return Alloc_alarm( -1, meid );
}
return Alloc_alarm( -1, meid );
}
return std::unique_ptr<xapp::Metrics>( new xapp::Metrics( m ) );
}
return std::unique_ptr<xapp::Metrics>( new xapp::Metrics( m ) );
}
-std::unique_ptr<xapp::Metrics> xapp::Messenger::Alloc_metrics( std::string source ) {
+std::unique_ptr<xapp::Metrics> xapp::Messenger::Alloc_metrics( const std::string& source ) {
std::shared_ptr<Message> m;
m = Alloc_msg( 4096 );
return std::unique_ptr<xapp::Metrics>( new xapp::Metrics( m, source ) );
}
std::shared_ptr<Message> m;
m = Alloc_msg( 4096 );
return std::unique_ptr<xapp::Metrics>( new xapp::Metrics( m, source ) );
}
-std::unique_ptr<xapp::Metrics> xapp::Messenger::Alloc_metrics( std::string reporter, std::string source ) {
+std::unique_ptr<xapp::Metrics> xapp::Messenger::Alloc_metrics( const std::string& reporter, const std::string& source ) {
std::shared_ptr<Message> m;
m = Alloc_msg( 4096 );
std::shared_ptr<Message> m;
m = Alloc_msg( 4096 );
Concurrently executing listeners are allowed.
*/
void xapp::Messenger::Listen( ) {
Concurrently executing listeners are allowed.
*/
void xapp::Messenger::Listen( ) {
rmr_mbuf_t* mbuf = NULL;
std::map<int,Callback*>::iterator mi; // map iterator; silly indirect way to point at the value
Callback* dcb = NULL; // default callback so we don't search
rmr_mbuf_t* mbuf = NULL;
std::map<int,Callback*>::iterator mi; // map iterator; silly indirect way to point at the value
Callback* dcb = NULL; // default callback so we don't search
/*
Open a wormhole to the indicated endpoint and return the wormhole ID.
*/
/*
Open a wormhole to the indicated endpoint and return the wormhole ID.
*/
-int xapp::Messenger::Wormhole_open( std::string endpoint ) {
+int xapp::Messenger::Wormhole_open( const std::string& endpoint ) {
rmr_whid_t whid;
whid = rmr_wh_open( mrc, endpoint.c_str() );
rmr_whid_t whid;
whid = rmr_wh_open( mrc, endpoint.c_str() );
std::unique_ptr<Message> Alloc_msg( int payload_size ); // message allocation
std::unique_ptr<xapp::Alarm> Alloc_alarm( ); // alarm allocation
std::unique_ptr<Message> Alloc_msg( int payload_size ); // message allocation
std::unique_ptr<xapp::Alarm> Alloc_alarm( ); // alarm allocation
- std::unique_ptr<xapp::Alarm> Alloc_alarm( std::string meid );
- std::unique_ptr<xapp::Alarm> Alloc_alarm( int prob_id, std::string meid );
+ std::unique_ptr<xapp::Alarm> Alloc_alarm( const std::string& meid );
+ std::unique_ptr<xapp::Alarm> Alloc_alarm( int prob_id, const std::string& meid );
std::unique_ptr<xapp::Metrics> Alloc_metrics( ); // metrics allocation
std::unique_ptr<xapp::Metrics> Alloc_metrics( ); // metrics allocation
- std::unique_ptr<xapp::Metrics> Alloc_metrics( std::string source );
- std::unique_ptr<xapp::Metrics> Alloc_metrics( std::string reporter, std::string source );
+ std::unique_ptr<xapp::Metrics> Alloc_metrics( const std::string& source );
+ std::unique_ptr<xapp::Metrics> Alloc_metrics( const std::string& reporter, const std::string& source );
void Listen( ); // lisen driver
std::unique_ptr<Message> Receive( int timeout ); // receive 1 message
void Stop( ); // force to stop
bool Wait_for_cts( int max_wait );
void Listen( ); // lisen driver
std::unique_ptr<Message> Receive( int timeout ); // receive 1 message
void Stop( ); // force to stop
bool Wait_for_cts( int max_wait );
- int Wormhole_open( std::string endpoint );
+ int Wormhole_open( const std::string& endpoint );
such a smart pointer, and does _nothing_ when called.
*/
typedef struct {
such a smart pointer, and does _nothing_ when called.
*/
typedef struct {
- void operator()( unsigned char * p ){}
+ void operator()( unsigned char * p ) const { /* empty to prevent free */ }