$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: mariano.consoni_at_[hidden]
Date: 2007-08-13 17:38:45
Author: mconsoni
Date: 2007-08-13 17:38:44 EDT (Mon, 13 Aug 2007)
New Revision: 38633
URL: http://svn.boost.org/trac/boost/changeset/38633
Log:
- Made shorter and more concrete the extension integration example. Now it's
  just the creation of the reflection, loading the library and combining them.
- Added the second tutorial, describing the Boost.Extension example.
Added:
   sandbox/libs/reflection/boostbook.css   (contents, props changed)
   sandbox/libs/reflection/doc/tutorial2.qbk   (contents, props changed)
Text files modified: 
   sandbox/libs/reflection/doc/Jamfile.v2                   |     4 ++--                                    
   sandbox/libs/reflection/doc/tutorials.qbk                |    13 ++++++-------                           
   sandbox/libs/reflection/examples/extension/car_lib.cpp   |     2 +-                                      
   sandbox/libs/reflection/examples/extension/extension.cpp |    34 +++++++---------------------------      
   4 files changed, 16 insertions(+), 37 deletions(-)
Added: sandbox/libs/reflection/boostbook.css
==============================================================================
--- (empty file)
+++ sandbox/libs/reflection/boostbook.css	2007-08-13 17:38:44 EDT (Mon, 13 Aug 2007)
@@ -0,0 +1,511 @@
+/*=============================================================================
+    Copyright (c) 2004 Joel de Guzman
+    http://spirit.sourceforge.net/
+
+    Use, modification and distribution is subject to 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)
+=============================================================================*/
+
+/*=============================================================================
+    Body defaults
+=============================================================================*/
+
+    body 
+    {
+        margin: 1em;
+        font-family: sans-serif;
+    }
+
+/*=============================================================================
+    Paragraphs
+=============================================================================*/
+
+    p 
+    {
+        text-align: left;
+        font-size: 10pt; 
+        line-height: 1.15;
+    }
+
+/*=============================================================================
+    Program listings
+=============================================================================*/
+
+    /* Code on paragraphs */
+    p tt.computeroutput
+    {
+        font-size: 9pt;
+    }
+
+    pre.synopsis
+    {
+        font-size: 90%;
+        margin: 1pc 4% 0pc 4%;
+        padding: 0.5pc 0.5pc 0.5pc 0.5pc;
+    }
+
+    .programlisting, 
+    .screen
+    {
+        font-size: 9pt;
+        display: block;
+        margin: 1pc 4% 0pc 4%;
+        padding: 0.5pc 0.5pc 0.5pc 0.5pc;
+    }
+
+    /* Program listings in tables don't get borders */
+    td .programlisting, 
+    td .screen
+    {
+        margin: 0pc 0pc 0pc 0pc;
+        padding:  0pc 0pc 0pc 0pc;
+    }
+
+/*=============================================================================
+    Headings
+=============================================================================*/
+
+    h1, h2, h3, h4, h5, h6 
+    { 
+        text-align: left; 
+        margin: 1em 0em 0.5em 0em;
+        font-weight: bold;
+    }
+
+    h1 { font: 140% }
+    h2 { font: bold 140% }
+    h3 { font: bold 130% }
+    h4 { font: bold 120% }
+    h5 { font: italic 110% }
+    h6 { font: italic 100% }
+
+    /* Top page titles */
+    title, 
+    h1.title, 
+    h2.title
+    h3.title, 
+    h4.title, 
+    h5.title, 
+    h6.title, 
+    .refentrytitle
+    {
+        font-weight: bold;
+        margin-bottom: 1pc;
+    }
+
+    h1.title { font-size: 140% }
+    h2.title { font-size: 140% }
+    h3.title { font-size: 130% }
+    h4.title { font-size: 120% }
+    h5.title { font-size: 110% }
+    h6.title { font-size: 100% }
+
+    .section h1 
+    {
+        margin: 0em 0em 0.5em 0em;
+        font-size: 140%;
+    }
+
+    .section h2 { font-size: 140% }
+    .section h3 { font-size: 130% }
+    .section h4 { font-size: 120% }
+    .section h5 { font-size: 110% }
+    .section h6 { font-size: 100% }
+
+    /* Code on titles */
+    h1 tt.computeroutput { font-size: 140% }
+    h2 tt.computeroutput { font-size: 140% }
+    h3 tt.computeroutput { font-size: 130% }
+    h4 tt.computeroutput { font-size: 120% }
+    h5 tt.computeroutput { font-size: 110% }
+    h6 tt.computeroutput { font-size: 100% }
+
+/*=============================================================================
+    Author
+=============================================================================*/
+
+    h3.author 
+    { 
+        font-size: 100% 
+    }
+
+/*=============================================================================
+    Lists
+=============================================================================*/
+
+    li
+    {
+        font-size: 10pt;
+        line-height: 1.3;
+    }
+    
+    /* Unordered lists */
+    ul 
+    {
+        text-align: left;
+    }
+    
+    /* Ordered lists */
+    ol 
+    {
+        text-align: left;
+    }
+
+/*=============================================================================
+    Links
+=============================================================================*/
+
+    a
+    {
+        text-decoration: none; /* no underline */
+    }
+    
+    a:hover
+    {
+        text-decoration: underline;
+    }
+
+/*=============================================================================
+    Spirit style navigation
+=============================================================================*/
+
+    .spirit-nav
+    {
+        text-align: right;
+    }
+    
+    .spirit-nav a
+    {
+        color: white;
+        padding-left: 0.5em;
+    }
+    
+    .spirit-nav img
+    {
+        border-width: 0px;
+    }
+
+/*=============================================================================
+    Table of contents
+=============================================================================*/
+
+    .toc
+    {
+       margin: 1pc 4% 0pc 4%;
+       padding: 0.1pc 1pc 0.1pc 1pc;
+       font-size: 80%; 
+       line-height: 1.15;
+    }
+    
+    .boost-toc
+    {
+       float: right;
+       padding: 0.5pc;
+    }
+
+/*=============================================================================
+    Tables
+=============================================================================*/
+
+    .table-title, 
+    div.table p.title
+    {
+        margin-left: 4%;
+        padding-right: 0.5em; 
+        padding-left: 0.5em;
+    }
+    
+    .informaltable table, 
+    .table table
+    {
+        width: 92%;
+        margin-left: 4%;
+        margin-right: 4%;
+    }
+    
+    div.informaltable table, 
+    div.table table
+    {
+        padding: 4px;
+    }
+    
+    /* Table Cells */
+    div.informaltable table tr td, 
+    div.table table tr td
+    {
+        padding: 0.5em;
+        text-align: left;
+        font-size: 9pt;
+    }
+
+    div.informaltable table tr th, 
+    div.table table tr th
+    {
+        padding: 0.5em 0.5em 0.5em 0.5em;
+        border: 1pt solid white;
+        font-size: 80%;
+    }
+
+/*=============================================================================
+    Blurbs
+=============================================================================*/
+
+    div.note,
+    div.tip,
+    div.important,
+    div.caution,
+    div.warning,
+    p.blurb
+    {
+        font-size: 9pt; /* A little bit smaller than the main text */
+        line-height: 1.2;
+        display: block;
+        margin: 1pc 4% 0pc 4%;
+        padding: 0.5pc 0.5pc 0.5pc 0.5pc;
+    }
+    
+    p.blurb img
+    {
+        padding: 1pt;
+    }
+
+/*=============================================================================
+    Variable Lists
+=============================================================================*/
+
+    /* Make the terms in definition lists bold */
+    div.variablelist dl dt,
+    span.term
+    {
+        font-weight: bold;
+        font-size: 10pt;
+    }
+
+    div.variablelist table tbody tr td
+    {
+        text-align: left;
+        vertical-align: top;
+        padding: 0em 2em 0em 0em;
+        font-size: 10pt;
+        margin: 0em 0em 0.5em 0em;
+        line-height: 1;
+    }
+
+    div.variablelist dl dt
+    {
+        margin-bottom: 0.2em;
+    }
+
+    div.variablelist dl dd
+    {
+        margin: 0em 0em 0.5em 2em;
+        font-size: 10pt;
+    }
+
+    div.variablelist table tbody tr td p,
+    div.variablelist dl dd p
+    {
+        margin: 0em 0em 0.5em 0em;
+        line-height: 1;
+    }
+
+/*=============================================================================
+    Misc
+=============================================================================*/
+
+    /* Title of books and articles in bibliographies */
+    span.title
+    {
+        font-style: italic;
+    }
+
+    span.underline
+    {
+        text-decoration: underline;
+    }
+
+    span.strikethrough
+    {
+        text-decoration: line-through;
+    }
+
+    /* Copyright, Legal Notice */
+    div div.legalnotice p
+    {
+        text-align: left
+    }
+
+/*=============================================================================
+    Colors
+=============================================================================*/
+
+    @media screen
+    {
+    /* Links */
+        a
+        {
+            color: #005a9c;
+        }
+    
+        a:visited
+        {
+            color: #9c5a9c;
+        }
+
+        h1 a, h2 a, h3 a, h4 a, h5 a, h6 a,
+        h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover, h5 a:hover, h6 a:hover,
+        h1 a:visited, h2 a:visited, h3 a:visited, h4 a:visited, h5 a:visited, h6 a:visited
+        {
+            text-decoration: none; /* no underline */
+            color: #000000;
+        }
+    
+    /* Syntax Highlighting */
+        .keyword        { color: #0000AA; }
+        .identifier     { color: #000000; }
+        .special        { color: #707070; }
+        .preprocessor   { color: #402080; }
+        .char           { color: teal; }
+        .comment        { color: #800000; }
+        .string         { color: teal; }
+        .number         { color: teal; }
+        .white_bkd      { background-color: #FFFFFF; }
+        .dk_grey_bkd    { background-color: #999999; }
+    
+    /* Copyright, Legal Notice */
+        .copyright      
+        { 
+            color: #666666; 
+            font-size: small; 
+        }
+    
+        div div.legalnotice p
+        {
+            color: #666666;
+        }
+    
+    /* Program listing */
+        pre.synopsis
+        {
+            border: 1px solid #DCDCDC;
+        }
+    
+        .programlisting, 
+        .screen
+        {
+            border: 1px solid #DCDCDC;
+        }
+    
+        td .programlisting, 
+        td .screen
+        {
+            border: 0px solid #DCDCDC;
+        }
+    
+    /* Blurbs */
+        div.note,
+        div.tip,
+        div.important,
+        div.caution,
+        div.warning,
+        p.blurb
+        {
+            border: 1px solid #DCDCDC;
+        }
+    
+    /* Table of contents */
+        .toc
+        {
+            border: 1px solid #DCDCDC;
+        }
+    
+    /* Tables */
+        div.informaltable table tr td, 
+        div.table table tr td
+        {
+            border: 1px solid #DCDCDC;
+        }
+    
+        div.informaltable table tr th, 
+        div.table table tr th
+        {
+            background-color: #F0F0F0;
+            border: 1px solid #DCDCDC;
+        }
+    
+    /* Misc */
+        span.highlight
+        {
+            color: #00A000;
+        }
+    }
+    
+    @media print
+    {
+    /* Links */
+        a
+        {
+            color: black;
+        }
+    
+        a:visited
+        {
+            color: black;
+        }
+    
+        .spirit-nav
+        {
+            display: none;
+        }
+    
+    /* Program listing */
+        pre.synopsis
+        {
+            border: 1px solid gray;
+        }
+    
+        .programlisting, 
+        .screen
+        {
+            border: 1px solid gray;
+        }
+    
+        td .programlisting, 
+        td .screen
+        {
+            border: 0px solid #DCDCDC;
+        }
+    
+    /* Table of contents */
+        .toc
+        {
+            border: 1px solid gray;
+        }
+    
+        .informaltable table, 
+        .table table
+        {
+            border: 1px solid gray;
+            border-collapse: collapse;
+        }
+    
+    /* Tables */
+        div.informaltable table tr td, 
+        div.table table tr td
+        {
+            border: 1px solid gray;
+        }
+    
+        div.informaltable table tr th, 
+        div.table table tr th
+        {
+            border: 1px solid gray;
+        }
+    
+    /* Misc */
+        span.highlight
+        {
+            font-weight: bold;
+        }
+    }
Modified: sandbox/libs/reflection/doc/Jamfile.v2
==============================================================================
--- sandbox/libs/reflection/doc/Jamfile.v2	(original)
+++ sandbox/libs/reflection/doc/Jamfile.v2	2007-08-13 17:38:44 EDT (Mon, 13 Aug 2007)
@@ -23,5 +23,5 @@
 
     ;
 
-install html : ../../../../src/sandbox/doc/html/boostbook.css ;
-install ../ : ../../../../src/sandbox/boost.png ;
+install html : ../boostbook.css ;
+install ../ : ../boost.png ;
Added: sandbox/libs/reflection/doc/tutorial2.qbk
==============================================================================
--- (empty file)
+++ sandbox/libs/reflection/doc/tutorial2.qbk	2007-08-13 17:38:44 EDT (Mon, 13 Aug 2007)
@@ -0,0 +1,99 @@
+[/ Boost.Reflection - boost.extension tutorial ]
+[/ Copyright 2007 Mariano G. Consoni ]
+[/ 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) ]
+[/ See http://www.boost.org/ for latest version. ]
+
+
+[section:tutorial02 Tutorial 2]
+
+In this tutorial we show how Boost.Extension could be integrated with
+Boost.Reflection. This relationship is important because
+we can load different factories with Boost.Extension (from dynamic link
+libraries) and then reflect its instances using Boost.Reflection.
+
+This example is based in the first tutorial , specially in the Reflection 
+part. So it's preferred that the reader is familiarized with that
+tutorial, and of course has a basic understanding of Boost.Extension.
+
+First, we create a Boost.Extension based in our car interface. It 
+defines two derived classes, and has the export declaration. 
+
+``
+class suv : public car
+{
+public:
+	suv(const std::string name) : car(name) {}
+	virtual std::string get_type(void) { return "It's a SUV."; }
+	virtual ~suv(void) {}
+};
+
+class compact : public car
+{
+public:
+	compact(const std::string name) : car(name) {}
+	virtual std::string get_type(void) { return "It's a compact."; }
+	virtual ~compact(void) {}
+};
+``
+
+``
+extern "C" 
+void BOOST_EXTENSION_EXPORT_DECL 
+extension_export_car(boost::extensions::factory_map & fm)
+{
+  fm.add<suv, car, std::string, std::string>("SUV");
+  fm.add<compact, car, std::string, std::string>("Compact");
+}
+``
+
+We compile it as a dynamic link library that will be loaded from the
+main program. 
+
+Having the library we could start our main program. We'll define our
+reflection (creating it and adding methods) and them we'll cycle
+the factories, create some instances and use our reflection to
+call methods.
+
+Let's define the reflection, very similar to the one in tutorial 1:
+
+``
+  boost::extension::reflection<car, std::string> car_reflection("A Car!");
+  car_reflection.add<int, bool>(&car::start, 3);
+  car_reflection.add<std::string, bool, float, 
+    std::string>(&car::turn, "turn", "turn_angle");
+``
+
+Now we load the dynamic link library:
+
+``
+  load_single_library(fm, "libcar_lib.extension", 
+		      "extension_export_car");
+  std::list<factory<car, std::string, std::string> > & factory_list = 
+	  fm.get<car, std::string, std::string>();  
+``
+
+Now, the interesting part. We iterate the factories searching for
+a Compacts factory. When we find it we create an instance, and then
+we use our car reflection to call the 3 method (start).
+
+``
+  for (std::list<factory<car, std::string, std::string> >
+	 ::iterator current_car = factory_list.begin(); 
+       current_car != factory_list.end(); 
+       ++current_car)
+  {
+    if(current_car->get_info() == "Compact") {
+       car *beetle(current_car->create("VW New Beetle"));
+       car_reflection.call<int, bool>(beetle, 3);
+       delete beetle;
+    }
+  }
+``
+
+In this way you can load instance factories dynamically, and then
+use your reflections to access your methods.
+
+
+[endsect]
\ No newline at end of file
Modified: sandbox/libs/reflection/doc/tutorials.qbk
==============================================================================
--- sandbox/libs/reflection/doc/tutorials.qbk	(original)
+++ sandbox/libs/reflection/doc/tutorials.qbk	2007-08-13 17:38:44 EDT (Mon, 13 Aug 2007)
@@ -7,13 +7,12 @@
 
 [section Tutorials]
 [include tutorial1.qbk]
-[/ include tutorial2.qbk]
-[/ include tutorial3.qbk]
-[/ include tutorial4.qbk]
-[/ include tutorial5.qbk]
-[/ include tutorial6.qbk]
+[include tutorial2.qbk]
 
-We only have one basic tutorial for now. It shows the implemented functionalities.
-The tutorial code can be found in the examples folder. 
+We only have two tutorials for now. The first is the basic example
+and it shows the implemented functionalities. The second is about
+Boost.Extension integration.
+
+The tutorials code can be found in the examples folder.
 
 [endsect]
\ No newline at end of file
Modified: sandbox/libs/reflection/examples/extension/car_lib.cpp
==============================================================================
--- sandbox/libs/reflection/examples/extension/car_lib.cpp	(original)
+++ sandbox/libs/reflection/examples/extension/car_lib.cpp	2007-08-13 17:38:44 EDT (Mon, 13 Aug 2007)
@@ -2,7 +2,7 @@
  * Boost.Extension / hello world implementations
  *
  * (C) Copyright Jeremy Pack 2007
- * Distributed under the Boost Software License, Version 1.0. (See             
+ * 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)
  *
Modified: sandbox/libs/reflection/examples/extension/extension.cpp
==============================================================================
--- sandbox/libs/reflection/examples/extension/extension.cpp	(original)
+++ sandbox/libs/reflection/examples/extension/extension.cpp	2007-08-13 17:38:44 EDT (Mon, 13 Aug 2007)
@@ -26,50 +26,30 @@
 
 int main(void)
 {
-
-  /* Here we declare that we are reflecting out a Car. The second
-     template parameter declares that we will describe this reflection
-     using a string. Any arbitrary type could be used here. */
+  // Let's create the reflection and add the methods
   boost::extension::reflection<car, std::string> car_reflection("A Car!");
-
-  /* Here we add two methods to the reflection. The library must
-     correctly parse and remember the parameters and return type of these
-     methods. Here, we elect to describe the first method using a number
-     and the second using a string. For the second method, the library
-     knows now that it is a function of Car called turn that takes a float
-     named "turn_angle". */ 
   car_reflection.add<int, bool>(&car::start, 3);
   car_reflection.add<std::string, bool, float, 
     std::string>(&car::turn, "turn", "turn_angle");
 
-  car porsche_911("Porsche 911");
-  car ferrari_f40("Ferrari F40");
-
-  car_reflection.call<int, bool>(&porsche_911, 3);
-  car_reflection.call<std::string, bool, 
-    float, std::string>(&porsche_911, "turn", .5f);
-
-  car_reflection.call<std::string, bool, 
-    float, std::string>(&ferrari_f40, "turn", .10f);
-
-  // prepare the parameter map for a call
-  boost::extension::parameter_map pm;
-  pm.add<float, std::string>(.15f, "turn_angle");
-  pm.add<int, std::string>(50, "aceleration");
-
-
   // extension tests
   using namespace boost::extensions;
   factory_map fm;
+
+  // load the car library
   load_single_library(fm, "libcar_lib.extension", 
                       "extension_export_car");
   std::list<factory<car, std::string, std::string> > & factory_list = 
           fm.get<car, std::string, std::string>();  
+
+  // check if the factories loaded fine
   if(factory_list.size() < 2) {
     std::cout << "Error - the classes were not found (" 
               << factory_list.size() << ").\n";
     return -1;
   }
+
+  // create some instances and call the method "3" (start)
   for (std::list<factory<car, std::string, std::string> >
          ::iterator current_car = factory_list.begin(); 
        current_car != factory_list.end();