C:/nobackup/private/physical_svn/trunk/include/physical/detail/fixedexponents.hpp

Go to the documentation of this file.
00001 
00002 /*=============================================================================
00003     physical quantities / units / constants
00004     Copyright (c) 2006, 2007 Martin Schulz
00005     http://physical.sourceforge.net
00006   
00007     This is private code by Martin Schulz.
00008   
00009     Use, modification and distribution is subject to the Boost Software
00010     License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
00011     http://www.boost.org/LICENSE_1_0.txt)
00012 =============================================================================*/
00013 
00014 #ifndef PHYSICAL_FIXEDEXPONENTS
00015 #define PHYSICAL_FIXEDEXPONENTS
00016 
00017 #include "physical/config.hpp"
00018 #include "physical/detail/dimension_vector.hpp"
00019 
00020 #include <boost/mpl/size.hpp>
00021 #include <boost/mpl/transform.hpp>
00022 #include <boost/static_assert.hpp>
00023 
00024 namespace physical {
00025 
00026         namespace detail {
00027 
00028         
00029         /* define static exponents and associated compile time operations 
00030 
00031                 implementation based on boost compile time vector.
00032 
00033                 */
00034 
00035                 template<class UnitSystem, class ExpVector>
00036                 struct FixedExponents {
00037                         typedef ExpVector dimensions;
00038 
00039                         BOOST_STATIC_ASSERT(( boost::mpl::size<dimensions>::value==UnitSystem::number_baseunits ));
00040                 };
00041 
00042 
00043                 template<class fixedexponents1, class fixedexponents2>
00044                 struct plus; // general implementation not provided, only specialisation
00045 
00046                 template<class UnitSystem, class ExpVector1, class ExpVector2>
00047                 struct plus< FixedExponents<UnitSystem, ExpVector1>, FixedExponents<UnitSystem, ExpVector2> >  {
00048                         typedef struct FixedExponents<
00049             UnitSystem, 
00050                                 typename boost::mpl::transform<
00051                                         ExpVector1, ExpVector2, 
00052                                         boost::mpl::plus<boost::mpl::placeholders::_1, boost::mpl::placeholders::_2> 
00053                                 >::type
00054                         > type;
00055                 };
00056 
00057                 template<class fixedexponents1, class fixedexponents2>
00058                 struct minus; // general implementation not provided, only specialisation
00059 
00060 
00061                 template<class UnitSystem, class ExpVector1, class ExpVector2>
00062                 struct minus< FixedExponents<UnitSystem, ExpVector1>, FixedExponents<UnitSystem, ExpVector2> > {
00063                         typedef struct FixedExponents<
00064             UnitSystem, 
00065                                 typename boost::mpl::transform<
00066                                         ExpVector1, ExpVector2, 
00067                                         boost::mpl::minus<boost::mpl::placeholders::_1, boost::mpl::placeholders::_2> 
00068                                 >::type
00069                         > type;
00070                 };
00071 
00072                 template<class UnitSystem, int Pos>
00073                 struct FixExponents{
00074                         typedef FixedExponents<UnitSystem, typename dimension_vector<Pos, UnitSystem::number_baseunits>::type> type;
00075                 };
00076 
00077         }; // namespace detail
00078 
00079 }; // namespace physical
00080 
00081 #endif

Generated on Mon Apr 2 22:25:03 2007 for physical_svn by  doxygen 1.5.1-p1
hosted on SourceForge.net Logo