diff --git a/src/api/lrc.h b/src/api/lrc.h index 67b7a50b97dfcc5407e3633d4f4740194c777ae7..39dc20a9488cc5eae623160f22ca0efa3b8e71bd 100644 --- a/src/api/lrc.h +++ b/src/api/lrc.h @@ -27,8 +27,6 @@ namespace lrc { -class Database; -class CallbacksHandler; class LrcPimpl; namespace api @@ -40,8 +38,11 @@ class LIB_EXPORT Lrc { public: Lrc(); ~Lrc(); - - NewAccountModel& getAccountModel(); + /** + * get a reference on account model. + * @return a NewAccountModel&. + */ + const NewAccountModel& getAccountModel() const; private: std::unique_ptr<LrcPimpl> lrcPipmpl_; diff --git a/src/lrc.cpp b/src/lrc.cpp index e73838d2e406ec6724915c8fc5cea39839281347..8275afaf6fe6f3c00432718fb47ecc6281ef581c 100644 --- a/src/lrc.cpp +++ b/src/lrc.cpp @@ -32,16 +32,16 @@ class LrcPimpl { public: - LrcPimpl(); + LrcPimpl(const Lrc& linked); - std::unique_ptr<Lrc> parent; + const Lrc& linked; std::unique_ptr<Database> database; - std::unique_ptr<NewAccountModel> accountModel; std::unique_ptr<CallbacksHandler> callbackHandler; + std::unique_ptr<NewAccountModel> accountModel; }; Lrc::Lrc() -: lrcPipmpl_(std::make_unique<LrcPimpl>()) +: lrcPipmpl_(std::make_unique<LrcPimpl>(*this)) { } @@ -49,15 +49,19 @@ Lrc::~Lrc() { } -NewAccountModel& -Lrc::getAccountModel() +const NewAccountModel& +Lrc::getAccountModel() const { 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