diff --git a/libs/client/CMakeLists.txt b/libs/client/CMakeLists.txt index 7c9a5a51982e55fa648f582148af0d16bab3dca6..c581e2e6000a7e6e46633694163ac7637a0e4992 100644 --- a/libs/client/CMakeLists.txt +++ b/libs/client/CMakeLists.txt @@ -5,8 +5,9 @@ set (CLIENT_LIB_SRC_FILES DirectoryEntry.cpp DirectoryIterator.cpp Exception.cpp + FileAttribute.cpp + MockAPITest.cpp MockClientAPI.cpp -# MockAPITest.cpp StorageClass.cpp) add_library (ctaclient SHARED diff --git a/libs/client/ClientAPI.hpp b/libs/client/ClientAPI.hpp index 7de9755ac68a09c9718c1403eb7b712a01567f90..71d70db0790331307df0a74008f2798ced30ae44 100644 --- a/libs/client/ClientAPI.hpp +++ b/libs/client/ClientAPI.hpp @@ -2,7 +2,6 @@ #include "DirectoryIterator.hpp" #include "StorageClass.hpp" -#include "StorageClassList.hpp" #include <list> #include <stdint.h> @@ -44,7 +43,7 @@ public: * * @return The current list of storage classes in lexicographical order. */ - virtual StorageClassList getStorageClasses() const = 0; + virtual std::list<StorageClass> getStorageClasses() const = 0; /** * Gets an iterator over the entries of the specified directory. diff --git a/libs/client/DirectoryEntry.cpp b/libs/client/DirectoryEntry.cpp index 27f03539f9d75aeec825be3bd587557ee2d05cd4..7c126cdf15b2ff8579976dc7b2e4fd0dcf82f76e 100644 --- a/libs/client/DirectoryEntry.cpp +++ b/libs/client/DirectoryEntry.cpp @@ -1 +1,20 @@ #include "DirectoryEntry.hpp" + +//------------------------------------------------------------------------------ +// typeToString +//------------------------------------------------------------------------------ +const char *cta::DirectoryEntry::typeToString(const EntryType enumValue) + throw() { + switch(enumValue) { + case NONE : return "NONE"; + case FILE_ENTRY : return "FILE_ENTRY"; + case DIRECTORY_ENTRY: return "DIRECTORY_ENTRY"; + default : return "UNKNOWN"; + } +} + +//------------------------------------------------------------------------------ +// constructor +//------------------------------------------------------------------------------ +cta::DirectoryEntry::DirectoryEntry(): entryType(NONE) { +} diff --git a/libs/client/DirectoryEntry.hpp b/libs/client/DirectoryEntry.hpp index 25269a0ba2286dedaf28b2af7445a68f2d99e921..1448499fafa766148beae44d021c81e032f2fa9f 100644 --- a/libs/client/DirectoryEntry.hpp +++ b/libs/client/DirectoryEntry.hpp @@ -1,11 +1,53 @@ #pragma once +#include "FileAttribute.hpp" + +#include <list> #include <string> namespace cta { struct DirectoryEntry { + /** + * Enumeration of the different types of directory entry. + */ + enum EntryType { + NONE, + FILE_ENTRY, + DIRECTORY_ENTRY + }; + + /** + * Thread safe method that returns the string representation of the + * specified enumeration (integer) value. + * + * @param enumValue The enumeration (integer) value. + * @return The string value. + */ + static const char *typeToString(const EntryType enumValue) throw(); + + /** + * The type of the directory entry. + */ + EntryType entryType; + + /** + * The name of the directory. + */ std::string name; + + /** + * The attributes of the directory. + */ + std::list<FileAttribute> attributes; + + /** + * Constructor. + * + * Initialises the entry type of the DirectoryEntry to NONE. + */ + DirectoryEntry(); + }; // DirectoryEntry } // namespace cta diff --git a/libs/client/FileAttribute.cpp b/libs/client/FileAttribute.cpp index d934deb9c14ce20c3cfbe3824609f59f8a53cd83..84432ac75c2197652070f75c8e54c1c83308f7a7 100644 --- a/libs/client/FileAttribute.cpp +++ b/libs/client/FileAttribute.cpp @@ -3,12 +3,12 @@ //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -cta::FileAtribute::FileAtribute() { +cta::FileAttribute::FileAttribute() { } //------------------------------------------------------------------------------ // constructor //------------------------------------------------------------------------------ -cta::FileAtribute::FileAtribute(const std::string &name, +cta::FileAttribute::FileAttribute(const std::string &name, const std::string &value): name(name), value(value) { } diff --git a/libs/client/FileAttribute.hpp b/libs/client/FileAttribute.hpp index 6b8f1d927424f57d7b28a90154abe831de9a8d7c..299913948f37cecd1e75ea0786cc9efab0212529 100644 --- a/libs/client/FileAttribute.hpp +++ b/libs/client/FileAttribute.hpp @@ -7,7 +7,7 @@ namespace cta { /** * Class representing a file atrribute. */ -struct FileAtribute { +struct FileAttribute { /** * The name of the attribute. @@ -22,7 +22,7 @@ struct FileAtribute { /** * Constructor. */ - FileAtribute(); + FileAttribute(); /** * Constructor. @@ -30,8 +30,8 @@ struct FileAtribute { * @param name The name of the attribute. * @param value value of the attribute. */ - FileAtribute(const std::string &name, const std::string &value); + FileAttribute(const std::string &name, const std::string &value); -}; // struct FileAtribute +}; // struct FileAttribute } // namespace cta diff --git a/libs/client/MockAPITest.cpp b/libs/client/MockAPITest.cpp index 441bc29d823f2bd4161b725d41e318e0850ddb9e..c95b9dd06dc5a9bc96136c22db68d9e73fd6b422 100644 --- a/libs/client/MockAPITest.cpp +++ b/libs/client/MockAPITest.cpp @@ -26,7 +26,7 @@ TEST_F(cta_client_MockClientAPITest, createStorageClass_new) { ASSERT_NO_THROW(api.createStorageClass(name, nbCopies)); ASSERT_EQ(1, api.getStorageClasses().size()); - cta::StorageClass storageClass; + StorageClass storageClass; ASSERT_NO_THROW(storageClass = api.getStorageClasses().front()); ASSERT_EQ(name, storageClass.name); ASSERT_EQ(nbCopies, storageClass.nbCopies); @@ -44,7 +44,7 @@ TEST_F(cta_client_MockClientAPITest, createStorageClass_already_existing) { ASSERT_NO_THROW(api.createStorageClass(name, nbCopies)); ASSERT_EQ(1, api.getStorageClasses().size()); - cta::StorageClass storageClass; + StorageClass storageClass; ASSERT_NO_THROW(storageClass = api.getStorageClasses().front()); ASSERT_EQ(name, storageClass.name); ASSERT_EQ(nbCopies, storageClass.nbCopies); @@ -66,7 +66,7 @@ TEST_F(cta_client_MockClientAPITest, createStorageClass_lexicographical_order) { ASSERT_EQ(4, api.getStorageClasses().size()); - cta::StorageClassList storageClasses = api.getStorageClasses(); + std::list<StorageClass> storageClasses = api.getStorageClasses(); ASSERT_EQ(std::string("a"), storageClasses.front().name); storageClasses.pop_front(); @@ -89,7 +89,7 @@ TEST_F(cta_client_MockClientAPITest, deleteStorageClass_existing) { ASSERT_NO_THROW(api.createStorageClass(name, nbCopies)); ASSERT_EQ(1, api.getStorageClasses().size()); - cta::StorageClass storageClass; + StorageClass storageClass; ASSERT_NO_THROW(storageClass = api.getStorageClasses().front()); ASSERT_EQ(name, storageClass.name); ASSERT_EQ(nbCopies, storageClass.nbCopies); diff --git a/libs/client/MockClientAPI.hpp b/libs/client/MockClientAPI.hpp index 1e115f959f6f55ce87501677af1ac3daa7e6cc1d..67d415a2a0e624a6a2a52371d3471b7496f13f5d 100644 --- a/libs/client/MockClientAPI.hpp +++ b/libs/client/MockClientAPI.hpp @@ -45,7 +45,7 @@ public: * * @return The current list of storage classes in lexicographical order. */ - StorageClassList getStorageClasses() const; + std::list<StorageClass> getStorageClasses() const; /** * Gets an iterator over the entries of the specified directory. diff --git a/libs/client/StorageClassList.hpp b/libs/client/StorageClassList.hpp deleted file mode 100644 index 3e24d1be0fb1e51f2ce5b5d85521fed0b0ed5177..0000000000000000000000000000000000000000 --- a/libs/client/StorageClassList.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include "StorageClass.hpp" - -#include <list> - -namespace cta { - -typedef std::list<StorageClass> StorageClassList; - -} // namespace cta diff --git a/xroot_plugins/XrdProFilesystem.cpp b/xroot_plugins/XrdProFilesystem.cpp index 02ca09501dc03b44656992a39edd21322b514472..bd8704da319428674ac35874d260d19b9585cbe3 100644 --- a/xroot_plugins/XrdProFilesystem.cpp +++ b/xroot_plugins/XrdProFilesystem.cpp @@ -235,9 +235,9 @@ int XrdProFilesystem::executeListStorageClassCommand(ParsedRequest &req, XrdOucE return SFS_DATA; } try { - cta::StorageClassList stgList = m_clientAPI->getStorageClasses(); + std::list<cta::StorageClass> stgList = m_clientAPI->getStorageClasses(); std::string response = "[OK] Listing of the storage class names and no of copies:"; - for(cta::StorageClassList::iterator it = stgList.begin(); it != stgList.end(); it++) { + for(std::list<cta::StorageClass>::iterator it = stgList.begin(); it != stgList.end(); it++) { response += "\n"; response += it->name; response += " "; @@ -563,4 +563,4 @@ XrdProFilesystem::XrdProFilesystem() { //------------------------------------------------------------------------------ XrdProFilesystem::~XrdProFilesystem() { delete m_clientAPI; -} \ No newline at end of file +}