diff --git a/SpeckleLib/Speckle/Database/AccountDBase.cpp b/SpeckleLib/Speckle/Database/AccountDBase.cpp index 164b504..eb1b902 100644 --- a/SpeckleLib/Speckle/Database/AccountDBase.cpp +++ b/SpeckleLib/Speckle/Database/AccountDBase.cpp @@ -1,8 +1,11 @@ #include "Active/Database/Storage/SQLiteEngine.h" +#include "Active/Database/Storage/Storage.h" +#include "Active/Serialise/JSON/JSONTransport.h" #include "Active/Setting/ValueSetting.h" #include "Active/Setting/Values/StringValue.h" #include "Speckle/Database/AccountDBase.h" +using namespace active::container; using namespace active::database; using namespace active::serialise::json; using namespace active::setting; @@ -10,8 +13,6 @@ using namespace speckle::record::cred; using namespace speckle::database; using namespace speckle::utility; -using AccountsEngine = SQLiteEngine; - namespace { enum Fields { @@ -25,17 +26,35 @@ namespace { const char* contentFieldName = "content"; } -// template + +namespace speckle::database { + + ///Accounts database engine declaration + using AccountsEngine = SQLiteEngine; + + ///Accounts database storage declaration + class AccountDBase::Store : public active::database::Storage { + using base = active::database::Storage; + using base::base; + }; + +} /*-------------------------------------------------------------------- Constructor path: Path to the database file --------------------------------------------------------------------*/ -AccountDBase::AccountDBase(const active::file::Path& path) : base{ - std::make_unique( - path, DBaseSchema{ - accountsDBaseName, { +AccountDBase::AccountDBase(const active::file::Path& path) { + m_store = std::make_unique( + //Engine + std::make_unique(path, + //Schema + DBaseSchema{active::utility::String{accountsDBaseName}, + //Tables + { { accountsTableName, Fields::hashID, Fields::contentID, { ValueSetting{StringValue{}, hashFieldName}, @@ -45,6 +64,15 @@ AccountDBase::AccountDBase(const active::file::Path& path) : base{ } } ) - } { - + ); } //AccountDBase::AccountDBase + + +/*-------------------------------------------------------------------- + Get all accounts + + return: All the accounts + --------------------------------------------------------------------*/ +Vector AccountDBase::getAccounts() const { + return m_store->getObjects(); +} //AccountDBase::getAccounts diff --git a/SpeckleLib/Speckle/Database/AccountDBase.h b/SpeckleLib/Speckle/Database/AccountDBase.h index b789855..14cac57 100644 --- a/SpeckleLib/Speckle/Database/AccountDBase.h +++ b/SpeckleLib/Speckle/Database/AccountDBase.h @@ -1,32 +1,17 @@ #ifndef SPECKLE_DATABASE_ACCOUNT_DBASE #define SPECKLE_DATABASE_ACCOUNT_DBASE -#include "Active/Database/Storage/SQLiteEngine.h" -#include "Active/Database/Storage/Storage.h" #include "Active/File/Path.h" -#include "Active/Serialise/JSON/JSONTransport.h" #include "Speckle/Record/Credentials/Account.h" -#include "Speckle/Utility/String.h" - -#include namespace speckle::database { /*! A base class for an addon */ - class AccountDBase : public active::database::Storage { + class AccountDBase { public: - // MARK: - Types - - using base = active::database::Storage; - - using type_identity_t = std::type_identity>::type; - // MARK: - Constructors /*! @@ -38,7 +23,7 @@ namespace speckle::database { Copy constructor @param source The object to copy */ - AccountDBase(const AccountDBase& source) : base{source} {} + AccountDBase(const AccountDBase& source) {} /*! Destructor */ @@ -46,9 +31,18 @@ namespace speckle::database { // MARK: - Functions (const) + /*! + Get all accounts + @return All the accounts + */ + active::container::Vector getAccounts() const; // MARK: - Functions (mutating) - + + private: + class Store; + ///Accounts database storage + std::unique_ptr m_store; }; }