Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62991 - in sandbox/SOC/2010/bit_masks: boost/integer boost/integer/details/bft/ext boost/integer/details/bit_mask_group_fusion_ext lib/integer/test/bft_testing
From: bbartmanboost_at_[hidden]
Date: 2010-06-15 14:48:48


Author: bbartman
Date: 2010-06-15 14:48:47 EDT (Tue, 15 Jun 2010)
New Revision: 62991
URL: http://svn.boost.org/trac/boost/changeset/62991

Log:
completed work on the fusion iterator extension's value_of functionality.

Text files modified:
   sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp | 24 ++++----
   sandbox/SOC/2010/bit_masks/boost/integer/details/bft/ext/bitfield_iterator.hpp | 102 +++++++++++++++++++++++++++++++++++++--
   sandbox/SOC/2010/bit_masks/boost/integer/details/bit_mask_group_fusion_ext/bit_mask_group_iterator.hpp | 6 +-
   sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/fusion_integration_testing.cpp | 18 ++++++
   4 files changed, 127 insertions(+), 23 deletions(-)

Modified: sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp 2010-06-15 14:48:47 EDT (Tue, 15 Jun 2010)
@@ -51,7 +51,7 @@
     /** Proxy type returned by get functions.
      * This serves as the go between things within this class.
      */
- template <typename Mask_Info>
+ template <typename MaskInfo>
     struct bit_ref {
 
         /** typedefs
@@ -61,8 +61,8 @@
          * mask - contains all information needed to iteract with data in the
          * the stroage.
          */
- typedef typename Mask_Info::return_type return_type;
- typedef bit_ref<Mask_Info> _self;
+ typedef typename MaskInfo::return_type return_type;
+ typedef bit_ref<MaskInfo> _self;
         typedef typename make_unsigned<return_type>::type unsigned_return_type;
         typedef typename make_unsigned<
             storage_type
@@ -73,8 +73,8 @@
          */
         typedef typename integer::bitfield<
             unsigned_storage_type,
- Mask_Info::offset::value,
- Mask_Info::offset::value + Mask_Info::field_width::value - 1
+ MaskInfo::offset::value,
+ MaskInfo::offset::value + MaskInfo::field_width::value - 1
> bitfield_type;
 
 
@@ -97,7 +97,7 @@
         /** copy constructor.
          * This is because references are copy construtible.
          */
- // bit_ref( bit_ref<Mask_Info> const& x)
+ // bit_ref( bit_ref<MaskInfo> const& x)
         // :_ref( x )
         // { }
         
@@ -126,7 +126,7 @@
         bit_ref();
     };
 
- template <typename Mask_Info>
+ template <typename MaskInfo>
     struct const_bit_ref {
 
         /** typedefs
@@ -136,8 +136,8 @@
          * mask - contains all information needed to iteract with data in the
          * the stroage.
          */
- typedef typename Mask_Info::return_type return_type;
- typedef bit_ref<Mask_Info> _self;
+ typedef typename MaskInfo::return_type return_type;
+ typedef bit_ref<MaskInfo> _self;
         typedef typename make_unsigned<return_type>::type unsigned_return_type;
         typedef typename make_unsigned<
             storage_type
@@ -148,8 +148,8 @@
          */
         typedef typename integer::bitfield<
             unsigned_storage_type,
- Mask_Info::offset::value,
- Mask_Info::offset::value + Mask_Info::field_width::value - 1
+ MaskInfo::offset::value,
+ MaskInfo::offset::value + MaskInfo::field_width::value - 1
> bitfield_type;
 
 
@@ -164,7 +164,7 @@
         /** copy constructor.
          * This is because references are copy construtible.
          */
- // bit_ref( bit_ref<Mask_Info> const& x)
+ // bit_ref( bit_ref<MaskInfo> const& x)
         // :_ref( x )
         // { }
         

Modified: sandbox/SOC/2010/bit_masks/boost/integer/details/bft/ext/bitfield_iterator.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/details/bft/ext/bitfield_iterator.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/details/bft/ext/bitfield_iterator.hpp 2010-06-15 14:48:47 EDT (Tue, 15 Jun 2010)
@@ -10,23 +10,111 @@
 #include <boost/mpl/assert.hpp>
 #include <boost/mpl/if.hpp>
 #include <boost/mpl/minus.hpp>
+#include <boost/mpl/size_t.hpp>
 #include <boost/type_traits/is_const.hpp>
 #include <boost/fusion/iterator/iterator_facade.hpp>
+#include <boost/mpl/void.hpp>
+#include <boost/fusion/iterator/value_of.hpp>
+#include <boost/fusion/include/value_of.hpp>
 
-namespace boost { namespace fusion {
+
+
+
+namespace boost {
+
+namespace details {
+struct category
+ : boost::fusion::random_access_traversal_tag,
+ boost::fusion::associative_tag
+{ };
+
+typedef mpl::void_ IMPLEMENT_ME;
+} // end detials
 
 /** Fusion Iterator for bitfield_tuple class.
  * This is an iterator over an associative array type.
  */
-template <typename Bitfeid_Tuple, std::size_t Pos>
+template <typename BitfieldTuple, std::size_t Pos>
 struct bitfield_tuple_iterator
- : iterator_facade<
- bitfield_tuple_iterator<Bitfeid_Tuple, Pos>,
- random_access_traversal_tag
+ : fusion::iterator_facade<
+ bitfield_tuple_iterator<BitfieldTuple, Pos>,
+ details::category
>
-{ };
+{
+ /** Constructor over a bitfield tuple. */
+ bitfield_tuple_iterator(BitfieldTuple& bft)
+ : _data(bft) { }
+
+ /** Important information about the current iterators
+ * template parameters.
+ */
+ //@{
+ typedef mpl::size_t<Pos> index;
+ typedef BitfieldTuple bitfield_tuple_type;
+ //@}
+
+ /** member value Of struct.
+ *
+ */
+ template<typename Iter>
+ struct value_of {
+ typedef typename Iter::bitfield_tuple_type::template bit_ref<
+ typename mpl::at<
+ typename Iter::bitfield_tuple_type::members,
+ typename Iter::index
+ >::type
+ > type;
+ };
+
+ template <typename Iter>
+ struct deref {
+ // the type returned by dereferencing the iterator.
+ typedef typename details::IMPLEMENT_ME type;
+ // dereference operation.
+ static type call(Iter& iter);
+ };
+
+ template<typename Iter>
+ struct next {
+ typedef typename details::IMPLEMENT_ME type;
+ static type call(Iter& iter);
+ };
+
+ template<typename Iter>
+ struct prior {
+ typedef typename details::IMPLEMENT_ME type;
+ static type call(Iter& iter);
+ };
+
+ template <typename Iter1,typename Iter2>
+ struct distance {
+ // The distance between iterators of type It1 and It2 as
+ // an MPL Integral Constant
+ typedef typename details::IMPLEMENT_ME type;
+ static type call(Iter1& it1,Iter2& it2);
+ };
+
+ template <typename Iter>
+ struct key_of {
+ typedef typename details::IMPLEMENT_ME type;
+ };
+
+ template <typename Iter>
+ struct value_of_data {
+ typedef typename details::IMPLEMENT_ME type;
+ };
+
+ template <typename Iter>
+ struct deref_data {
+ typedef typename details::IMPLEMENT_ME type;
+ static type call(Iter& it);
+ };
+
+private:
+ BitfieldTuple& _data;
+};
 
-}} // end boost::fusion
+} // end boost::fusion
 
 
 #endif

Modified: sandbox/SOC/2010/bit_masks/boost/integer/details/bit_mask_group_fusion_ext/bit_mask_group_iterator.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/details/bit_mask_group_fusion_ext/bit_mask_group_iterator.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/details/bit_mask_group_fusion_ext/bit_mask_group_iterator.hpp 2010-06-15 14:48:47 EDT (Tue, 15 Jun 2010)
@@ -20,16 +20,16 @@
  * As the type bit_mask_group is trivially constructible, copyable and
  * destructable there is no member to actually hold any data.
  */
-template<typename Mask_Group, unsigned int Pos>
+template<typename MaskGroup, unsigned int Pos>
 struct bit_mask_group_iterator
     : iterator_facade<
- bit_mask_group_iterator<Mask_Group, Pos>,
+ bit_mask_group_iterator<MaskGroup, Pos>,
         random_access_traversal_tag
>
 {
     // TODO: At a later time add preconditions for the iterator.
     // maybe
- typedef Mask_Group mask_group;
+ typedef MaskGroup mask_group;
     typedef boost::mpl::int_<Pos> index;
     typedef boost::fusion::random_access_traversal_tag category;
 

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/fusion_integration_testing.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/fusion_integration_testing.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/fusion_integration_testing.cpp 2010-06-15 14:48:47 EDT (Tue, 15 Jun 2010)
@@ -25,12 +25,28 @@
 
 
 int main() {
- // tag of testing
+ // bitfield_tuple tag_of testing
     {
         // bitfield_tuple_tag
         typedef fusion::traits::tag_of<test_tuple>::type tag;
         BOOST_MPL_ASSERT(( is_same< tag, fusion::bitfield_tuple_tag> ));
     }
+ // iterator tag_of testing. still don't know if this is really needed
+ // for fusion integration, at any rate I can't seem to get it to work.
+ {
+ // typedef bitfield_tuple_iterator<test_tuple,0> iter;
+ // typedef fusion::traits::tag_of<iter>::type tag;
+ // BOOST_MPL_ASSERT(( is_same<bitfield_tuple_iterator_tag, tag> ));
+ }
+
+ // iterator value of testing.
+ // this is strange to tes, because of the construction of the
+ // members vector.
+ {
+ typedef bitfield_tuple_iterator<test_tuple,0> iter;
+ typedef fusion::result_of::value_of<iter>::type value_of_result;
+ BOOST_MPL_ASSERT(( is_same< value_of_result::return_type, char> ));
+ }
     /*
     bmg_t bmg;
 


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