// Boost.Units - A C++ library for zero-overhead dimensional analysis and // unit/quantity manipulation and conversion // // Copyright (C) 2003-2008 Matthias Christian Schabel // Copyright (C) 2008 Steven Watanabe // // 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) #ifndef MCS_TEST_SYSTEM_HPP #define MCS_TEST_SYSTEM_HPP #include #include #include #include #include #include #include #include #include #include namespace boost { namespace units { //[test_system_snippet_1 /// base dimension of length struct length_base_dimension : base_dimension { }; /// base dimension of mass struct mass_base_dimension : base_dimension { }; /// base dimension of time struct time_base_dimension : base_dimension { }; //] #if 0 //[test_system_snippet_2 typedef make_dimension_list< boost::mpl::list< dim< length_base_dimension,static_rational<1> > > >::type length_dimension; typedef make_dimension_list< boost::mpl::list< dim< mass_base_dimension,static_rational<1> > > >::type mass_dimension; typedef make_dimension_list< boost::mpl::list< dim< time_base_dimension,static_rational<1> > > >::type time_dimension; //] #endif //[test_system_snippet_3 typedef length_base_dimension::dimension_type length_dimension; typedef mass_base_dimension::dimension_type mass_dimension; typedef time_base_dimension::dimension_type time_dimension; //] #if 0 //[test_system_snippet_4 typedef make_dimension_list< boost::mpl::list< dim< length_base_dimension,static_rational<2> > > >::type area_dimension; typedef make_dimension_list< boost::mpl::list< dim< mass_base_dimension,static_rational<1> >, dim< length_base_dimension,static_rational<2> >, dim< time_base_dimension,static_rational<-2> > > >::type energy_dimension; //] #endif //[test_system_snippet_5 typedef derived_dimension::type area_dimension; typedef derived_dimension::type energy_dimension; //] namespace test { //[test_system_snippet_6 struct meter_base_unit : base_unit { }; struct kilogram_base_unit : base_unit { }; struct second_base_unit : base_unit { }; typedef make_system< meter_base_unit, kilogram_base_unit, second_base_unit>::type mks_system; /// unit typedefs typedef unit dimensionless; typedef unit length; typedef unit mass; typedef unit time; typedef unit area; typedef unit energy; //] //[test_system_snippet_7 /// unit constants BOOST_UNITS_STATIC_CONSTANT(meter,length); BOOST_UNITS_STATIC_CONSTANT(meters,length); BOOST_UNITS_STATIC_CONSTANT(kilogram,mass); BOOST_UNITS_STATIC_CONSTANT(kilograms,mass); BOOST_UNITS_STATIC_CONSTANT(second,time); BOOST_UNITS_STATIC_CONSTANT(seconds,time); BOOST_UNITS_STATIC_CONSTANT(square_meter,area); BOOST_UNITS_STATIC_CONSTANT(square_meters,area); BOOST_UNITS_STATIC_CONSTANT(joule,energy); BOOST_UNITS_STATIC_CONSTANT(joules,energy); //] } // namespace test //[test_system_snippet_8 template<> struct base_unit_info { static std::string name() { return "meter"; } static std::string symbol() { return "m"; } }; //] template<> struct base_unit_info { static std::string name() { return "kilogram"; } static std::string symbol() { return "kg"; } }; template<> struct base_unit_info { static std::string name() { return "second"; } static std::string symbol() { return "s"; } }; } // namespace units } // namespace boost #endif // MCS_TEST_SYSTEM_HPP