diff --git a/middletier/cta/FileSystemStorageClasses.cpp b/middletier/cta/FileSystemStorageClasses.cpp index 1d45a8933c29086239b053a7734655df9d774338..883016fa2803113432d7f9a2a7fe3404b96fe2ab 100644 --- a/middletier/cta/FileSystemStorageClasses.cpp +++ b/middletier/cta/FileSystemStorageClasses.cpp @@ -13,7 +13,7 @@ void cta::FileSystemStorageClasses::createStorageClass( const std::string &comment) { try { checkStorageClassDoesNotAlreadyExist(name); - StorageClass storageClass(name, nbCopies, creator, time(NULL), comment); + StorageClass storageClass(name, nbCopies, creator, comment); m_storageClasses[name] = storageClass; } catch(std::exception &ex) { throw Exception(std::string("Failed to create storage class: ") + diff --git a/middletier/cta/SqliteDatabase.cpp b/middletier/cta/SqliteDatabase.cpp index 0bfab88a8031f413727bca912904e18a148bc8f1..5269d30455d045640c25434d4e6bb8d9c067a159 100644 --- a/middletier/cta/SqliteDatabase.cpp +++ b/middletier/cta/SqliteDatabase.cpp @@ -830,8 +830,8 @@ std::list<cta::StorageClass> cta::SqliteDatabase::selectAllStorageClasses(const std::string((char *)sqlite3_column_text(statement,idx("NAME"))), sqlite3_column_int(statement,idx("NBCOPIES")), 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("COMMENT"))), + time_t(sqlite3_column_int(statement,idx("CREATIONTIME"))) )); } sqlite3_finalize(statement); @@ -1112,8 +1112,8 @@ cta::StorageClass cta::SqliteDatabase::getStorageClassByName(const SecurityIdent std::string((char *)sqlite3_column_text(statement,idx("NAME"))), sqlite3_column_int(statement,idx("NBCOPIES")), 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("COMMENT"))), + time_t(sqlite3_column_int(statement,idx("CREATIONTIME"))) ); } else if(res==SQLITE_DONE) { diff --git a/middletier/cta/StorageClass.cpp b/middletier/cta/StorageClass.cpp index cca9d3002f7b66d3de2855230532b64820f1f7f6..2ee9d41939132e9929ed9f017c81c1c89245e58a 100644 --- a/middletier/cta/StorageClass.cpp +++ b/middletier/cta/StorageClass.cpp @@ -4,8 +4,13 @@ // constructor //------------------------------------------------------------------------------ cta::StorageClass::StorageClass(): - m_nbCopies(0), - m_creationTime(time(NULL)) { + m_nbCopies(0) { +} + +//------------------------------------------------------------------------------ +// destructor +//------------------------------------------------------------------------------ +cta::StorageClass::~StorageClass() throw() { } //------------------------------------------------------------------------------ @@ -15,13 +20,11 @@ cta::StorageClass::StorageClass( const std::string &name, const uint16_t nbCopies, const UserIdentity &creator, - const time_t creationTime, - const std::string &comment): + const std::string &comment, + const time_t creationTime): + ConfigurationItem(creator, comment, creationTime), m_name(name), - m_nbCopies(nbCopies), - m_creationTime(creationTime), - m_creator(creator), - m_comment(comment) { + m_nbCopies(nbCopies) { } //------------------------------------------------------------------------------ @@ -37,25 +40,3 @@ const std::string &cta::StorageClass::getName() const throw() { uint16_t cta::StorageClass::getNbCopies() const throw() { return m_nbCopies; } - -//------------------------------------------------------------------------------ -// getCreationTime -//------------------------------------------------------------------------------ -time_t cta::StorageClass::getCreationTime() const throw() { - return m_creationTime; -} - -//------------------------------------------------------------------------------ -// getCreator -//------------------------------------------------------------------------------ -const cta::UserIdentity &cta::StorageClass::getCreator() - const throw() { - return m_creator; -} - -//------------------------------------------------------------------------------ -// getComment -//------------------------------------------------------------------------------ -const std::string &cta::StorageClass::getComment() const throw() { - return m_comment; -} diff --git a/middletier/cta/StorageClass.hpp b/middletier/cta/StorageClass.hpp index 578ea4e23890f4834a3c56b1ae69367fc21a9479..6d34b8bf0dc3f4317551615efb14049bcd44a2c9 100644 --- a/middletier/cta/StorageClass.hpp +++ b/middletier/cta/StorageClass.hpp @@ -1,6 +1,6 @@ #pragma once -#include "cta/UserIdentity.hpp" +#include "cta/ConfigurationItem.hpp" #include <stdint.h> #include <string> @@ -10,7 +10,7 @@ namespace cta { /** * Class representing an archive storage-class. */ -class StorageClass { +class StorageClass: public ConfigurationItem { public: /** @@ -18,6 +18,11 @@ public: */ StorageClass(); + /** + * Destructor. + */ + ~StorageClass() throw(); + /** * Constructor. * @@ -26,13 +31,16 @@ public: * class should have on tape. * @param creator The identity of the user that created the storage class. * @param comment The comment describing the storage class. + * @param creationTime Optionally the absolute time at which the + * configuration item was created. If no value is given then the current + * time is used. */ StorageClass( const std::string &name, const uint16_t nbCopies, const UserIdentity &creator, - const time_t creationTime, - const std::string &comment); + const std::string &comment, + const time_t creationTime = time(NULL)); /** * Returns the name of the storage class. @@ -50,27 +58,6 @@ public: */ uint16_t getNbCopies() const throw(); - /** - * Returns the time when the storage class was created. - * - * @return The time when the storage class was created. - */ - time_t getCreationTime() const throw(); - - /** - * Returns the identity of the user that created the storage class. - * - * @return The identity of the user that created the storage class. - */ - const UserIdentity &getCreator() const throw(); - - /** - * Returns the comment describing the storage class. - * - * @return The comment describing the storage class. - */ - const std::string &getComment() const throw(); - private: /** @@ -84,21 +71,6 @@ private: */ uint16_t m_nbCopies; - /** - * The time when the storage class was created. - */ - time_t m_creationTime; - - /** - * The identity of the user that created the storage class. - */ - UserIdentity m_creator; - - /** - * Comment describing the storage class. - */ - std::string m_comment; - }; // class StorageClass } // namespace cta