diff --git a/middletier/cta/AdminHost.cpp b/middletier/cta/AdminHost.cpp index 39735f75dfbfbe853e90b97c781468022b2c3320..60807d23527e8fa7496a2866db222ee440c01320 100644 --- a/middletier/cta/AdminHost.cpp +++ b/middletier/cta/AdminHost.cpp @@ -3,8 +3,13 @@ //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -cta::AdminHost::AdminHost(): - m_creationTime(time(NULL)) { +cta::AdminHost::AdminHost() { +} + +//------------------------------------------------------------------------------ +// constructor +//------------------------------------------------------------------------------ +cta::AdminHost::~AdminHost() throw() { } //------------------------------------------------------------------------------ @@ -13,12 +18,10 @@ cta::AdminHost::AdminHost(): cta::AdminHost::AdminHost( const std::string &name, const UserIdentity &creator, - const time_t creationTime, - const std::string &comment): - m_name(name), - m_creationTime(creationTime), - m_creator(creator), - m_comment(comment) { + const std::string &comment, + const time_t creationTime): + ConfigurationItem(creator, comment, creationTime), + m_name(name) { } //------------------------------------------------------------------------------ @@ -27,25 +30,3 @@ cta::AdminHost::AdminHost( const std::string &cta::AdminHost::getName() const throw() { return m_name; } - -//------------------------------------------------------------------------------ -// getCreationTime -//------------------------------------------------------------------------------ -time_t cta::AdminHost::getCreationTime() const throw() { - return m_creationTime; -} - -//------------------------------------------------------------------------------ -// getCreator -//------------------------------------------------------------------------------ -const cta::UserIdentity &cta::AdminHost::getCreator() - const throw() { - return m_creator; -} - -//------------------------------------------------------------------------------ -// getComment -//------------------------------------------------------------------------------ -const std::string &cta::AdminHost::getComment() const throw() { - return m_comment; -} diff --git a/middletier/cta/AdminHost.hpp b/middletier/cta/AdminHost.hpp index 404a7e29be6b8663d29992d1a4706179e153035c..5ae12417b4aedc462255bb06b31e909ee0386df2 100644 --- a/middletier/cta/AdminHost.hpp +++ b/middletier/cta/AdminHost.hpp @@ -1,5 +1,6 @@ #pragma once +#include "cta/ConfigurationItem.hpp" #include "cta/UserIdentity.hpp" #include <string> @@ -9,7 +10,7 @@ namespace cta { /** * Class representing a administration host. */ -class AdminHost { +class AdminHost: public ConfigurationItem { public: /** @@ -17,21 +18,28 @@ public: */ AdminHost(); + /** + * Destructor. + */ + ~AdminHost() throw(); + /** * Constructor. * * @param name The network name of the administration host. - * @param creator The identity of the user that created the administration - * host. - * @param creationTime The absolute time at which the admin host entry was - * created. - * @param comment The comment describing the administration host. + * @param creator The identity of the user that created this configuration + * item. + * @param comment The comment made by the creator of this configuration + * item. + * @param creationTime Optionally the absolute time at which this + * configuration item was created. If no value is given then the current + * time is used. */ AdminHost( const std::string &name, const UserIdentity &creator, - const time_t creationTime, - const std::string &comment); + const std::string &comment, + const time_t creationTime = time(NULL)); /** * Returns the network name of the administration host. @@ -40,27 +48,6 @@ public: */ const std::string &getName() const throw(); - /** - * Returns the time when the administration host was created. - * - * @return The time when the administration host was created. - */ - time_t getCreationTime() const throw(); - - /** - * Returns the identity of the user that created the administration host. - * - * @return The identity of the user that created the administration host. - */ - const UserIdentity &getCreator() const throw(); - - /** - * Returns the comment describing the administration host. - * - * @return The comment describing the administration host. - */ - const std::string &getComment() const throw(); - private: /** @@ -68,21 +55,6 @@ private: */ std::string m_name; - /** - * The time when the administration host was created. - */ - time_t m_creationTime; - - /** - * The identity of the user that created the administration host. - */ - UserIdentity m_creator; - - /** - * Comment describing the administration host. - */ - std::string m_comment; - }; // class AdminHost } // namespace cta diff --git a/middletier/cta/SqliteDatabase.cpp b/middletier/cta/SqliteDatabase.cpp index f930b48953fc9efb1e0b7db95c6b536c80614d1a..f8685baa3deac315125e93e16a88bef6480fc936 100644 --- a/middletier/cta/SqliteDatabase.cpp +++ b/middletier/cta/SqliteDatabase.cpp @@ -1082,12 +1082,13 @@ std::list<cta::AdminHost> cta::SqliteDatabase::selectAllAdminHosts(const Securit } while(sqlite3_step(statement)==SQLITE_ROW) { SqliteColumnNameToIndex idx(statement); + const UserIdentity creator(sqlite3_column_int(statement,idx("UID")),sqlite3_column_int(statement,idx("GID"))); list.push_back(cta::AdminHost( - std::string((char *)sqlite3_column_text(statement,idx("NAME"))), - cta::UserIdentity(sqlite3_column_int(statement,idx("UID")),sqlite3_column_int(statement,idx("GID"))), - time_t(sqlite3_column_int(statement,idx("CREATIONTIME"))), - std::string((char *)sqlite3_column_text(statement,idx("COMMENT"))) - )); + std::string((char *)sqlite3_column_text(statement,idx("NAME"))), + creator, + std::string((char *)sqlite3_column_text(statement,idx("COMMENT"))), + time_t(sqlite3_column_int(statement,idx("CREATIONTIME"))) + )); } sqlite3_finalize(statement); return list;