diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-09-05 11:59:27 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-09-05 11:59:27 +0200 |
commit | 47e38764ebc759c0884921cfb594a215a88dcb98 (patch) | |
tree | 3b11cc7dcccbb54bbf7517ecf988d773d901331b /boost/employee.hxx | |
parent | c97a759dcc080705c956c87fce076709ca66a0c8 (diff) |
Support for Boost uuid persistence
New Boost sub-profile: uuid. New test: boost/common/uuid. Updated the
boost example to use uuid as an object id.
Diffstat (limited to 'boost/employee.hxx')
-rw-r--r-- | boost/employee.hxx | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/boost/employee.hxx b/boost/employee.hxx index 89aec1f..8d6173a 100644 --- a/boost/employee.hxx +++ b/boost/employee.hxx @@ -11,6 +11,8 @@ #include <boost/weak_ptr.hpp> #include <boost/optional.hpp> #include <boost/unordered_set.hpp> +#include <boost/uuid/uuid.hpp> +#include <boost/uuid/uuid_generators.hpp> #include <boost/date_time/gregorian/gregorian.hpp> #include <odb/core.hxx> @@ -23,6 +25,7 @@ using boost::weak_ptr; using odb::boost::lazy_shared_ptr; using odb::boost::lazy_weak_ptr; +using boost::uuids::uuid; using boost::gregorian::date; // Forward declarations. @@ -86,7 +89,8 @@ public: const std::string& last, const date& born, shared_ptr<employer_type> employer) - : first_ (first), last_ (last), + : id_ (boost::uuids::random_generator () ()), + first_ (first), last_ (last), born_ (born), employer_ (employer) { @@ -97,12 +101,21 @@ public: const std::string& last, const date& born, shared_ptr<employer_type> employer) - : first_ (first), middle_ (middle), last_ (last), + : id_ (boost::uuids::random_generator () ()), + first_ (first), middle_ (middle), last_ (last), born_ (born), employer_ (employer) { } + // Id. + // + const uuid& + id () const + { + return id_; + } + // Name. // const std::string& @@ -166,8 +179,8 @@ private: employee () {} - #pragma db id auto - unsigned long id_; + #pragma db id + uuid id_; std::string first_; boost::optional<std::string> middle_; |