Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54359 - in sandbox/monotonic: boost/object_model boost/object_model/detail boost/object_model/generic boost/object_model/type libs/monotonic/test/Tests libs/object_model/src libs/object_model/src/generic libs/object_model/test
From: christian.schladetsch_at_[hidden]
Date: 2009-06-25 21:14:24


Author: cschladetsch
Date: 2009-06-25 21:14:21 EDT (Thu, 25 Jun 2009)
New Revision: 54359
URL: http://svn.boost.org/trac/boost/changeset/54359

Log:
added type/specifier.hpp and type/modifier.hpp

Added:
   sandbox/monotonic/boost/object_model/detail/make_method.hpp (contents, props changed)
   sandbox/monotonic/boost/object_model/generic/method.hpp (contents, props changed)
   sandbox/monotonic/boost/object_model/string.hpp (contents, props changed)
   sandbox/monotonic/boost/object_model/type/modifiers.hpp (contents, props changed)
   sandbox/monotonic/boost/object_model/type/signature.hpp (contents, props changed)
   sandbox/monotonic/boost/object_model/type/specifier.hpp (contents, props changed)
Text files modified:
   sandbox/monotonic/boost/object_model/builder.hpp | 11 ++++++--
   sandbox/monotonic/boost/object_model/dictionary.hpp | 13 ++++++++++
   sandbox/monotonic/boost/object_model/generic/object.hpp | 4 +++
   sandbox/monotonic/boost/object_model/generic/storage.hpp | 11 +++++++++
   sandbox/monotonic/libs/monotonic/test/Tests/Tests.vcproj | 8 +++++
   sandbox/monotonic/libs/monotonic/test/Tests/tests.cpp | 48 ++++++++++++++++++++++++++++++++++++++++
   sandbox/monotonic/libs/object_model/src/generic/object.cpp | 25 +++++++++++++-------
   sandbox/monotonic/libs/object_model/src/object_model.vcproj | 24 ++++++++++++++++++++
   sandbox/monotonic/libs/object_model/test/basic_tests.cpp | 18 ++++++++++++--
   9 files changed, 146 insertions(+), 16 deletions(-)

Modified: sandbox/monotonic/boost/object_model/builder.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/builder.hpp (original)
+++ sandbox/monotonic/boost/object_model/builder.hpp 2009-06-25 21:14:21 EDT (Thu, 25 Jun 2009)
@@ -20,11 +20,10 @@
         typedef type::traits<T> traits;
 
 private:
- registry<Allocator> &reg;
- klass<T> *my_klass;
+ klass<T, Allocator> *my_klass;
 
 public:
- builder(registry<Allocator> &R) : reg(R)
+ builder(registry<Allocator> &reg)
         {
                 my_klass = reg.register_class<T>();
         }
@@ -48,6 +47,12 @@
         } methods;
 };
 
+template <class T, class Al>
+builder<T,Al> class_builder(registry<Al> &reg)
+{
+ return builder<T,Al>(reg);
+}
+
 BOOST_OM_END
 
 #include <boost/object_model/detail/postfix.hpp>

Added: sandbox/monotonic/boost/object_model/detail/make_method.hpp
==============================================================================

Modified: sandbox/monotonic/boost/object_model/dictionary.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/dictionary.hpp (original)
+++ sandbox/monotonic/boost/object_model/dictionary.hpp 2009-06-25 21:14:21 EDT (Thu, 25 Jun 2009)
@@ -11,6 +11,7 @@
 
 #include <map>
 #include <boost/object_model/detail/prefix.hpp>
+#include <boost/object_model/label.hpp>
 
 BOOST_OM_BEGIN
 
@@ -19,6 +20,18 @@
         typedef std::map<label, generic::object> contents_type;
 
         contents_type contents;
+
+ void set(label const &name, generic::object const &obj)
+ {
+ contents[name] = obj;
+ }
+ generic::object get(label const &name) const
+ {
+ contents_type::const_iterator iter = contents.find(name);
+ if (iter == contents.end())
+ return null_object;
+ return iter->second;
+ }
 };
 
 BOOST_OM_END

Added: sandbox/monotonic/boost/object_model/generic/method.hpp
==============================================================================
--- (empty file)
+++ sandbox/monotonic/boost/object_model/generic/method.hpp 2009-06-25 21:14:21 EDT (Thu, 25 Jun 2009)
@@ -0,0 +1,33 @@
+// (C) 2009 Christian Schladetsch
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// documentation at https://svn.boost.org/svn/boost/sandbox/monotonic/libs/object_model/doc/index.html
+// sandbox at https://svn.boost.org/svn/boost/sandbox/monotonic/object_model/
+
+#ifndef BOOST_OBJECT_MODEL_(X)_HPP
+#define BOOST_OBJECT_MODEL_(X)_HPP
+
+#include <boost/object_model/detail/prefix.hpp>
+#include <boost/object_model/label.hpp>
+#include <boost/object_model/type/signature.hpp>
+
+BOOST_OM_BEGIN
+
+namespace generic
+{
+ struct method
+ {
+ label name;
+ signature sig;
+ };
+}
+
+BOOST_OM_END
+
+#include <boost/object_model/detail/postfix.hpp>
+
+#endif // BOOST_OBJECT_MODEL_(X)_HPP
+
+//EOF

Modified: sandbox/monotonic/boost/object_model/generic/object.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/generic/object.hpp (original)
+++ sandbox/monotonic/boost/object_model/generic/object.hpp 2009-06-25 21:14:21 EDT (Thu, 25 Jun 2009)
@@ -33,6 +33,7 @@
                 template <class T, class Al> friend struct object_model::klass;
 
                 void construct(registry &, klass const &, handle);
+ storage &get_storage();
 
         public:
                 klass const &get_class() const;
@@ -48,6 +49,9 @@
                 {
                         return get_type_number() == type::traits<T>::type_number;
                 }
+
+ void set(label const &name, object const &obj);
+ object get(label const &name) const;
         };
 
         struct const_object : object_base

Modified: sandbox/monotonic/boost/object_model/generic/storage.hpp
==============================================================================
--- sandbox/monotonic/boost/object_model/generic/storage.hpp (original)
+++ sandbox/monotonic/boost/object_model/generic/storage.hpp 2009-06-25 21:14:21 EDT (Thu, 25 Jun 2009)
@@ -18,7 +18,18 @@
 {
         struct const_storage : const_object
         {
+ protected:
                 dictionary dict;
+
+ public:
+ void set(label const &name, generic::object const &obj)
+ {
+ dict.set(name, obj);
+ }
+ generic::object get(label const &name) const
+ {
+ return dict.get(name);
+ }
         };
 
         struct storage : const_storage

Added: sandbox/monotonic/boost/object_model/string.hpp
==============================================================================
--- (empty file)
+++ sandbox/monotonic/boost/object_model/string.hpp 2009-06-25 21:14:21 EDT (Thu, 25 Jun 2009)
@@ -0,0 +1,37 @@
+// (C) 2009 Christian Schladetsch
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// documentation at https://svn.boost.org/svn/boost/sandbox/monotonic/libs/object_model/doc/index.html
+// sandbox at https://svn.boost.org/svn/boost/sandbox/monotonic/object_model/
+
+#ifndef BOOST_OBJECT_MODEL_STRING_HPP
+#define BOOST_OBJECT_MODEL_STRING_HPP
+
+#include <boost/object_model/detail/prefix.hpp>
+
+BOOST_OM_BEGIN
+
+template <class Alloc = default_allocator, class Ch = char, class Tr = std::char_traits<Ch> >
+struct string
+{
+ typedef std::basic_string<Ch, Tr, Alloc> implementation;
+ typedef typename implementation::value_type value_type;
+ typedef typename implementation::iterator iterator;
+ typedef typename implementation::const_iterator const_iterator;
+
+private:
+ implementation impl;
+
+public:
+
+};
+
+BOOST_OM_END
+
+#include <boost/object_model/detail/postfix.hpp>
+
+#endif // BOOST_OBJECT_MODEL_STRING_HPP
+
+//EOF

Added: sandbox/monotonic/boost/object_model/type/modifiers.hpp
==============================================================================
--- (empty file)
+++ sandbox/monotonic/boost/object_model/type/modifiers.hpp 2009-06-25 21:14:21 EDT (Thu, 25 Jun 2009)
@@ -0,0 +1,50 @@
+// (C) 2009 Christian Schladetsch
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// documentation at https://svn.boost.org/svn/boost/sandbox/monotonic/libs/object_model/doc/index.html
+// sandbox at https://svn.boost.org/svn/boost/sandbox/monotonic/object_model/
+
+#ifndef BOOST_OBJECT_MODEL_TYPE_MODIFIER_HPP
+#define BOOST_OBJECT_MODEL_TYPE_MODIFIER_HPP
+
+#include <bitset>
+#include <boost/object_model/detail/prefix.hpp>
+
+BOOST_OM_BEGIN
+
+namespace type
+{
+ struct modifiers
+ {
+ typedef std::bitset<3> flags_type;
+ typedef unsigned long flags_value;
+ enum
+ {
+ None = 0,
+ Const = 1,
+ Reference = 2,
+ };
+ private:
+ flags_type flags;
+
+ public:
+ modifiers() : flags((flags_value)0) { }
+ modifiers(flags_value N) : flags(N) { }
+
+ bool is_const() const { return flags[Const]; }
+ bool is_reference() const { return flags[Reference]; }
+ void set_const(bool B = true) { flags[Const] = B; }
+ void set_reference(bool B = true) { flags[Reference] = B; }
+ void set_const_reference(bool B = true) { set_const(B); set_reference(B); }
+ };
+}
+
+BOOST_OM_END
+
+#include <boost/object_model/detail/postfix.hpp>
+
+#endif // BOOST_OBJECT_MODEL_TYPE_MODIFIER_HPP
+
+//EOF

Added: sandbox/monotonic/boost/object_model/type/signature.hpp
==============================================================================
--- (empty file)
+++ sandbox/monotonic/boost/object_model/type/signature.hpp 2009-06-25 21:14:21 EDT (Thu, 25 Jun 2009)
@@ -0,0 +1,29 @@
+// (C) 2009 Christian Schladetsch
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// documentation at https://svn.boost.org/svn/boost/sandbox/monotonic/libs/object_model/doc/index.html
+// sandbox at https://svn.boost.org/svn/boost/sandbox/monotonic/object_model/
+
+#ifndef BOOST_OBJECT_MODEL_TYPE_SIGNATURE_HPP
+#define BOOST_OBJECT_MODEL_TYPE_SIGNATURE_HPP
+
+#include <boost/object_model/detail/prefix.hpp>
+
+BOOST_OM_BEGIN
+
+namespace type
+{
+ struct signature
+ {
+ };
+}
+
+BOOST_OM_END
+
+#include <boost/object_model/detail/postfix.hpp>
+
+#endif // BOOST_OBJECT_MODEL_TYPE_SIGNATURE_HPP
+
+//EOF

Added: sandbox/monotonic/boost/object_model/type/specifier.hpp
==============================================================================
--- (empty file)
+++ sandbox/monotonic/boost/object_model/type/specifier.hpp 2009-06-25 21:14:21 EDT (Thu, 25 Jun 2009)
@@ -0,0 +1,58 @@
+// (C) 2009 Christian Schladetsch
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// documentation at https://svn.boost.org/svn/boost/sandbox/monotonic/libs/object_model/doc/index.html
+// sandbox at https://svn.boost.org/svn/boost/sandbox/monotonic/object_model/
+
+#ifndef BOOST_OBJECT_MODEL_TYPE_SPECIFIER_HPP
+#define BOOST_OBJECT_MODEL_TYPE_SPECIFIER_HPP
+
+#include <boost/object_model/detail/prefix.hpp>
+#include <boost/object_model/string.hpp>
+#include <boost/object_model/type/modifiers.hpp>
+
+BOOST_OM_BEGIN
+
+namespace type
+{
+ struct specifier : modifiers
+ {
+ number type_number;
+
+ specifier(number N = number::None, modifiers M = modifiers()) : modifiers(M), type_number(N) { }
+
+ number get_number() const { return type_number; }
+
+ //template <class Alloc, template <class Al = Alloc, class Ch = char, class Tr = std::char_traits<Ch> > String = string>
+ //bool to_string(const registry<Alloc> &, string<Alloc> ) const;
+ };
+
+ template <class T>
+ struct is_const : mpl::true_ { };
+
+ template <class T>
+ struct is_const<const T> : mpl::true_ { };
+
+ template <class T>
+ struct is_const<const T&> : mpl::true_ { };
+
+ template <class T>
+ specifier make_specifier()
+ {
+ modifiers mods;
+ mods.set_const(is_const<T>::value); // what is wrong with boost::is_const<T> ??
+ mods.set_reference(boost::is_reference<T>::value);
+ return specifier(traits<typename base_type<T>::Type>::type_number, mods);
+ };
+
+} // namespace type
+
+BOOST_OM_END
+
+#include <boost/object_model/detail/postfix.hpp>
+
+#endif // BOOST_OBJECT_MODEL_TYPE_SPECIFIER_HPP
+
+//EOF

Modified: sandbox/monotonic/libs/monotonic/test/Tests/Tests.vcproj
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/Tests/Tests.vcproj (original)
+++ sandbox/monotonic/libs/monotonic/test/Tests/Tests.vcproj 2009-06-25 21:14:21 EDT (Thu, 25 Jun 2009)
@@ -118,14 +118,20 @@
                         <Tool
                                 Name="VCCLCompilerTool"
                                 Optimization="2"
+ InlineFunctionExpansion="2"
                                 EnableIntrinsicFunctions="true"
+ FavorSizeOrSpeed="1"
                                 AdditionalIncludeDirectories="$(ProjectDir)/../../../..;C:\Lib\tbb21_20080605oss\include"
                                 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ ExceptionHandling="1"
                                 RuntimeLibrary="2"
                                 EnableFunctionLevelLinking="true"
+ EnableEnhancedInstructionSet="2"
+ FloatingPointModel="2"
+ OpenMP="true"
                                 UsePrecompiledHeader="0"
                                 WarningLevel="3"
- DebugInformationFormat="3"
+ DebugInformationFormat="0"
                         />
                         <Tool
                                 Name="VCManagedResourceCompilerTool"

Modified: sandbox/monotonic/libs/monotonic/test/Tests/tests.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/Tests/tests.cpp (original)
+++ sandbox/monotonic/libs/monotonic/test/Tests/tests.cpp 2009-06-25 21:14:21 EDT (Thu, 25 Jun 2009)
@@ -12,9 +12,11 @@
 #include <boost/monotonic/allocator.hpp>
 #include <boost/interprocess/containers/list.hpp>
 #include <boost/monotonic/reclaimable_storage.hpp>
+#include <boost/iterator.hpp>
 
 #define BOOST_TEST_MODULE basic_test test
 #include <boost/test/unit_test.hpp>
+#include <boost/timer.hpp>
 
 
 template <class II>
@@ -72,6 +74,52 @@
 
 int Tracked::count = 0;
 
+template <class Number>
+Number work(size_t iterations, std::vector<Number> const &data)
+{
+ Number sum = 0;
+ size_t size = data.size();
+ for (size_t i = 0; i < iterations; ++i)
+ {
+ Number a = data[i % size];
+ Number b = data[(i + 500)%size];
+ sum += a * b;
+ }
+ return sum;
+}
+
+void test_floats()
+{
+ size_t iterations = 1000*1000*100;
+ size_t outter = 1;//00;//0*1000*10;
+ double int_t = 0;
+ double float_t = 0;
+
+ size_t size = 100000;
+ std::vector<int> ints(size);
+ srand(42);
+ generate_n(ints.begin(), size, rand);
+ std::vector<float> floats(size);
+ srand(42);
+ generate_n(floats.begin(), size, rand);
+
+ boost::timer int_timer;
+ int int_sum = 0;
+ for (size_t n = 0; n < outter; ++n)
+ {
+ int_sum += work(iterations, ints);
+ }
+ int_t = int_timer.elapsed();
+ boost::timer float_timer;
+ float float_sum = 0;
+ for (size_t n = 0; n < outter; ++n)
+ {
+ float_sum += work(iterations, floats);
+ }
+ float_t = float_timer.elapsed();
+ cout << int_t << ", " << float_t << "; " << int_sum << ", " << float_sum << endl;
+}
+
 BOOST_AUTO_TEST_CASE(test_reclaimable)
 {
         std::vector<Tracked, monotonic::allocator<Tracked, heap_region_tag> > vec;

Modified: sandbox/monotonic/libs/object_model/src/generic/object.cpp
==============================================================================
--- sandbox/monotonic/libs/object_model/src/generic/object.cpp (original)
+++ sandbox/monotonic/libs/object_model/src/generic/object.cpp 2009-06-25 21:14:21 EDT (Thu, 25 Jun 2009)
@@ -10,14 +10,13 @@
 #include <boost/object_model/generic/class.hpp>
 #include <boost/object_model/generic/storage.hpp>
 #include <boost/object_model/registry.hpp>
+#include <boost/object_model/label.hpp>
 
 BOOST_OM_BEGIN
 
 namespace generic
 {
- //---------------------------------------------------
         // object_base
- //---------------------------------------------------
 
         object_base::object_base()
                 : reg(0), type(0), number(0)
@@ -75,9 +74,22 @@
                 return get_registry().get_storage(get_handle());
         }
 
- //---------------------------------------------------
+ storage &object_base::get_storage()
+ {
+ return get_registry().get_storage(get_handle());
+ }
+
+ void object_base::set(label const &name, object const &obj)
+ {
+ get_storage().set(name, obj);
+ }
+
+ object object_base::get(label const &name) const
+ {
+ return get_storage().get(name);
+ }
+
         // const_object
- //---------------------------------------------------
 
         //const_object::const_object()
         //{
@@ -91,10 +103,7 @@
         //{
         //}
 
-
- //---------------------------------------------------
         // mutable_object
- //---------------------------------------------------
 
         mutable_object::mutable_object()
         {
@@ -109,9 +118,7 @@
                 return get_registry().get_storage(get_handle());
         }
 
- //---------------------------------------------------
         // object
- //---------------------------------------------------
 
         object::object() : konst(false) { }
 

Modified: sandbox/monotonic/libs/object_model/src/object_model.vcproj
==============================================================================
--- sandbox/monotonic/libs/object_model/src/object_model.vcproj (original)
+++ sandbox/monotonic/libs/object_model/src/object_model.vcproj 2009-06-25 21:14:21 EDT (Thu, 25 Jun 2009)
@@ -294,6 +294,10 @@
>
                                 </File>
                                 <File
+ RelativePath="..\..\..\boost\object_model\string.hpp"
+ >
+ </File>
+ <File
                                         RelativePath="..\..\..\boost\object_model\template_header.hpp"
>
                                 </File>
@@ -305,6 +309,10 @@
>
                                         </File>
                                         <File
+ RelativePath="..\..\..\boost\object_model\detail\make_method.hpp"
+ >
+ </File>
+ <File
                                                 RelativePath="..\..\..\boost\object_model\detail\postfix.hpp"
>
                                         </File>
@@ -321,10 +329,22 @@
>
                                         </File>
                                         <File
+ RelativePath="..\..\..\boost\object_model\type\modifiers.hpp"
+ >
+ </File>
+ <File
                                                 RelativePath="..\..\..\boost\object_model\type\number.hpp"
>
                                         </File>
                                         <File
+ RelativePath="..\..\..\boost\object_model\type\signature.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\boost\object_model\type\specifier.hpp"
+ >
+ </File>
+ <File
                                                 RelativePath="..\..\..\boost\object_model\type\traits.hpp"
>
                                         </File>
@@ -341,6 +361,10 @@
>
                                         </File>
                                         <File
+ RelativePath="..\..\..\boost\object_model\generic\method.hpp"
+ >
+ </File>
+ <File
                                                 RelativePath="..\..\..\boost\object_model\generic\object.hpp"
>
                                         </File>

Modified: sandbox/monotonic/libs/object_model/test/basic_tests.cpp
==============================================================================
--- sandbox/monotonic/libs/object_model/test/basic_tests.cpp (original)
+++ sandbox/monotonic/libs/object_model/test/basic_tests.cpp 2009-06-25 21:14:21 EDT (Thu, 25 Jun 2009)
@@ -19,11 +19,22 @@
 #include <boost/object_model/builder.hpp>
 #include <boost/object_model/type/traits.hpp>
 #include <boost/object_model/dereference.hpp>
+#include <boost/object_model/type/specifier.hpp>
+#include <boost/object_model/string.hpp>
 
 using namespace std;
 using namespace boost;
 namespace om = boost::object_model;
 
+BOOST_AUTO_TEST_CASE(test_type_specifier)
+{
+ om::registry<> reg;
+ reg.register_class<void>();
+ reg.register_class<int>();
+
+ //om::string<> text = type::make_specifier<int>().to_string(reg);
+}
+
 BOOST_AUTO_TEST_CASE(test_type_traits)
 {
         BOOST_STATIC_ASSERT(om::type::traits<int>::type_number == om::type::number::Int);
@@ -58,10 +69,13 @@
         om::registry<> reg;
         reg.register_class<int>();
         BOOST_ASSERT(reg.has_class<int>());
+
         om::object<int> num = reg.create<int>();
         BOOST_ASSERT(num.exists());
         BOOST_ASSERT(num.is_type<int>());
+
         *num = 42;
+
         BOOST_ASSERT(om::deref<int>(num) == 42);
 }
 
@@ -83,10 +97,8 @@
 
 BOOST_AUTO_TEST_CASE(test_builder)
 {
- return;
-
         om::registry<> reg;
- om::builder<Foo>(reg)
+ om::class_builder<Foo>(reg)
                 .methods
                         ("bar", &Foo::bar)
                         ("spam", &Foo::spam)


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