Commit 46421a31 authored by Matthieu Kermagoret's avatar Matthieu Kermagoret
Browse files

Connector SSH: restored sessions singleton.

parent 5f2a9930
......@@ -128,7 +128,7 @@ add_library("${CONNECTORLIB}"
"${SRC_DIR}/credentials.cc"
"${SRC_DIR}/multiplexer.cc"
"${SRC_DIR}/session.cc"
# "${SRC_DIR}/sessions.cc"
"${SRC_DIR}/sessions.cc"
"${SRC_DIR}/socket_handle.cc"
# Headers.
"${INC_DIR}/channel.hh"
......@@ -138,7 +138,7 @@ add_library("${CONNECTORLIB}"
"${INC_DIR}/multiplexer.hh"
"${INC_DIR}/namespace.hh"
"${INC_DIR}/session.hh"
# "${INC_DIR}/sessions.hh"
"${INC_DIR}/sessions.hh"
"${INC_DIR}/socket_handle.hh"
)
target_link_libraries(
......
......@@ -25,7 +25,7 @@
# include "com/centreon/connector/ssh/credentials.hh"
# include "com/centreon/connector/ssh/namespace.hh"
CCC_SSH_BEGIN()
CCCS_BEGIN()
// Forward declaration.
class session;
......@@ -37,14 +37,7 @@ class session;
* Manage sessions.
*/
class sessions {
private:
std::map<credentials, session*>
_set;
sessions();
sessions(sessions const& s);
sessions& operator=(sessions const& s);
public:
public:
~sessions();
session*& operator[](credentials const& c);
std::map<credentials, session*>::iterator
......@@ -56,8 +49,16 @@ class sessions {
void erase(std::map<credentials, session*>::iterator it);
static sessions& instance();
unsigned int size() const;
private:
sessions();
sessions(sessions const& s);
sessions& operator=(sessions const& s);
std::map<credentials, session*>
_set;
};
CCC_SSH_END()
CCCS_END()
#endif /* !CCC_SSH_SESSIONS_HH_ */
#endif // !CCCS_SESSIONS_HH
......@@ -25,46 +25,6 @@
using namespace com::centreon::connector::ssh;
/**************************************
* *
* Private Methods *
* *
**************************************/
/**
* Constructor.
*/
sessions::sessions() {}
/**
* @brief Copy constructor.
*
* Any call to this constructor will result in a call to abort().
*
* @param[in] s Object to copy.
*/
sessions::sessions(sessions const& s) {
(void)s;
assert(false);
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.
*/
sessions& sessions::operator=(sessions const& s) {
(void)s;
assert(false);
abort();
return (*this);
}
/**************************************
* *
* Public Methods *
......@@ -172,3 +132,43 @@ sessions& sessions::instance() {
unsigned int sessions::size() const {
return (_set.size());
}
/**************************************
* *
* Private Methods *
* *
**************************************/
/**
* Constructor.
*/
sessions::sessions() {}
/**
* @brief Copy constructor.
*
* Any call to this constructor will result in a call to abort().
*
* @param[in] s Object to copy.
*/
sessions::sessions(sessions const& s) {
(void)s;
assert(!"sessions 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.
*/
sessions& sessions::operator=(sessions const& s) {
(void)s;
assert(!"sessions is not copyable");
abort();
return (*this);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment