diff options
author | Remko Tronçon <git@el-tramo.be> | 2011-04-09 07:54:44 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2011-04-18 19:11:41 (GMT) |
commit | e3d2137622cea23298f203801bc698eff08e0ea1 (patch) | |
tree | e8d02f3334a6422e25ca5f30606850d960b27cc7 /Swiften/Roster | |
parent | 01385d84f07466550fff702079555c65963463a8 (diff) | |
download | swift-e3d2137622cea23298f203801bc698eff08e0ea1.zip swift-e3d2137622cea23298f203801bc698eff08e0ea1.tar.bz2 |
Factor out payload persisting into utility classes.
Diffstat (limited to 'Swiften/Roster')
-rw-r--r-- | Swiften/Roster/RosterFileStorage.cpp | 18 | ||||
-rw-r--r-- | Swiften/Roster/RosterFileStorage.h | 7 |
2 files changed, 11 insertions, 14 deletions
diff --git a/Swiften/Roster/RosterFileStorage.cpp b/Swiften/Roster/RosterFileStorage.cpp index de7b442..31b6c5e 100644 --- a/Swiften/Roster/RosterFileStorage.cpp +++ b/Swiften/Roster/RosterFileStorage.cpp @@ -6,19 +6,21 @@ #include <Swiften/Roster/RosterFileStorage.h> -#include <boost/smart_ptr/make_shared.hpp> +#include <Swiften/Entity/GenericPayloadPersister.h> +#include <Swiften/Serializer/PayloadSerializers/RosterSerializer.h> +#include <Swiften/Parser/PayloadParsers/RosterParser.h> -namespace Swift { +using namespace Swift; + +typedef GenericPayloadPersister<RosterPayload, RosterParser, RosterSerializer> RosterPersister; RosterFileStorage::RosterFileStorage(const boost::filesystem::path& path) : path(path) { } -// FIXME -void RosterFileStorage::setRoster(boost::shared_ptr<RosterPayload> r) { - roster.reset(); - if (r) { - roster = boost::make_shared<RosterPayload>(*r); - } +boost::shared_ptr<RosterPayload> RosterFileStorage::getRoster() const { + return RosterPersister().loadPayloadGeneric(path); } +void RosterFileStorage::setRoster(boost::shared_ptr<RosterPayload> roster) { + RosterPersister().savePayload(roster, path); } diff --git a/Swiften/Roster/RosterFileStorage.h b/Swiften/Roster/RosterFileStorage.h index dc91c27..cb00969 100644 --- a/Swiften/Roster/RosterFileStorage.h +++ b/Swiften/Roster/RosterFileStorage.h @@ -15,15 +15,10 @@ namespace Swift { public: RosterFileStorage(const boost::filesystem::path& path); - // FIXME - virtual boost::shared_ptr<RosterPayload> getRoster() const { - return roster; - } - + virtual boost::shared_ptr<RosterPayload> getRoster() const; virtual void setRoster(boost::shared_ptr<RosterPayload>); private: boost::filesystem::path path; - boost::shared_ptr<RosterPayload> roster; }; } |