Skip to content
Snippets Groups Projects
Commit 288c1e92 authored by Nicolas Jager's avatar Nicolas Jager Committed by Guillaume Roguez
Browse files

Lrc: implementation


- Pimpl
- make const the return type of getAccountModel()

Change-Id: Id38179ea9271e906f52a2c4ace64b3860c8bebc4
Reviewed-by: default avatarGuillaume Roguez <guillaume.roguez@savoirfairelinux.com>
Signed-off-by: default avatarGuillaume Roguez <guillaume.roguez@savoirfairelinux.com>
parent e8dda4e6
No related branches found
No related tags found
No related merge requests found
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
namespace lrc namespace lrc
{ {
class Database;
class CallbacksHandler;
class LrcPimpl; class LrcPimpl;
namespace api namespace api
...@@ -40,8 +38,11 @@ class LIB_EXPORT Lrc { ...@@ -40,8 +38,11 @@ class LIB_EXPORT Lrc {
public: public:
Lrc(); Lrc();
~Lrc(); ~Lrc();
/**
NewAccountModel& getAccountModel(); * get a reference on account model.
* @return a NewAccountModel&.
*/
const NewAccountModel& getAccountModel() const;
private: private:
std::unique_ptr<LrcPimpl> lrcPipmpl_; std::unique_ptr<LrcPimpl> lrcPipmpl_;
......
...@@ -32,16 +32,16 @@ class LrcPimpl ...@@ -32,16 +32,16 @@ class LrcPimpl
{ {
public: public:
LrcPimpl(); LrcPimpl(const Lrc& linked);
std::unique_ptr<Lrc> parent; const Lrc& linked;
std::unique_ptr<Database> database; std::unique_ptr<Database> database;
std::unique_ptr<NewAccountModel> accountModel;
std::unique_ptr<CallbacksHandler> callbackHandler; std::unique_ptr<CallbacksHandler> callbackHandler;
std::unique_ptr<NewAccountModel> accountModel;
}; };
Lrc::Lrc() Lrc::Lrc()
: lrcPipmpl_(std::make_unique<LrcPimpl>()) : lrcPipmpl_(std::make_unique<LrcPimpl>(*this))
{ {
} }
...@@ -49,15 +49,19 @@ Lrc::~Lrc() ...@@ -49,15 +49,19 @@ Lrc::~Lrc()
{ {
} }
NewAccountModel& const NewAccountModel&
Lrc::getAccountModel() Lrc::getAccountModel() const
{ {
return *lrcPipmpl_->accountModel; return *lrcPipmpl_->accountModel;
} }
LrcPimpl::LrcPimpl() LrcPimpl::LrcPimpl(const Lrc& linked)
: linked(linked)
, database(std::make_unique<Database>())
, callbackHandler(std::make_unique<CallbacksHandler>())
, accountModel(std::make_unique<NewAccountModel>(*database))
{ {
database = std::make_unique<Database>();
} }
} // namespace lrc } // namespace lrc
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment