Commit 914c9d85 authored by Dorian Guillois's avatar Dorian Guillois
Browse files

Remove internal copy with abort/assert.

parent 26b61110
......@@ -60,7 +60,6 @@ namespace checks {
private:
check(check const& c);
check& operator=(check const& c);
void _internal_copy(check const& c);
void _send_result_and_unregister(result const& r);
pid_t _child;
......
......@@ -54,7 +54,6 @@ private:
char*** env);
embedded_perl(embedded_perl const& ep);
embedded_perl& operator=(embedded_perl const& ep);
void _internal_copy(embedded_perl const& ep);
umap<std::string, SV*> _parsed;
static char const* const _script;
......
......@@ -35,14 +35,6 @@ CCC_PERL_BEGIN()
* (provide check results).
*/
class main_io {
private:
std::string _rbuffer;
std::string _wbuffer;
main_io();
main_io(main_io const& mio);
main_io& operator=(main_io const& mio);
int _parse(std::string const& cmd);
public:
~main_io();
static main_io& instance();
......@@ -50,6 +42,15 @@ class main_io {
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);
std::string _rbuffer;
std::string _wbuffer;
};
CCC_PERL_END()
......
......@@ -21,7 +21,6 @@
#ifndef CCCP_MULTIPLEXER_HH
# define CCCP_MULTIPLEXER_HH
# include <memory>
# include "com/centreon/handle_manager.hh"
# include "com/centreon/task_manager.hh"
# include "com/centreon/connector/perl/namespace.hh"
......@@ -35,8 +34,9 @@ CCCP_BEGIN()
* 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 {
class multiplexer
: public com::centreon::task_manager,
public com::centreon::handle_manager {
public:
~multiplexer() throw ();
static multiplexer& instance() throw ();
......@@ -46,10 +46,6 @@ public:
private:
multiplexer();
multiplexer(multiplexer const& m);
multiplexer& operator=(multiplexer const& m);
static std::auto_ptr<multiplexer>
_instance;
};
CCCP_END()
......
......@@ -63,7 +63,6 @@ public:
private:
policy(policy const& p);
policy& operator=(policy const& p);
void _internal_copy(policy const& p);
std::map<pid_t, checks::check*>
_checks;
......
......@@ -18,7 +18,7 @@
** <http://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include <memory>
#include <signal.h>
#include <stdlib.h>
#include "com/centreon/connector/perl/checks/check.hh"
......@@ -270,39 +270,6 @@ void check::write(handle& h) {
* *
**************************************/
/**
* Copy constructor.
*
* @param[in] c Unused.
*/
check::check(check const& c) : handle_listener(c) {
_internal_copy(c);
}
/**
* Assignment operator.
*
* @param[in] c Unused.
*
* @return This object.
*/
check& check::operator=(check const& c) {
_internal_copy(c);
return (*this);
}
/**
* Copy internal data members.
*
* @param[in] c Object to copy.
*/
void check::_internal_copy(check const& c) {
(void)c;
assert(!"check is not copyable");
abort();
return ;
}
/**
* Send check result and unregister.
*
......
......@@ -19,7 +19,6 @@
*/
#include <iostream>
#include <memory>
#include <stdlib.h>
#include <unistd.h>
#include <EXTERN.h>
......@@ -35,7 +34,7 @@ using namespace com::centreon::connector::perl;
#define SCRIPT_PATH "/tmp/centreon_connector_perl.XXXXXX"
// Embedded Perl instance.
static std::auto_ptr<embedded_perl> _instance;
static embedded_perl* _instance = NULL;
// Perl interpreter object.
PerlInterpreter* my_perl(NULL);
......@@ -83,8 +82,8 @@ embedded_perl& embedded_perl::instance() {
* @param[in] env Program environment.
*/
void embedded_perl::load(int* argc, char*** argv, char*** env) {
unload();
_instance.reset(new embedded_perl(argc, argv, env));
if (!_instance)
_instance = new embedded_perl(argc, argv, env);
return ;
}
......@@ -244,7 +243,8 @@ pid_t embedded_perl::run(std::string const& cmd, int fds[3]) {
* Unload Embedded Perl.
*/
void embedded_perl::unload() {
_instance.reset();
delete _instance;
_instance = NULL;
return ;
}
......@@ -326,36 +326,3 @@ embedded_perl::embedded_perl(int* argc, char*** argv, char*** env) {
PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
perl_run(my_perl);
}
/**
* Copy constructor.
*
* @param[in] ep Unused.
*/
embedded_perl::embedded_perl(embedded_perl const& ep) {
_internal_copy(ep);
}
/**
* Assignment operator.
*
* @param[in] ep Unused.
*
* @return This object.
*/
embedded_perl& embedded_perl::operator=(embedded_perl const& ep) {
_internal_copy(ep);
return (*this);
}
/**
* Copy internal data members.
*
* @param[in] ep Object to copy.
*/
void embedded_perl::_internal_copy(embedded_perl const& ep) {
(void)ep;
assert(!"Embedded Perl cannot be copied");
abort();
return ;
}
......@@ -18,7 +18,6 @@
** <http://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include <errno.h>
#include <iostream>
#include <sstream>
......@@ -42,31 +41,6 @@ using namespace com::centreon::connector::perl;
*/
main_io::main_io() {}
/**
* Copy constructor.
*
* @param[in] mio Object to copy.
*/
main_io::main_io(main_io const& mio) {
(void)mio;
assert(false);
abort();
}
/**
* Assignment operator.
*
* @param[in] mio Object to copy.
*
* @return This object.
*/
main_io& main_io::operator=(main_io const& mio) {
(void)mio;
assert(false);
abort();
return (*this);
}
/**
* Parse a command.
*
......
......@@ -18,14 +18,13 @@
** <http://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include <stdlib.h>
#include "com/centreon/connector/perl/multiplexer.hh"
using namespace com::centreon::connector::perl;
// Class instance pointer.
std::auto_ptr<multiplexer> multiplexer::_instance;
static multiplexer* _instance = NULL;
/**************************************
* *
......@@ -51,8 +50,8 @@ multiplexer& multiplexer::instance() throw () {
* Load singleton.
*/
void multiplexer::load() {
if (!_instance.get())
_instance.reset(new multiplexer);
if (!_instance)
_instance = new multiplexer;
return ;
}
......@@ -60,7 +59,8 @@ void multiplexer::load() {
* Unload singleton.
*/
void multiplexer::unload() {
_instance.reset();
delete _instance;
_instance = NULL;
return ;
}
......@@ -75,34 +75,3 @@ void multiplexer::unload() {
*/
multiplexer::multiplexer()
: com::centreon::handle_manager(this) {}
/**
* @brief Copy constructor.
*
* Any call to this constructor will result in a call to abort().
*
* @param[in] m Unused.
*/
multiplexer::multiplexer(multiplexer const& m)
: com::centreon::task_manager(),
com::centreon::handle_manager() {
(void)m;
assert(false);
abort();
}
/**
* @brief Assignment operator.
*
* Any call to this method will result in a call to abort().
*
* @param[in] m Unused.
*
* @return This object.
*/
multiplexer& multiplexer::operator=(multiplexer const& m) {
(void)m;
assert(false);
abort();
return (*this);
}
......@@ -18,7 +18,6 @@
** <http://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include <errno.h>
#include <memory>
#include <stdio.h>
......@@ -221,47 +220,3 @@ bool policy::run() {
return (!_error);
}
/**************************************
* *
* Private Methods *
* *
**************************************/
/**
* @brief Copy constructor.
*
* Any call to this constructor will result in a call to abort().
*
* @param[in] p Unused.
*/
policy::policy(policy const& p)
: orders::listener(p), checks::listener(p) {
_internal_copy(p);
}
/**
* @brief Assignment operator.
*
* Any call to this method will result in a call to abort().
*
* @param[in] p Unused.
*
* @return This object.
*/
policy& policy::operator=(policy const& p) {
_internal_copy(p);
return (*this);
}
/**
* Calls abort().
*
* @param[in] p Unused.
*/
void policy::_internal_copy(policy const& p) {
(void)p;
assert(!"policy is not copyable");
abort();
return ;
}
......@@ -21,7 +21,6 @@
#ifndef CCCS_MULTIPLEXER_HH
# define CCCS_MULTIPLEXER_HH
# include <memory>
# include "com/centreon/handle_manager.hh"
# include "com/centreon/task_manager.hh"
# include "com/centreon/connector/ssh/namespace.hh"
......@@ -35,8 +34,9 @@ CCCS_BEGIN()
* 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 {
class multiplexer
: public com::centreon::task_manager,
public com::centreon::handle_manager {
public:
~multiplexer() throw ();
static multiplexer& instance() throw ();
......@@ -47,9 +47,6 @@ private:
multiplexer();
multiplexer(multiplexer const& m);
multiplexer& operator=(multiplexer const& m);
static std::auto_ptr<multiplexer>
_instance;
};
CCCS_END()
......
......@@ -77,7 +77,6 @@ public:
private:
policy(policy const& p);
policy& operator=(policy const& p);
void _internal_copy(policy const& p);
std::map<unsigned long long, std::pair<checks::check*, sessions::session*> >
_checks;
......
......@@ -18,7 +18,6 @@
** <http://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include <memory>
#include <stdio.h>
#include <stdlib.h>
......@@ -274,35 +273,6 @@ void check::unlisten(checks::listener* listnr) {
* *
**************************************/
/**
* @brief Copy constructor.
*
* Any call to this constructor will result in a call to abort().
*
* @param[in] c Unused.
*/
check::check(check const& c) : sessions::listener(c) {
(void)c;
assert(!"check is not copyable");
abort();
}
/**
* @brief Assignment operator.
*
* Any call to this method will result in a call to abort().
*
* @param[in] c Unused.
*
* @return This object.
*/
check& check::operator=(check const& c) {
(void)c;
assert(!"check is not copyable");
abort();
return (*this);
}
/**
* Attempt to close channel.
*
......
......@@ -18,14 +18,13 @@
** <http://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include <stdlib.h>
#include "com/centreon/connector/ssh/multiplexer.hh"
using namespace com::centreon::connector::ssh;
// Class instance pointer.
std::auto_ptr<multiplexer> multiplexer::_instance;
static multiplexer* _instance = NULL;
/**************************************
* *
......@@ -51,8 +50,8 @@ multiplexer& multiplexer::instance() throw () {
* Load singleton.
*/
void multiplexer::load() {
if (!_instance.get())
_instance.reset(new multiplexer);
if (!_instance)
_instance = new multiplexer;
return ;
}
......@@ -60,7 +59,8 @@ void multiplexer::load() {
* Unload singleton.
*/
void multiplexer::unload() {
_instance.reset();
delete _instance;
_instance = NULL;
return ;
}
......@@ -75,34 +75,3 @@ void multiplexer::unload() {
*/
multiplexer::multiplexer()
: com::centreon::handle_manager(this) {}
/**
* @brief Copy constructor.
*
* Any call to this constructor will result in a call to abort().
*
* @param[in] m Unused.
*/
multiplexer::multiplexer(multiplexer const& m)
: com::centreon::task_manager(),
com::centreon::handle_manager() {
(void)m;
assert(false);
abort();
}
/**
* @brief Assignment operator.
*
* Any call to this method will result in a call to abort().
*
* @param[in] m Unused.
*
* @return This object.
*/
multiplexer& multiplexer::operator=(multiplexer const& m) {
(void)m;
assert(false);
abort();
return (*this);
}
......@@ -18,7 +18,6 @@
** <http://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include <memory>
#include <stdio.h>
#include <stdlib.h>
......@@ -350,47 +349,3 @@ bool policy::run() {
return (!_error);
}
/**************************************
* *
* Private Methods *
* *
**************************************/
/**
* @brief Copy constructor.
*
* Any call to this constructor will result in a call to abort().
*
* @param[in] p Unused.
*/
policy::policy(policy const& p)
: orders::listener(p), checks::listener(p) {
_internal_copy(p);
}
/**
* @brief Assignment operator.
*
* Any call to this method will result in a call to abort().
*
* @param[in] p Unused.
*
* @return This object.
*/
policy& policy::operator=(policy const& p) {
_internal_copy(p);
return (*this);
}
/**
* Calls abort().
*
* @param[in] p Unused.
*/
void policy::_internal_copy(policy const& p) {
(void)p;
assert(!"policy is not copyable");
abort();
return ;
}
......@@ -19,7 +19,6 @@
*/
#include <arpa/inet.h>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <libssh2.h>
......@@ -422,35 +421,6 @@ void session::write(handle& h) {
* *
**************************************/
/**
* @brief Copy constructor.
*
* Any call to this constructor will result in a call to abort().
*
* @param[in] s Object to copy.
*/
session::session(session const& s) : com::centreon::handle_listener(s) {
(void)s;
assert(!"session is not copyable");
abort();
}
/**
* @brief Assignment operator.
*
* Any call to this method will result in a call to abort().
*
* @param[in] s Object to copy.
*
* @return This object.
*/
session& session::operator=(session const& s) {
(void)s;
assert(!"session is not copyable");
abort();
return (*this);
}
/**
* Session is available for operation.
*/
......