Commit 4fbb0cf6 authored by David Boucher's avatar David Boucher
Browse files

cleanup(various): coding style uniformized

parent 835d0d29
......@@ -17,60 +17,57 @@
*/
#ifndef CCCP_CHECKS_CHECK_HH
# define CCCP_CHECKS_CHECK_HH
#define CCCP_CHECKS_CHECK_HH
# include <string>
# include <sys/types.h>
# include "com/centreon/connector/perl/namespace.hh"
# include "com/centreon/connector/perl/pipe_handle.hh"
# include "com/centreon/handle_listener.hh"
#include <sys/types.h>
#include <string>
#include "com/centreon/connector/perl/namespace.hh"
#include "com/centreon/connector/perl/pipe_handle.hh"
#include "com/centreon/handle_listener.hh"
CCCP_BEGIN()
namespace checks {
// Forward declarations.
class listener;
class result;
namespace checks {
// Forward declarations.
class listener;
class result;
/**
* @class check check.hh "com/centreon/connector/perl/checks/check.hh"
* @brief Perl check.
*
* Class wrapping a Perl check as requested by the monitoring engine.
*/
class check : public handle_listener {
public:
check();
~check() throw ();
void error(handle& h);
pid_t execute(
unsigned long long cmd_id,
std::string const& cmd,
time_t tmt);
void listen(listener* listnr);
void on_timeout(bool final = true);
void read(handle& h);
void terminated(int exit_code);
void unlisten(listener* listnr);
bool want_read(handle& h);
void write(handle& h);
/**
* @class check check.hh "com/centreon/connector/perl/checks/check.hh"
* @brief Perl check.
*
* Class wrapping a Perl check as requested by the monitoring engine.
*/
class check : public handle_listener {
public:
check();
~check() throw();
void error(handle& h);
pid_t execute(unsigned long long cmd_id, std::string const& cmd, time_t tmt);
void listen(listener* listnr);
void on_timeout(bool final = true);
void read(handle& h);
void terminated(int exit_code);
void unlisten(listener* listnr);
bool want_read(handle& h);
void write(handle& h);
private:
check(check const& c);
check& operator=(check const& c);
void _send_result_and_unregister(result const& r);
private:
check(check const& c);
check& operator=(check const& c);
void _send_result_and_unregister(result const& r);
pid_t _child;
unsigned long long _cmd_id;
pipe_handle _err;
listener* _listnr;
pipe_handle _out;
std::string _stderr;
std::string _stdout;
unsigned long _timeout;
};
}
pid_t _child;
unsigned long long _cmd_id;
pipe_handle _err;
listener* _listnr;
pipe_handle _out;
std::string _stderr;
std::string _stdout;
unsigned long _timeout;
};
} // namespace checks
CCCP_END()
#endif // !CCCP_CHECKS_CHECK_HH
#endif // !CCCP_CHECKS_CHECK_HH
......@@ -17,30 +17,30 @@
*/
#ifndef CCCP_CHECKS_LISTENER_HH
# define CCCP_CHECKS_LISTENER_HH
#define CCCP_CHECKS_LISTENER_HH
# include "com/centreon/connector/perl/checks/result.hh"
# include "com/centreon/connector/perl/namespace.hh"
#include "com/centreon/connector/perl/checks/result.hh"
#include "com/centreon/connector/perl/namespace.hh"
CCCP_BEGIN()
namespace checks {
/**
* @class listener listener.hh "com/centreon/connector/perl/checks/listener.hh"
* @brief Check listener.
*
* Listen check events.
*/
class listener {
public:
listener();
listener(listener const& l);
virtual ~listener();
listener& operator=(listener const& l);
virtual void on_result(result const& result) = 0;
};
}
namespace checks {
/**
* @class listener listener.hh "com/centreon/connector/perl/checks/listener.hh"
* @brief Check listener.
*
* Listen check events.
*/
class listener {
public:
listener();
listener(listener const& l);
virtual ~listener();
listener& operator=(listener const& l);
virtual void on_result(result const& result) = 0;
};
} // namespace checks
CCCP_END()
#endif // !CCCP_CHECKS_LISTENER_HH
#endif // !CCCP_CHECKS_LISTENER_HH
......@@ -17,48 +17,48 @@
*/
#ifndef CCCP_CHECKS_RESULT_HH
# define CCCP_CHECKS_RESULT_HH
#define CCCP_CHECKS_RESULT_HH
# include <string>
# include "com/centreon/connector/perl/namespace.hh"
#include <string>
#include "com/centreon/connector/perl/namespace.hh"
CCCP_BEGIN()
namespace checks {
/**
* @class result result.hh "com/centreon/connector/perl/checks/result.hh"
* @brief Check result.
*
* Store check result.
*/
class result {
public:
result();
result(result const& r);
~result();
result& operator=(result const& r);
unsigned long long get_command_id() const throw ();
std::string const& get_error() const throw ();
bool get_executed() const throw ();
int get_exit_code() const throw ();
std::string const& get_output() const throw ();
void set_command_id(unsigned long long cmd_id) throw ();
void set_error(std::string const& error);
void set_executed(bool executed) throw ();
void set_exit_code(int code) throw ();
void set_output(std::string const& output);
namespace checks {
/**
* @class result result.hh "com/centreon/connector/perl/checks/result.hh"
* @brief Check result.
*
* Store check result.
*/
class result {
public:
result();
result(result const& r);
~result();
result& operator=(result const& r);
unsigned long long get_command_id() const throw();
std::string const& get_error() const throw();
bool get_executed() const throw();
int get_exit_code() const throw();
std::string const& get_output() const throw();
void set_command_id(unsigned long long cmd_id) throw();
void set_error(std::string const& error);
void set_executed(bool executed) throw();
void set_exit_code(int code) throw();
void set_output(std::string const& output);
private:
void _internal_copy(result const& r);
private:
void _internal_copy(result const& r);
unsigned long long _cmd_id;
std::string _error;
bool _executed;
int _exit_code;
std::string _output;
};
}
unsigned long long _cmd_id;
std::string _error;
bool _executed;
int _exit_code;
std::string _output;
};
} // namespace checks
CCCP_END()
#endif // !CCCP_CHECKS_RESULT_HH
#endif // !CCCP_CHECKS_RESULT_HH
......@@ -17,44 +17,44 @@
*/
#ifndef CCCP_CHECKS_TIMEOUT_HH
# define CCCP_CHECKS_TIMEOUT_HH
#define CCCP_CHECKS_TIMEOUT_HH
# include <cstddef>
# include "com/centreon/connector/perl/namespace.hh"
# include "com/centreon/task.hh"
#include <cstddef>
#include "com/centreon/connector/perl/namespace.hh"
#include "com/centreon/task.hh"
CCCP_BEGIN()
namespace checks {
// Forward declaration.
class check;
/**
* @class timeout timeout.hh "com/centreon/connector/perl/checks/timeout.hh"
* @brief Check timeout.
*
* Task executed when a check timeouts.
*/
class timeout : public com::centreon::task {
public:
timeout(check* chk = NULL, bool final = false);
timeout(timeout const& t);
~timeout() throw ();
timeout& operator=(timeout const& t);
check* get_check() const throw ();
bool is_final() const throw ();
void run();
void set_check(check* chk) throw ();
void set_final(bool final) throw ();
private:
void _internal_copy(timeout const& t);
check* _check;
bool _final;
};
}
namespace checks {
// Forward declaration.
class check;
/**
* @class timeout timeout.hh "com/centreon/connector/perl/checks/timeout.hh"
* @brief Check timeout.
*
* Task executed when a check timeouts.
*/
class timeout : public com::centreon::task {
public:
timeout(check* chk = NULL, bool final = false);
timeout(timeout const& t);
~timeout() throw();
timeout& operator=(timeout const& t);
check* get_check() const throw();
bool is_final() const throw();
void run();
void set_check(check* chk) throw();
void set_final(bool final) throw();
private:
void _internal_copy(timeout const& t);
check* _check;
bool _final;
};
} // namespace checks
CCCP_END()
#endif // !CCCP_CHECKS_TIMEOUT_HH
#endif // !CCCP_CHECKS_TIMEOUT_HH
......@@ -17,53 +17,49 @@
*/
#ifndef CCCP_EMBEDDED_PERL_HH
# define CCCP_EMBEDDED_PERL_HH
#define CCCP_EMBEDDED_PERL_HH
# include "com/centreon/connector/perl/namespace.hh"
# include "com/centreon/unordered_hash.hh"
# include <string>
# include <sys/types.h>
# include <EXTERN.h>
# include <perl.h>
#include <EXTERN.h>
#include <perl.h>
#include <sys/types.h>
#include <string>
#include "com/centreon/connector/perl/namespace.hh"
#include "com/centreon/unordered_hash.hh"
// Global Perl interpreter.
extern PerlInterpreter* my_perl;
extern PerlInterpreter* my_perl;
CCCP_BEGIN()
/**
* @class embedded_perl embedded_perl.hh "com/centreon/connector/perl/embedded_perl.hh"
* @class embedded_perl embedded_perl.hh
* "com/centreon/connector/perl/embedded_perl.hh"
* @brief Embedded Perl interpreter.
*
* Embedded Perl interpreter wrapped in a singleton.
*/
class embedded_perl {
public:
~embedded_perl();
static embedded_perl& instance();
static void load(
int* argc,
char*** argv,
char*** env,
char const* code = NULL);
pid_t run(std::string const& cmd, int fds[3]);
static void unload();
class embedded_perl {
public:
~embedded_perl();
static embedded_perl& instance();
static void load(int* argc,
char*** argv,
char*** env,
char const* code = NULL);
pid_t run(std::string const& cmd, int fds[3]);
static void unload();
private:
embedded_perl(
int* argc,
char*** argv,
char*** env,
char const* code = NULL);
embedded_perl(embedded_perl const& ep);
embedded_perl& operator=(embedded_perl const& ep);
void _write(char const* data, size_t len);
private:
embedded_perl(int* argc, char*** argv, char*** env, char const* code = NULL);
embedded_perl(embedded_perl const& ep);
embedded_perl& operator=(embedded_perl const& ep);
void _write(char const* data, size_t len);
umap<std::string, SV*> _parsed;
umap<std::string, SV*> _parsed;
static char const* const _script;
pid_t _self;
pid_t _self;
};
CCCP_END()
#endif // !CCCP_EMBEDDED_PERL_HH
#endif // !CCCP_EMBEDDED_PERL_HH
......@@ -17,10 +17,10 @@
*/
#ifndef CCC_PERL_MAIN_IO_HH_
# define CCC_PERL_MAIN_IO_HH_
#define CCC_PERL_MAIN_IO_HH_
# include <string>
# include "com/centreon/connector/perl/namespace.hh"
#include <string>
#include "com/centreon/connector/perl/namespace.hh"
CCC_PERL_BEGIN()
......@@ -32,23 +32,23 @@ CCC_PERL_BEGIN()
* orders from the monitoring engine) and on standard output
* (provide check results).
*/
class main_io {
class main_io {
public:
~main_io();
~main_io();
static main_io& instance();
int read();
int write();
void write(std::string const& data);
bool write_wanted() const;
int read();
int write();
void write(std::string const& data);
bool write_wanted() const;
private:
main_io();
main_io(main_io const& mio);
main_io& operator=(main_io const& mio);
int _parse(std::string const& cmd);
main_io();
main_io(main_io const& mio);
main_io& operator=(main_io const& mio);
int _parse(std::string const& cmd);
std::string _rbuffer;
std::string _wbuffer;
std::string _rbuffer;
std::string _wbuffer;
};
CCC_PERL_END()
......
......@@ -17,35 +17,35 @@
*/
#ifndef CCCP_MULTIPLEXER_HH
# define CCCP_MULTIPLEXER_HH
#define CCCP_MULTIPLEXER_HH
# include "com/centreon/handle_manager.hh"
# include "com/centreon/task_manager.hh"
# include "com/centreon/connector/perl/namespace.hh"
#include "com/centreon/connector/perl/namespace.hh"
#include "com/centreon/handle_manager.hh"
#include "com/centreon/task_manager.hh"
CCCP_BEGIN()
/**
* @class multiplexer multiplexer.hh "com/centreon/connector/perl/multiplexer.hh"
* @class multiplexer multiplexer.hh
* "com/centreon/connector/perl/multiplexer.hh"
* @brief Multiplexing class.
*
* Singleton that aggregates multiplexing features such as file
* descriptor monitoring and task execution.
*/
class multiplexer
: public com::centreon::task_manager,
public com::centreon::handle_manager {
public:
~multiplexer() throw ();
static multiplexer& instance() throw ();
static void load();
static void unload();
class multiplexer : public com::centreon::task_manager,
public com::centreon::handle_manager {
public:
~multiplexer() throw();
static multiplexer& instance() throw();
static void load();
static void unload();
private:
multiplexer();
multiplexer(multiplexer const& m);
private:
multiplexer();
multiplexer(multiplexer const& m);
};
CCCP_END()
#endif // !CCCP_MULTIPLEXER_HH
#endif // !CCCP_MULTIPLEXER_HH
......@@ -17,19 +17,24 @@
*/
#ifndef CCCP_NAMESPACE_HH
# define CCCP_NAMESPACE_HH
#define CCCP_NAMESPACE_HH
# ifdef CCCP_BEGIN
# undef CCCP_BEGIN
# endif // CCCP_BEGIN
# define CCCP_BEGIN() namespace com { \
namespace centreon { \
namespace connector { \
namespace perl {
#ifdef CCCP_BEGIN
#undef CCCP_BEGIN
#endif // CCCP_BEGIN
#define CCCP_BEGIN() \
namespace com { \
namespace centreon { \
namespace connector { \
namespace perl {
# ifdef CCCP_END
# undef CCCP_END
# endif // CCCP_END
# define CCCP_END() } } } }
#ifdef CCCP_END
#undef CCCP_END
#endif // CCCP_END
#define CCCP_END() \
} \
} \
} \
}
#endif // !CCCP_NAMESPACE_HH
#endif // !CCCP_NAMESPACE_HH
......@@ -17,10 +17,10 @@
*/
#ifndef CCCP_OPTIONS_HH
# define CCCP_OPTIONS_HH
#define CCCP_OPTIONS_HH
# include "com/centreon/connector/perl/namespace.hh"
# include "com/centreon/misc/get_options.hh"
#include "com/centreon/connector/perl/namespace.hh"
#include "com/centreon/misc/get_options.hh"
CCCP_BEGIN()
......@@ -30,20 +30,20 @@ CCCP_BEGIN()
*
* Parse and expose command line arguments.
*/
class options : public com::centreon::misc::get_options {
public:
options();
options(options const& opts);
~options() throw ();
options& operator=(options const& opts);
class options : public com::centreon::misc::get_options {
public:
options();
options(options const& opts);
~options() throw();
options& operator=(options const& opts);
std::string help() const;
void parse(int argc, char* argv[]);
void parse(int argc, char* argv[]);
std::string usage() const;
private:
void _init();
private:
void _init();
};
CCCP_END()
#endif // !CCCP_OPTIONS_HH
#endif // !CCCP_OPTIONS_HH
......@@ -17,39 +17,38 @@
*/
#ifndef CCCP_ORDERS_LISTENER_HH
# define CCCP_ORDERS_LISTENER_HH
#define CCCP_ORDERS_LISTENER_HH
# include <ctime>