Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r73625 - sandbox/SOC/2011/checks/boost/checks
From: pierre.talbot.6114_at_[hidden]
Date: 2011-08-09 12:15:09


Author: trademark
Date: 2011-08-09 12:15:09 EDT (Tue, 09 Aug 2011)
New Revision: 73625
URL: http://svn.boost.org/trac/boost/changeset/73625

Log:
A weight is the contribution to a value on a sequence. This class encapsulate one or more weights and provide an unique static method to access it. This method returns the weight of the corresponding position of the current value analyzed.

This structure is used by the check algorithm that used weighted-sequence.
Added:
   sandbox/SOC/2011/checks/boost/checks/weight.hpp (contents, props changed)

Added: sandbox/SOC/2011/checks/boost/checks/weight.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2011/checks/boost/checks/weight.hpp 2011-08-09 12:15:09 EDT (Tue, 09 Aug 2011)
@@ -0,0 +1,42 @@
+// Boost checks/weight.hpp header file ------------------------------------//
+// (C) Copyright Pierre Talbot 2011
+// 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 updates, documentation, and revision history.
+
+#ifndef BOOST_CHECK_WEIGHT_HPP
+#define BOOST_CHECK_WEIGHT_HPP
+
+#include <boost/preprocessor/repetition.hpp>
+#include <boost/preprocessor/facilities/intercept.hpp>
+
+#define BOOST_CHECK_LIMIT_WEIGHTS 10
+
+namespace boost{
+ namespace checks{
+
+template <BOOST_PP_ENUM_BINARY_PARAMS(BOOST_CHECK_LIMIT_WEIGHTS, int weight_value, = 0 BOOST_PP_INTERCEPT) >
+struct weight
+{
+ static int weight_associated_with_pos(const unsigned int &value_pos) { return 1; }
+};
+
+#define _WEIGHT_factory(z, weight_size ,unused) \
+ template<BOOST_PP_ENUM_PARAMS(weight_size , int weight_value)> \
+ struct weight<BOOST_PP_ENUM_PARAMS(weight_size, weight_value)> \
+ { \
+ static int weight_associated_with_pos(const unsigned int &value_pos) \
+ { \
+ static const int weights[weight_size] = { BOOST_PP_ENUM_PARAMS(weight_size, weight_value) } ; \
+ return weights[value_pos % weight_size] ; \
+ } \
+ } ;
+
+// Develop the macro _WEIGHT_factory BOOST_CHECK_LIMIT_WEIGHTS times.
+BOOST_PP_REPEAT_FROM_TO(1,BOOST_CHECK_LIMIT_WEIGHTS,_WEIGHT_factory,~)
+#undef _WEIGHT_factory
+
+}}
+
+#endif //BOOST_CHECK_WEIGHT_HPP
\ No newline at end of file


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