Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76207 - trunk/libs/geometry/doc/src/docutils/tools/support_status
From: barend.gehrels_at_[hidden]
Date: 2011-12-28 05:52:37


Author: barendgehrels
Date: 2011-12-28 05:52:37 EST (Wed, 28 Dec 2011)
New Revision: 76207
URL: http://svn.boost.org/trac/boost/changeset/76207

Log:
Added qbk output additional to text output.
Added:
   trunk/libs/geometry/doc/src/docutils/tools/support_status/qbk_outputter.hpp (contents, props changed)
   trunk/libs/geometry/doc/src/docutils/tools/support_status/text_outputter.hpp (contents, props changed)
Text files modified:
   trunk/libs/geometry/doc/src/docutils/tools/support_status/support_status.cpp | 93 ++++++++++++++++++++++++++++++---------
   1 files changed, 71 insertions(+), 22 deletions(-)

Added: trunk/libs/geometry/doc/src/docutils/tools/support_status/qbk_outputter.hpp
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/doc/src/docutils/tools/support_status/qbk_outputter.hpp 2011-12-28 05:52:37 EST (Wed, 28 Dec 2011)
@@ -0,0 +1,115 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// Tool reporting Implementation Support Status in QBK or plain text format
+
+// Copyright (c) 2011 Bruno Lalande, Paris, France.
+// Copyright (c) 2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// 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)
+
+#ifndef BOOST_GEOMETRY_SUPPORT_STATUS_QBK_OUTPUTTER_HPP
+#define BOOST_GEOMETRY_SUPPORT_STATUS_QBK_OUTPUTTER_HPP
+
+
+template <typename Tag> struct qbk_geometry_name { static inline std::string name() { return "Range"; } }; // TODO / make general
+template <> struct qbk_geometry_name<boost::geometry::point_tag> { static inline std::string name() { return "Point"; } };
+template <> struct qbk_geometry_name<boost::geometry::segment_tag> { static inline std::string name() { return "Segment"; } };
+template <> struct qbk_geometry_name<boost::geometry::box_tag> { static inline std::string name() { return "Box"; } };
+template <> struct qbk_geometry_name<boost::geometry::linestring_tag> { static inline std::string name() { return "Linestring"; } };
+template <> struct qbk_geometry_name<boost::geometry::ring_tag> { static inline std::string name() { return "Ring"; } };
+template <> struct qbk_geometry_name<boost::geometry::polygon_tag> { static inline std::string name() { return "Polygon"; } };
+template <> struct qbk_geometry_name<boost::geometry::multi_point_tag> { static inline std::string name() { return "MultiPoint"; } };
+template <> struct qbk_geometry_name<boost::geometry::multi_linestring_tag> { static inline std::string name() { return "MultiLinestring"; } };
+template <> struct qbk_geometry_name<boost::geometry::multi_polygon_tag> { static inline std::string name() { return "MultiPolygon"; } };
+
+
+struct qbk_table_row_header
+{
+ std::ofstream& m_out;
+
+ qbk_table_row_header(std::ofstream& out)
+ : m_out(out)
+ {}
+
+ template <typename G>
+ void operator()(G)
+ {
+ m_out
+ << "["
+ << qbk_geometry_name
+ <
+ typename boost::geometry::tag<G>::type
+ >::name()
+ << "]";
+ }
+};
+
+struct qbk_outputter
+{
+ std::ofstream m_out;
+
+ std::string filename(std::string const& name)
+ {
+ std::ostringstream out;
+ out << "../../../../generated/" << name << "_status.qbk";
+ return out.str();
+ }
+
+ qbk_outputter(std::string const& name)
+ : m_out(filename(name).c_str())
+ {
+ }
+
+ inline void ok() { m_out << "[ [$img/ok.png] ]"; }
+ inline void nyi() { m_out << "[ [$img/nyi.png] ]"; }
+
+ inline void header(std::string const& )
+ {
+ m_out << "[heading Supported geometries]" << std::endl;
+ }
+
+ template <typename Types>
+ inline void table_header()
+ {
+ m_out << "[table" << std::endl << "[[ ]";
+ boost::mpl::for_each<Types>(qbk_table_row_header(m_out));
+ m_out << "]" << std::endl;
+ }
+ inline void table_footer()
+ {
+ m_out << "]" << std::endl;
+ }
+
+ template <typename G>
+ inline void begin_row()
+ {
+ m_out
+ << "[["
+ << qbk_geometry_name
+ <
+ typename boost::geometry::tag<G>::type
+ >::name()
+ << "]"
+ ;
+ }
+
+ inline void end_row()
+ {
+ m_out << "]" << std::endl;
+ }
+
+};
+
+
+struct qbk_output_factory
+{
+ typedef qbk_outputter type;
+
+ static inline qbk_outputter create(std::string const& name)
+ {
+ return qbk_outputter(name);
+ }
+};
+
+#endif // BOOST_GEOMETRY_SUPPORT_STATUS_QBK_OUTPUTTER_HPP

Modified: trunk/libs/geometry/doc/src/docutils/tools/support_status/support_status.cpp
==============================================================================
--- trunk/libs/geometry/doc/src/docutils/tools/support_status/support_status.cpp (original)
+++ trunk/libs/geometry/doc/src/docutils/tools/support_status/support_status.cpp 2011-12-28 05:52:37 EST (Wed, 28 Dec 2011)
@@ -1,6 +1,16 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// Tool reporting Implementation Support Status in QBK or plain text format
+
+// Copyright (c) 2011 Bruno Lalande, Paris, France.
+// Copyright (c) 2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// 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)
+
 #include <iostream>
-#include <string>
-#include <vector>
+#include <fstream>
+#include <sstream>
 
 #include <boost/type_traits/is_base_of.hpp>
 #include <boost/mpl/for_each.hpp>
@@ -9,11 +19,15 @@
 #define BOOST_GEOMETRY_IMPLEMENTATION_STATUS_BUILD true
 #include <boost/geometry/core/cs.hpp>
 #include <boost/geometry/geometries/geometries.hpp>
+#include <boost/geometry/multi/geometries/multi_geometries.hpp>
+#include <boost/geometry/multi/multi.hpp>
 #include <boost/geometry/algorithms/append.hpp>
 #include <boost/geometry/algorithms/convert.hpp>
 #include <boost/geometry/algorithms/distance.hpp>
 #include <boost/geometry/strategies/cartesian/distance_pythagoras.hpp>
 
+#include "text_outputter.hpp"
+#include "qbk_outputter.hpp"
 
 typedef boost::geometry::cs::cartesian cartesian;
 
@@ -24,16 +38,22 @@
 typedef boost::geometry::model::ring<point_type> ring_type;
 typedef boost::geometry::model::segment<point_type> segment_type;
 
+typedef boost::geometry::model::multi_point<point_type> multi_point_type;
+typedef boost::geometry::model::multi_linestring<linestring_type> multi_linestring_type;
+typedef boost::geometry::model::multi_polygon<polygon_type> multi_polygon_type;
+
 typedef boost::mpl::vector<
     point_type,
- linestring_type,
- polygon_type,
+ segment_type,
     box_type,
+ linestring_type,
     ring_type,
- segment_type
+ polygon_type,
+ multi_point_type,
+ multi_linestring_type,
+ multi_polygon_type
> all_types;
 
-
 #define DECLARE_BINARY_ALGORITHM(algorithm) \
     template <typename G1, typename G2> \
     struct algorithm: boost::geometry::dispatch::algorithm<G1, G2> \
@@ -44,49 +64,78 @@
 DECLARE_BINARY_ALGORITHM(convert)
 
 
-template <template <typename, typename> class Dispatcher, typename G2>
+template <template <typename, typename> class Dispatcher, typename Outputter, typename G2 = void>
 struct do_test
 {
+ Outputter& m_outputter;
+ inline do_test(Outputter& outputter)
+ : m_outputter(outputter)
+ {}
+
     template <typename G1>
     void operator()(G1)
     {
         if (boost::is_base_of<boost::geometry::nyi::not_implemented_tag, Dispatcher<G1, G2> >::type::value)
         {
- std::cout << "-\t";
+ m_outputter.nyi();
         }
         else
         {
- std::cout << "OK\t";
+ m_outputter.ok();
         }
     }
 };
 
-template <template <typename, typename> class Dispatcher, typename Types>
+template <template <typename, typename> class Dispatcher, typename Types, typename Outputter>
 struct test
 {
+ Outputter& m_outputter;
+ inline test(Outputter& outputter)
+ : m_outputter(outputter)
+ {}
+
     template <typename G2>
     void operator()(G2)
     {
- boost::mpl::for_each<Types>(do_test<Dispatcher, G2>());
- std::cout << std::endl;
+ m_outputter.begin_row<G2>();
+ boost::mpl::for_each<Types>(do_test<Dispatcher, Outputter, G2>(m_outputter));
+ m_outputter.end_row();
     }
 };
 
-
-template<template <typename, typename> class Dispatcher, typename Types1, typename Types2>
-void test_binary_algorithm(const std::string& name)
+template <template <typename, typename> class Dispatcher, typename Types1, typename Types2, typename OutputFactory>
+void test_binary_algorithm(std::string const& name)
 {
- std::cout << name << std::endl;
- boost::mpl::for_each<Types1>(test<Dispatcher, Types2>());
- std::cout << std::endl;
+ typedef typename OutputFactory::type outputter_type;
+
+ outputter_type outputter = OutputFactory::create(name);
+ outputter.header(name);
+
+ outputter.table_header<Types2>();
+ boost::mpl::for_each<Types1>(test<Dispatcher, Types2, outputter_type>(outputter));
+
+ outputter.table_footer();
 }
 
 
-int main()
+template <typename OutputFactory>
+void support_status()
 {
- test_binary_algorithm<append, all_types, boost::mpl::vector<point_type, std::vector<point_type> > >("APPEND");
- test_binary_algorithm<convert, all_types, all_types>("CONVERT");
- test_binary_algorithm<distance, all_types, all_types>("DISTANCE");
+ test_binary_algorithm<append, all_types, boost::mpl::vector<point_type, std::vector<point_type> >, OutputFactory>("append");
+ test_binary_algorithm<distance, all_types, all_types, OutputFactory>("distance");
+ test_binary_algorithm<convert, all_types, all_types, OutputFactory>("convert");
+}
+
 
+int main(int argc, char** argv)
+{
+ if (argc > 1 && ! strcmp(argv[1], "qbk"))
+ {
+ support_status<qbk_output_factory>();
+ }
+ else
+ {
+ support_status<text_output_factory>();
+ }
     return 0;
 }

Added: trunk/libs/geometry/doc/src/docutils/tools/support_status/text_outputter.hpp
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/doc/src/docutils/tools/support_status/text_outputter.hpp 2011-12-28 05:52:37 EST (Wed, 28 Dec 2011)
@@ -0,0 +1,43 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// Tool reporting Implementation Support Status in QBK or plain text format
+
+// Copyright (c) 2011 Bruno Lalande, Paris, France.
+// Copyright (c) 2011 Barend Gehrels, Amsterdam, the Netherlands.
+
+// 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)
+
+#ifndef BOOST_GEOMETRY_SUPPORT_STATUS_TEXT_OUTPUTTER_HPP
+#define BOOST_GEOMETRY_SUPPORT_STATUS_TEXT_OUTPUTTER_HPP
+
+
+struct text_outputter
+{
+ static inline void ok() { std::cout << "OK\t"; }
+ static inline void nyi() { std::cout << "-\t"; }
+ static inline void header(std::string const& algo) { std::cout << algo << std::endl; }
+
+ template <typename T>
+ static inline void table_header() { }
+
+ static inline void table_footer() { std::cout << std::endl; }
+
+ template <typename G>
+ static inline void begin_row() {}
+
+ static inline void end_row() { std::cout << std::endl; }
+
+};
+
+struct text_output_factory
+{
+ typedef text_outputter type;
+
+ static inline text_outputter create(std::string const& name)
+ {
+ return text_outputter();
+ }
+};
+
+#endif // BOOST_GEOMETRY_SUPPORT_STATUS_TEXT_OUTPUTTER_HPP


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