Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r83326 - in sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1: . Syncable
From: afojgo_at_[hidden]
Date: 2013-03-05 18:26:39


Author: jofaber
Date: 2013-03-05 18:26:38 EST (Tue, 05 Mar 2013)
New Revision: 83326
URL: http://svn.boost.org/trac/boost/changeset/83326

Log:
Added lightweight abstraction.
Added:
   sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/Syncable/Syncable_Light.h (contents, props changed)
Text files modified:
   sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/Seans_Magic.h | 1
   sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/Syncable/Vector.h | 53 ++++++++++++++++++---------------------
   sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/TreeMaker.h | 4 +++
   sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/TreeMerge.h | 3 +
   sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/TreeSync1.cpp | 3 +
   5 files changed, 33 insertions(+), 31 deletions(-)

Modified: sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/Seans_Magic.h
==============================================================================
--- sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/Seans_Magic.h (original)
+++ sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/Seans_Magic.h 2013-03-05 18:26:38 EST (Tue, 05 Mar 2013)
@@ -1,5 +1,6 @@
 #pragma once
 
+#include <memory>
 #include <string>
 #include <iostream>
 

Added: sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/Syncable/Syncable_Light.h
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/Syncable/Syncable_Light.h 2013-03-05 18:26:38 EST (Tue, 05 Mar 2013)
@@ -0,0 +1,53 @@
+#pragma once
+
+//#include <boost/utility/enable_if.hpp>
+//#include "Syncable/Syncable_ModeledBy.h"
+typedef int tUuid;
+typedef int tTime;
+
+template<class Model>
+tUuid uuid(Model const& object)
+{
+ return object.uuid();
+}
+
+template<class Model>
+tTime time(Model const& object)
+{
+ return object.time();
+}
+
+template<class Model>
+bool less_for_time(Model const& lhs, Model const& rhs)
+{
+ return lhs.time() < rhs.time();
+}
+
+template<class Model>
+bool less_for_uuid(Model const& lhs, Model const& rhs)
+{
+ return lhs.uuid() < rhs.uuid();
+}
+
+template<class Syncable>
+struct LessForUuid : std::binary_function<Syncable, Syncable, bool>
+{
+ bool operator()(Syncable const& lhs, Syncable const& rhs)
+ {
+ return less_for_uuid(lhs, rhs);
+ }
+};
+
+template<class Syncable>
+struct LessForTime : std::binary_function<Syncable, Syncable, bool>
+{
+ typedef Syncable first_argument_type;
+ typedef Syncable second_argument_type;
+
+ bool operator()(Syncable const& lhs, Syncable const& rhs)
+ {
+ return less_for_time(lhs, rhs);
+ }
+};
+
+

Modified: sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/Syncable/Vector.h
==============================================================================
--- sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/Syncable/Vector.h (original)
+++ sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/Syncable/Vector.h 2013-03-05 18:26:38 EST (Tue, 05 Mar 2013)
@@ -5,72 +5,68 @@
 
 
 template<class Type, class UuidT = int, class TimeT = int>
-class Vector
+class Vector : private std::vector<Type>
 {
 public:
- typedef UuidT Uuid;
- typedef TimeT Time;
- typedef std::vector<Type> tVector;
-
- typedef typename tVector::size_type size_type;
- typedef typename tVector::value_type value_type;
- typedef typename tVector::const_reference const_reference;
+ typedef UuidT Uuid;
+ typedef TimeT Time;
+ typedef std::vector<Type> BaseT;
+
+ typedef typename BaseT::size_type size_type;
+ typedef typename BaseT::value_type value_type;
+ typedef typename BaseT::const_reference const_reference;
 
- typedef typename tVector::iterator iterator;
- typedef typename tVector::const_iterator const_iterator;
+ typedef typename BaseT::iterator iterator;
+ typedef typename BaseT::const_iterator const_iterator;
 
- Vector(): m_uuid(), m_time(), m_name("empty"), m_vector() {}
+ Vector(): BaseT(), m_uuid(), m_time(), m_name("empty"){}
 
   Vector(Uuid const& uuid, Time const& time, std::string const& name)
- : m_uuid(uuid), m_time(time), m_name(name), m_vector()
+ : BaseT(), m_uuid(uuid), m_time(time), m_name(name)
   {
   }
 
- Vector(Vector const& val) : m_vector(val.m_vector)
+ Vector(Vector const& val) : BaseT(val)
     , m_uuid(val.m_uuid)
     , m_time(val.m_time)
     , m_name(val.m_name)
   {
- std::cout << "c(" << m_vector.size() << ") ";
+ std::cout << "c(" << BaseT::size() << ") ";
   }
 
- Vector(Vector&& val): m_vector(std::move(val.m_vector))
+ Vector(Vector&& val): BaseT(std::move(val))
     , m_uuid(std::move(val.m_uuid))
     , m_time(std::move(val.m_time))
     , m_name(std::move(val.m_name))
   {
- std::cout << "m(" << m_vector.size() << ") ";
+ std::cout << "m(" << BaseT::size() << ") ";
   };
 
   Vector& operator = (Vector val)
   {
+ BaseT::operator = (std::move(val));
     m_uuid = std::move(val.m_uuid);
     m_time = std::move(val.m_time);
     m_name = std::move(val.m_name);
- m_vector = std::move(val.m_vector);
- std::cout << "m=" << m_vector.size() << " ";
+ std::cout << "m=" << BaseT::size() << " ";
     return *this;
   }
-
- const_iterator begin()const { return m_vector.begin(); }
- const_iterator end()const { return m_vector.end(); }
 
- iterator begin() { return m_vector.begin(); }
- iterator end() { return m_vector.end(); }
-
- void reserve(size_type size){ m_vector.reserve(size); }
- size_type size()const { return m_vector.size(); }
+ using BaseT::begin;
+ using BaseT::end;
+ using BaseT::reserve;
+ using BaseT::size;
 
   void emplace_back(Type val)
   {
     m_time = std::move(std::max(m_time, val.time()));
- m_vector.emplace_back(val);
+ BaseT::emplace_back(std::move(val));
   }
 
   void push_back(const Type& val)
   {
     m_time = std::max(m_time, val.time());
- m_vector.push_back(val);
+ BaseT::push_back(val);
   }
 
   Uuid uuid()const { return m_uuid; }
@@ -86,7 +82,6 @@
   Uuid m_uuid;
   Time m_time;
   std::string m_name;
- tVector m_vector;
 };
 
 

Modified: sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/TreeMaker.h
==============================================================================
--- sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/TreeMaker.h (original)
+++ sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/TreeMaker.h 2013-03-05 18:26:38 EST (Tue, 05 Mar 2013)
@@ -12,13 +12,16 @@
 Playlists content_1(int uuid, std::string const& name)
 {
       Playlist pl1(3, 2, " pl_1 ");
+ pl1.reserve(2);
         pl1.emplace_back(Playable<int>(11));
 
       Playlist pl2(2, 5, " pl_2 ");
+ pl2.reserve(2);
         pl2.emplace_back(Playable<int>(22));
         pl2.emplace_back(Playable<int>(21));
 
   Playlists pls1(uuid, 0, name);
+ pls1.reserve(2);
     pls1.emplace_back(std::move(pl1));
     pls1.emplace_back(std::move(pl2));
 
@@ -29,6 +32,7 @@
 {
 
       Playlist pl1(3, 6, " pl_3 ");
+ pl1.reserve(3);
         pl1.emplace_back(Playable<int>(11));
         pl1.emplace_back(Playable<int>(12));
         pl1.emplace_back(Playable<int>(11));

Modified: sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/TreeMerge.h
==============================================================================
--- sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/TreeMerge.h (original)
+++ sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/TreeMerge.h 2013-03-05 18:26:38 EST (Tue, 05 Mar 2013)
@@ -4,7 +4,8 @@
 #include <iterator>
 #include "std_algorithm.h"
 
-#include "Syncable/Syncable_Concept.h"
+//JODO #include "Syncable/Syncable_Concept.h"
+#include "Syncable/Syncable_Light.h"
 #include "Syncable/Vector.h"
 #include "Syncable/Node.h"
 #include "Playable.h"

Modified: sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/TreeSync1.cpp
==============================================================================
--- sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/TreeSync1.cpp (original)
+++ sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/TreeSync1.cpp 2013-03-05 18:26:38 EST (Tue, 05 Mar 2013)
@@ -32,6 +32,7 @@
   Playlists content1 = content_1(4, " pls_1 ");
   NodeList children1 = children_0(5, 6, "children_1", content1);
 
+/*
   Playlists content2 = content_2(9, " pls_2 ");
   NodeList children2 = children_0(10, 6, "children_2", content1);
 
@@ -57,7 +58,7 @@
   std::cout << "\n<<merge ========================================\n";
   std::cout << "merged ========================================\n";
   draw(merged, std::cout, 0);
-
+*/
   return 0;
 }
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk