|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r83164 - sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1
From: afojgo_at_[hidden]
Date: 2013-02-26 13:34:28
Author: jofaber
Date: 2013-02-26 13:34:26 EST (Tue, 26 Feb 2013)
New Revision: 83164
URL: http://svn.boost.org/trac/boost/changeset/83164
Log:
Merging on trees with value semantics.
Added:
sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/Object_03.h (contents, props changed)
sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/TreeSync1_11.vcproj (contents, props changed)
sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/Tree_03.h (contents, props changed)
sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/std_algorithm.h (contents, props changed)
sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/std_utils.h (contents, props changed)
Text files modified:
sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/Object.h | 55 ++++++++--
sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/Tree.h | 197 ++++++++++++++++++++++++++++++++++++---
sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/TreeSync1.cpp | 61 +++++++----
3 files changed, 261 insertions(+), 52 deletions(-)
Modified: sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/Object.h
==============================================================================
--- sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/Object.h (original)
+++ sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/Object.h 2013-02-26 13:34:26 EST (Tue, 26 Feb 2013)
@@ -3,7 +3,7 @@
#include <string>
#include <iostream>
#include <typeinfo>
-#include <boost/smart_ptr/shared_ptr.hpp>
+#include <memory>
template<class T>
void draw(const T& x, std::ostream& out, size_t pos)
@@ -15,33 +15,53 @@
{
public:
template<class Model>
- object(const Model& x) : m_object(new model<Model>(x)){ }
+ object(Model const& value) : m_value(new model<Model>(value)){ }
- object(const object& x) : m_object(x.m_object->copy()){ }
+ object(object const& value) : m_value(value.m_value->copy()){ }
- object& operator = (const object& x)
- { m_object.reset(x.m_object->copy()); return *this; }
+ object(object&& value): m_value(std::move(value.m_value)){};
- friend void draw(const object& x, std::ostream& out, size_t pos)
+ object& operator = (object value)
+ { m_value = std::move(value.m_value); return *this; }
+
+ friend void draw(const object& value, std::ostream& out, size_t pos)
{
- x.m_object->draw_(out, pos);
+ value.m_value->draw_(out, pos);
}
- friend std::string type_name(const object& x){ return x.m_object->type_name_(); }
+ friend std::string type_name(object const& value){ return value.m_value->type_name_(); }
+
+ friend bool is_less(object const& lhs, object const& rhs)
+ {
+ return lhs.m_value->is_less_(*rhs.m_value->as_model());
+ }
private:
struct concept
{
virtual ~concept() {}
virtual concept* copy() = 0;
+ virtual concept* as_model() = 0;
+
+ virtual bool is_less_(concept const& rhs)const = 0;
virtual void draw_(std::ostream&, size_t)const = 0;
virtual std::string type_name_()const = 0;
+
};
template<class Model> struct model : concept
{
- model( const Model& x) : m_model(x) {}
+ model(Model const& val) : m_model(val) {}
concept* copy(){ return new model(*this); }
+
+ concept* as_model() { return this; }
+
+ bool is_less_(concept const& rhs)const
+ {
+ //return is_less(m_model, dynamic_cast<model const&>(rhs).m_model);
+ return m_model < dynamic_cast<model const&>(rhs).m_model;
+ }
+
void draw_(std::ostream& out, size_t pos)const
{
//out << std::string(pos, ' ') << "{ " << type_name() << " }";
@@ -55,10 +75,19 @@
};
private:
- boost::shared_ptr<concept> m_object;
+ std::unique_ptr<concept> m_value;
};
+// friend enabled gate to polymorphic objects
+bool operator < (object const& lhs, object const& rhs){ return is_less(lhs, rhs); }
+
+
+// 30:13 unsave operator= using delete / new. (defects)
+// 30:25 operator= via unique_ptr and reset.
+// 34:15 rewrite assignment using pass by value and move.
+// 34:48 Pass sink arguments by value.
+// 39:58 Introducing move ctor.
+// 50:10 refactoring: (member) function templates across models
+// 50:19 refactoring local models structs to a template
+//1:06:00 Undo history and copy_on_write
-//30:25 operator= via unique_ptr.
-//50:10 refactoring: (member) function templates across models
-//50:19 refactoring local models structs to a template
\ No newline at end of file
Added: sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/Object_03.h
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/Object_03.h 2013-02-26 13:34:26 EST (Tue, 26 Feb 2013)
@@ -0,0 +1,64 @@
+#pragma once
+
+#include <string>
+#include <iostream>
+#include <typeinfo>
+#include <boost/smart_ptr/shared_ptr.hpp>
+
+template<class T>
+void draw(const T& x, std::ostream& out, size_t pos)
+{
+ out << std::string(pos, ' ') << x << std::endl;
+}
+
+class object
+{
+public:
+ template<class Model>
+ object(const Model& x) : m_object(new model<Model>(x)){ }
+
+ object(const object& x) : m_object(x.m_object->copy()){ }
+
+ object& operator = (const object& x)
+ { m_object.reset(x.m_object->copy()); return *this; }
+
+ friend void draw(const object& x, std::ostream& out, size_t pos)
+ {
+ x.m_object->draw_(out, pos);
+ }
+
+ friend std::string type_name(const object& x){ return x.m_object->type_name_(); }
+
+private:
+ struct concept
+ {
+ virtual ~concept() {}
+ virtual concept* copy() = 0;
+ virtual void draw_(std::ostream&, size_t)const = 0;
+ virtual std::string type_name_()const = 0;
+ };
+
+ template<class Model> struct model : concept
+ {
+ model( const Model& x) : m_model(x) {}
+ concept* copy(){ return new model(*this); }
+ void draw_(std::ostream& out, size_t pos)const
+ {
+ //out << std::string(pos, ' ') << "{ " << type_name() << " }";
+ draw(m_model, out, pos);
+ }
+
+ //std::string type_name()const { return typeid(m_model).name(); }
+ std::string type_name_()const{ return type_name(m_model); }
+
+ Model m_model;
+ };
+
+private:
+ boost::shared_ptr<concept> m_object;
+};
+
+
+//30:25 operator= via unique_ptr.
+//50:10 refactoring: (member) function templates across models
+//50:19 refactoring local models structs to a template
\ No newline at end of file
Modified: sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/Tree.h
==============================================================================
--- sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/Tree.h (original)
+++ sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/Tree.h 2013-02-26 13:34:26 EST (Tue, 26 Feb 2013)
@@ -2,6 +2,7 @@
#include <ostream>
#include <vector>
+#include "std_algorithm.h"
#include "Object.h"
typedef int tUuid;
@@ -23,6 +24,35 @@
Uuid m_uuid;
};
+
+template<class Uuid, class Time>
+bool operator < (Playable<Uuid,Time> const& lhs, Playable<Uuid,Time> const& rhs)
+{
+ return lhs.time() < rhs.time();
+}
+
+template<class Comparable>
+struct Minimum
+{
+ Comparable operator()(Comparable const& lhs, Comparable const& rhs)
+ { return rhs < lhs ? rhs : lhs; }
+};
+
+template<class Comparable>
+struct Maximum
+{
+ Comparable operator()(Comparable const& lhs, Comparable const& rhs)
+ { return lhs < rhs ? rhs : lhs; }
+};
+
+template<class Mergable>
+struct Merger
+{
+ Mergable operator()(Mergable const& lhs, Mergable const& rhs)
+ { return merge(lhs, rhs); }
+};
+
+
template<class CharType, class CharTraits, class Uuid>
std::basic_ostream<CharType, CharTraits>&
operator << (std::basic_ostream<CharType, CharTraits> &stream, Playable<Uuid> const& object)
@@ -34,20 +64,59 @@
template<class Type, class Uuid = int, class Time = int>
struct Vec
{
- typedef std::vector<object> tVector;
- typedef tVector::iterator iterator;
- typedef tVector::const_iterator const_iterator;
- typedef tVector::value_type value_type;
+ typedef std::vector<Type> tVector;
+
+ typedef typename tVector::size_type size_type;
+ typedef typename tVector::value_type value_type;
+ typedef Type ValueType;
+ typedef typename tVector::const_reference const_reference;
+
+ typedef typename tVector::iterator iterator;
+ typedef typename tVector::const_iterator const_iterator;
Vec(): m_uuid(), m_time(), m_name(), m_vector() {}
Vec(Uuid const& uuid, Time const& time, std::string const& name)
: m_uuid(uuid), m_time(time), m_name(name), m_vector() {}
+ Vec(Vec const& val) : m_vector(val.m_vector)
+ , m_uuid(val.m_uuid)
+ , m_time(val.m_time)
+ , m_name(val.m_name)
+ {
+ //std::cout << "c() ";
+ }
+
+ Vec(Vec&& val): m_vector(std::move(val.m_vector))
+ , m_uuid(std::move(val.m_uuid))
+ , m_time(std::move(val.m_time))
+ , m_name(std::move(val.m_name))
+ {
+ //std::cout << "m() ";
+ };
+
+ Vec& operator = (Vec 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= ";
+ 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(); }
+
+ //void push_back(const value_type& val)
void push_back(const Type& val)
{
+ //JODO
m_time = std::max(m_time, val.time());
m_vector.push_back(val);
}
@@ -66,14 +135,26 @@
tVector m_vector;
};
+template<class Type, class Uuid, class Time>
+bool operator < (Vec<Type,Uuid,Time> const& lhs, Vec<Type,Uuid,Time> const& rhs)
+{
+ return lhs.time() < rhs.time();
+}
template<class Content, class Uuid = int, class Time = int>
class Node
{
public:
+ typedef Content ContentType;
typedef Vec<Content> ContentVec;
typedef Vec<Node> NodeVec;
+ typedef typename ContentVec::const_iterator element_const_iterator;
+ typedef typename ContentVec::iterator element_iterator;
+
+ typedef typename NodeVec::const_iterator node_const_iterator;
+ typedef typename NodeVec::iterator node_iterator;
+
Node( Uuid const& uuid = 0, std::string const& name = std::string()
, const ContentVec& content = ContentVec(), const NodeVec& children = NodeVec())
@@ -83,10 +164,30 @@
m_time = std::max(m_content.time(), m_children.time());
}
+ element_const_iterator elements_begin()const { return m_content.begin(); }
+ element_const_iterator elements_end()const { return m_content.end(); }
+ element_iterator elements_begin() { return m_content.begin(); }
+ element_iterator elements_end() { return m_content.end(); }
+ int element_count()const { return m_content.size(); }
+
+ node_const_iterator nodes_begin()const { return m_children.begin(); }
+ node_const_iterator nodes_end()const { return m_children.end(); }
+ node_iterator nodes_begin() { return m_children.begin(); }
+ node_iterator nodes_end() { return m_children.end(); }
+ int node_count()const { return m_children.size(); }
+
+
+
Uuid uuid()const { return m_uuid; }
Time time()const { return m_time; }
std::string name()const { return m_name; }
+ void setUuid(Uuid const& uuid) { m_uuid=uuid; }
+ void setTime(Time const& time) { m_time=time; }
+ void setName(std::string& name){ m_name=name; }
+ void setContent(ContentVec content){ m_content = std::move(content); };
+ void setChildren(NodeVec nodes){ m_children = std::move(nodes); };
+
ContentVec content()const { return m_content; }
NodeVec children()const { return m_children; }
@@ -98,6 +199,7 @@
NodeVec m_children;
};
+
template<class Type>
void draw(const Node<Type>& obj, std::ostream& out, size_t pos)
{
@@ -109,21 +211,84 @@
out << std::string(pos,' ') << "</Node>\n";
}
-/*
+
template<class Type>
Node<Type> merge(const Node<Type>& lhs, const Node<Type>& rhs)
-{
+{
+ typedef typename Node<Type>::ContentVec ContentVec;
Node<Type> merged;
- m_uuid = lhs.uuid();
- m_time = std::max(lhs.time(), rhs.time());
+ merged.setUuid(lhs.uuid());
+ merged.setTime(std::max(lhs.time(), rhs.time()));
+
+ merged.setContent(mergeElements(lhs, rhs));
+ merged.setChildren(mergeNodes(lhs, rhs));
+
+ return std::move(merged);
+}
+
+
+template<class Type>
+typename Node<Type>::ContentVec mergeElements(Node<Type>const& lhs, Node<Type>const& rhs)
+{
+ typedef Node<Type>::ContentVec Elements;
+ typedef Elements::ValueType ElementType;
+
+ Elements merged;
+ merged.reserve(lhs.element_count() + rhs.element_count());
+
+ std::general_union( lhs.elements_begin(), lhs.elements_end()
+ , rhs.elements_begin(), rhs.elements_end()
+ , Maximum<ElementType>()
+ , std::back_inserter(merged) );
+
+ return std::move(merged);
+}
+
+
+template<class Type>
+typename Node<Type>::NodeVec mergeNodes(Node<Type>const& lhs, Node<Type>const& rhs)
+{
+ typedef Node<Type>::NodeVec Nodes;
+ typedef typename Nodes::ValueType NodeType;
+
+ Nodes merged;
+ merged.reserve(lhs.node_count() + rhs.node_count());
- for( ContentVec::const_iterator cont_it = m_content.begin()
- ; cont_it != m_content.end(); ++ cont_it)
- {
- merged.push_back(merge(*cont_it), );
- }
- merged.setContent(merge_content(lhs, rhs));
- merged.setChildren(merge_children(lhs, rhs));
+ std::general_union( lhs.nodes_begin(), lhs.nodes_end()
+ , rhs.nodes_begin(), rhs.nodes_end()
+ , Merger<NodeType>()
+ , std::back_inserter(merged) );
+
+ return std::move(merged);
}
-*/
+
+
+template<class Type>
+void sort(Node<Type>& val)
+{
+ typedef typename Node<Type>::ContentVec ContentVec;
+ Node<Type> sorted;
+
+ sortElements(val);
+ sortNodes(val);
+}
+
+template<class Type> struct Sorter
+{
+ void operator()(Type& value){ sort(value); }
+};
+
+template<class Type>
+void sortElements(Node<Type>& val)
+{
+ std::sort( val.elements_begin(), val.elements_end());
+}
+
+template<class Type>
+void sortNodes(Node<Type>& val)
+{
+ std::sort( val.nodes_begin(), val.nodes_end());
+ std::for_each(val.nodes_begin(), val.nodes_end(), Sorter<Node<Type> >());
+}
+
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-02-26 13:34:26 EST (Tue, 26 Feb 2013)
@@ -44,10 +44,11 @@
template<class Type>
void draw(const Vec<Type>& obj, std::ostream& out, size_t pos)
{
+ typedef typename Vec<Type>::const_iterator citer;
out << std::string(pos,' ')
//<< type_name(obj) << "{\n";
<< "<Vec>[" << obj.name() << "](" << obj.uuid() << "," << obj.time() << ")\n";
- for(coll_citer it = obj.begin(); it != obj.end(); ++it)
+ for(citer it = obj.begin(); it != obj.end(); ++it)
draw(*it, out, pos+2);
out << std::string(pos,' ')
@@ -63,31 +64,45 @@
coll.push_back(42);
+ //--- Playlist --------------------
Playlist pl1(1, 2, " pl_1 ");
- pl1.push_back(Playable<int>(43));
- pl1.push_back(Playable<int>(44));
+ pl1.push_back(Playable<int>(11));
+ pl1.push_back(Playable<int>(12));
- Playlist pl2(2, 4, " pl_2 ");
- pl2.push_back(Playable<int>(53));
- pl2.push_back(Playable<int>(54));
- //draw(pl, std::cout, 0);
-
-
- Playlists pls1(3, 3, " pls_1 ");
- pls1.push_back(pl1);
- Playlists pls2(4, 3, " pls_1 ");
- pls2.push_back(pl2);
-
- Node<Playlist> node1(5, " node_1 ", pls1);
- NodeList nodes1(5, 2, " nodes_1 ");
- nodes1.push_back(node1);
-
- Node<Playlist> node2(6, " node_2 ", pls2, nodes1);
-
- //coll.push_back(node1);
- //coll.push_back(node2);
+ Playlist pl2(2, 5, " pl_2 ");
+ pl2.push_back(Playable<int>(21));
+ pl2.push_back(Playable<int>(22));
+
+ Playlist pl3(3, 3, " pl_3 ");
+ pl2.push_back(Playable<int>(31));
+
+
+ //--- Playlists -------------------
+ Playlists pls1(4, 0, " pls_1 ");
+ pls1.push_back(pl1);
+ pls1.push_back(pl3);
+
+ Playlists pls2(5, 0, " pls_1 ");
+ pls2.push_back(pl2);
+ pls2.push_back(pl3);
+
+ //--- Nodes -----------------------
+ Node<Playlist> node1(6, " node_1 ", pls1);
+ NodeList nodes1(7, 2, " nodes_1 ");
+ nodes1.push_back(node1);
+
+ Node<Playlist> node2(8, " node_2 ", pls2, nodes1);
+
+ //=================================
+ draw(node2, std::cout, 0);
+
+ std::cout << "========================================\n";
+ //Node<Playlist> merged = merge(node1, node2);
+ //draw(merged, std::cout, 0);
+
+ sort(node2);
draw(node2, std::cout, 0);
- return 0;
+ return 0;
}
Added: sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/TreeSync1_11.vcproj
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/TreeSync1_11.vcproj 2013-02-26 13:34:26 EST (Tue, 26 Feb 2013)
@@ -0,0 +1,227 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="TreeSync1"
+ ProjectGUID="{12A9496D-1829-410E-9F6E-76908EFF025A}"
+ RootNamespace="TreeSync1"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="C:\NIBuild\3rdparty\boost-1.51.0-R4"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="2"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories="C:\NIBuild\3rdparty\boost-1.51.0-R4"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\stdafx.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\TreeSync1.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\stdafx.h"
+ >
+ </File>
+ <File
+ RelativePath=".\targetver.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ <File
+ RelativePath=".\ReadMe.txt"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/Tree_03.h
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/Tree_03.h 2013-02-26 13:34:26 EST (Tue, 26 Feb 2013)
@@ -0,0 +1,133 @@
+#pragma once
+
+#include <ostream>
+#include <vector>
+#include "Object.h"
+
+typedef int tUuid;
+typedef int tTime;
+
+
+template<class Uuid, class Time = int>
+class Playable
+{
+public:
+ Playable(Uuid uuid)
+ : m_uuid(uuid)
+ { }
+
+ Uuid uuid()const { return m_uuid; }
+ Time time()const { return Time(); } //JODO
+
+private:
+ Uuid m_uuid;
+};
+
+template<class CharType, class CharTraits, class Uuid>
+std::basic_ostream<CharType, CharTraits>&
+operator << (std::basic_ostream<CharType, CharTraits> &stream, Playable<Uuid> const& object)
+{
+ return stream << "Play(" << object.uuid() << ")";
+}
+
+
+template<class Type, class Uuid = int, class Time = int>
+struct Vec
+{
+ typedef std::vector<object> tVector;
+ typedef tVector::iterator iterator;
+ typedef tVector::const_iterator const_iterator;
+ typedef tVector::value_type value_type;
+
+ Vec(): m_uuid(), m_time(), m_name(), m_vector() {}
+ Vec(Uuid const& uuid, Time const& time, std::string const& name)
+ : m_uuid(uuid), m_time(time), m_name(name), m_vector() {}
+
+ const_iterator begin()const { return m_vector.begin(); }
+ const_iterator end()const { return m_vector.end(); }
+
+ void push_back(const Type& val)
+ {
+ m_time = std::max(m_time, val.time());
+ m_vector.push_back(val);
+ }
+
+ Uuid uuid()const { return m_uuid; }
+ Time time()const { return m_time; }
+ std::string name()const { return m_name; }
+
+ void setUuid(Uuid const& uuid){ m_uuid = uuid; }
+ void setTime(Time const& time){ m_time = time; }
+ void name(std::string const& name)const { m_name = name; }
+
+ Uuid m_uuid;
+ Time m_time;
+ std::string m_name;
+ tVector m_vector;
+};
+
+
+template<class Content, class Uuid = int, class Time = int>
+class Node
+{
+public:
+ typedef Vec<Content> ContentVec;
+ typedef Vec<Node> NodeVec;
+
+
+ Node( Uuid const& uuid = 0, std::string const& name = std::string()
+ , const ContentVec& content = ContentVec(), const NodeVec& children = NodeVec())
+ : m_uuid(uuid), m_name(name)
+ , m_content(content), m_children(children)
+ {
+ m_time = std::max(m_content.time(), m_children.time());
+ }
+
+ Uuid uuid()const { return m_uuid; }
+ Time time()const { return m_time; }
+ std::string name()const { return m_name; }
+
+ ContentVec content()const { return m_content; }
+ NodeVec children()const { return m_children; }
+
+private:
+ Uuid m_uuid;
+ Time m_time;
+ std::string m_name;
+ ContentVec m_content;
+ NodeVec m_children;
+};
+
+template<class Type>
+void draw(const Node<Type>& obj, std::ostream& out, size_t pos)
+{
+ out << std::string(pos,' ') << "<Node>[" << obj.name() << "](" << obj.uuid() << "," << obj.time() <<")\n";
+
+ draw(obj.content(), out, pos+2);
+ draw(obj.children(), out, pos+2);
+
+ out << std::string(pos,' ') << "</Node>\n";
+}
+
+
+/*
+template<class Type>
+Node<Type> merge(const Node<Type>& lhs, const Node<Type>& rhs)
+{
+ Node<Type> merged;
+ m_uuid = lhs.uuid();
+ m_time = std::max(lhs.time(), rhs.time());
+
+ for( ContentVec::const_iterator cont_it = m_content.begin()
+ ; cont_it != m_content.end(); ++ cont_it)
+ {
+ merged.push_back(merge(*cont_it), );
+ }
+ merged.setContent(merge_content(lhs, rhs));
+ merged.setChildren(merge_children(lhs, rhs));
+}
+*/
+
+
+
+
Added: sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/std_algorithm.h
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/std_algorithm.h 2013-02-26 13:34:26 EST (Tue, 26 Feb 2013)
@@ -0,0 +1,30 @@
+#pragma once
+
+#include <algorithm>
+
+namespace std
+{
+
+template <class InputIterator1, class InputIterator2, class OutputIterator, class Merger>
+ OutputIterator general_union(InputIterator1 first1, InputIterator1 last1,
+ InputIterator2 first2, InputIterator2 last2,
+ Merger merger,
+ OutputIterator result)
+{
+ while (true)
+ {
+ if (first1==last1) return std::copy(first2,last2,result);
+ if (first2==last2) return std::copy(first1,last1,result);
+
+ if (*first1 < *first2) { *result = *first1; ++first1; }
+ else if (*first2 < *first1) { *result = *first2; ++first2; }
+ else {
+ // *first1 == *first2
+ *result = merger(*first1, *first2);
+ ++first1; ++first2;
+ }
+ ++result;
+ }
+}
+
+} //std
\ No newline at end of file
Added: sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/std_utils.h
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/value_sem/TreeSync1/TreeSync1/std_utils.h 2013-02-26 13:34:26 EST (Tue, 26 Feb 2013)
@@ -0,0 +1,13 @@
+#pragma once
+
+namespace std{
+
+template<typename T, typename... Args>
+std::unique_ptr<T> make_unique(Args&&... args)
+{
+ return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
+}
+
+}
+
+
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