|
From: Matthias S. <mat...@us...> - 2007-04-02 21:24:49
|
Update of /cvsroot/boost-sandbox/boost-sandbox/boost/units/systems/conversions In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv663/conversions Modified Files: conversion_headers.hpp Added Files: convert_celsius_to_fahrenheit.hpp convert_celsius_to_kelvin.hpp convert_fahrenheit_to_celsius.hpp convert_fahrenheit_to_kelvin.hpp convert_kelvin_to_celsius.hpp convert_kelvin_to_fahrenheit.hpp Log Message: temperature conversions Index: conversion_headers.hpp =================================================================== RCS file: /cvsroot/boost-sandbox/boost-sandbox/boost/units/systems/conversions/conversion_headers.hpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- conversion_headers.hpp 29 Mar 2007 22:39:47 -0000 1.3 +++ conversion_headers.hpp 2 Apr 2007 21:24:44 -0000 1.4 @@ -16,6 +16,8 @@ #include <boost/units/systems/conversions/convert_si_to_cgs.hpp> #endif +// angle conversions + #if defined(BOOST_UNITS_DEGREES_HPP) && defined(BOOST_UNITS_GRADIANS_HPP) #include <boost/units/systems/conversions/convert_degrees_to_gradians.hpp> #include <boost/units/systems/conversions/convert_gradians_to_degrees.hpp> @@ -30,3 +32,20 @@ #include <boost/units/systems/conversions/convert_gradians_to_radians.hpp> #include <boost/units/systems/conversions/convert_radians_to_gradians.hpp> #endif + +// temperature conversions + +#if defined(BOOST_UNITS_CELSIUS_HPP) && defined(BOOST_UNITS_FAHRENHEIT_HPP) + #include <boost/units/systems/conversions/convert_celsius_to_fahrenheit.hpp> + #include <boost/units/systems/conversions/convert_fahrenheit_to_celsius.hpp> +#endif + +#if defined(BOOST_UNITS_CELSIUS_HPP) && defined(BOOST_UNITS_SI_TEMPERATURE_HPP) + #include <boost/units/systems/conversions/convert_celsius_to_kelvin.hpp> + #include <boost/units/systems/conversions/convert_kelvin_to_celsius.hpp> +#endif + +#if defined(BOOST_UNITS_FAHRENHEIT_HPP) && defined(BOOST_UNITS_SI_TEMPERATURE_HPP) + #include <boost/units/systems/conversions/convert_fahrenheit_to_kelvin.hpp> + #include <boost/units/systems/conversions/convert_kelvin_to_fahrenheit.hpp> +#endif --- NEW FILE: convert_kelvin_to_celsius.hpp --- // mcs::units - A C++ library for zero-overhead dimensional analysis and // unit/quantity manipulation and conversion // // Copyright (C) 2003-2007 Matthias Christian Schabel // Copyright (C) 2007 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 BOOST_UNITS_CONVERT_KELVIN_TO_CELSIUS_HPP #define BOOST_UNITS_CONVERT_KELVIN_TO_CELSIUS_HPP #include <boost/units/conversion.hpp> #include <boost/units/systems/si/temperature.hpp> #include <boost/units/systems/temperature/celsius.hpp> #include <boost/units/systems/conversions/convert_celsius_to_kelvin.hpp> namespace boost { namespace units { // convert absolute temperature in Kelvin to Celsius template<class Y> class conversion_helper< quantity<unit<temperature_type,SI::system>,absolute<Y> >, quantity<unit<temperature_type,celsius::system>,absolute<Y> > > { public: typedef unit<temperature_type,SI::system> unit1_type; typedef unit<temperature_type,celsius::system> unit2_type; typedef quantity<unit1_type,absolute<Y> > from_quantity_type; typedef quantity<unit2_type,absolute<Y> > to_quantity_type; static to_quantity_type convert(const from_quantity_type& source) { const typename from_quantity_type::value_type& in(source.value()); return to_quantity_type::from_value(in.value() - 273.16); } }; } // namespace units } // namespace boost #endif // BOOST_UNITS_CONVERT_KELVIN_TO_CELSIUS_HPP --- NEW FILE: convert_fahrenheit_to_kelvin.hpp --- // mcs::units - A C++ library for zero-overhead dimensional analysis and // unit/quantity manipulation and conversion // // Copyright (C) 2003-2007 Matthias Christian Schabel // Copyright (C) 2007 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 BOOST_UNITS_CONVERT_FAHRENHEIT_TO_KELVIN_HPP #define BOOST_UNITS_CONVERT_FAHRENHEIT_TO_KELVIN_HPP #include <boost/units/conversion.hpp> #include <boost/units/systems/si/temperature.hpp> #include <boost/units/systems/temperature/fahrenheit.hpp> namespace boost { namespace units { // convert temperature differences in Fahrenheit to Kelvin template<> struct base_unit_converter<temperature_tag,fahrenheit::system_tag,SI::system_tag> : #ifdef BOOST_UNITS_ENABLE_IMPLICIT_UNIT_CONVERSION public implicitly_convertible, #endif public trivial_inverse_conversion { typedef double type; static type value() { return (5.0/9.0); } }; // convert absolute temperature in Fahrenheit to Kelvin template<class Y> class conversion_helper< quantity<unit<temperature_type,fahrenheit::system>,absolute<Y> >, quantity<unit<temperature_type,SI::system>,absolute<Y> > > { public: typedef unit<temperature_type,fahrenheit::system> unit1_type; typedef unit<temperature_type,SI::system> unit2_type; typedef quantity<unit1_type,absolute<Y> > from_quantity_type; typedef quantity<unit2_type,absolute<Y> > to_quantity_type; static to_quantity_type convert(const from_quantity_type& source) { const typename from_quantity_type::value_type& in(source.value()); return to_quantity_type::from_value((in.value()-32.0)*(5.0/9.0) + 273.16); } }; } // namespace units } // namespace boost #endif // BOOST_UNITS_CONVERT_FAHRENHEIT_TO_KELVIN_HPP --- NEW FILE: convert_celsius_to_kelvin.hpp --- // mcs::units - A C++ library for zero-overhead dimensional analysis and // unit/quantity manipulation and conversion // // Copyright (C) 2003-2007 Matthias Christian Schabel // Copyright (C) 2007 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 BOOST_UNITS_CONVERT_CELSIUS_TO_KELVIN_HPP #define BOOST_UNITS_CONVERT_CELSIUS_TO_KELVIN_HPP #include <boost/units/conversion.hpp> #include <boost/units/systems/si/temperature.hpp> #include <boost/units/systems/temperature/celsius.hpp> namespace boost { namespace units { // convert temperature differences in Celsius to Kelvin template<> struct base_unit_converter<temperature_tag,celsius::system_tag,SI::system_tag> : #ifdef BOOST_UNITS_ENABLE_IMPLICIT_UNIT_CONVERSION public implicitly_convertible, #endif public trivial_conversion, public trivial_inverse_conversion { }; // convert absolute temperature in Celsius to Kelvin template<class Y> class conversion_helper< quantity<unit<temperature_type,celsius::system>,absolute<Y> >, quantity<unit<temperature_type,SI::system>,absolute<Y> > > { public: typedef unit<temperature_type,celsius::system> unit1_type; typedef unit<temperature_type,SI::system> unit2_type; typedef quantity<unit1_type,absolute<Y> > from_quantity_type; typedef quantity<unit2_type,absolute<Y> > to_quantity_type; static to_quantity_type convert(const from_quantity_type& source) { const typename from_quantity_type::value_type& in(source.value()); return to_quantity_type::from_value(in.value() + 273.16); } }; } // namespace units } // namespace boost #endif // BOOST_UNITS_CONVERT_CELSIUS_TO_KELVIN_HPP --- NEW FILE: convert_fahrenheit_to_celsius.hpp --- // mcs::units - A C++ library for zero-overhead dimensional analysis and // unit/quantity manipulation and conversion // // Copyright (C) 2003-2007 Matthias Christian Schabel // Copyright (C) 2007 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 BOOST_UNITS_CONVERT_FAHRENHEIT_TO_CELSIUS_HPP #define BOOST_UNITS_CONVERT_FAHRENHEIT_TO_CELSIUS_HPP #include <boost/units/conversion.hpp> #include <boost/units/systems/si/temperature.hpp> #include <boost/units/systems/temperature/celsius.hpp> #include <boost/units/systems/conversions/convert_celsius_to_fahrenheit.hpp> namespace boost { namespace units { // convert absolute temperature in Fahrenheit to Celsius template<class Y> class conversion_helper< quantity<unit<temperature_type,fahrenheit::system>,absolute<Y> >, quantity<unit<temperature_type,celsius::system>,absolute<Y> > > { public: typedef unit<temperature_type,fahrenheit::system> unit1_type; typedef unit<temperature_type,celsius::system> unit2_type; typedef quantity<unit1_type,absolute<Y> > from_quantity_type; typedef quantity<unit2_type,absolute<Y> > to_quantity_type; static to_quantity_type convert(const from_quantity_type& source) { const typename from_quantity_type::value_type& in(source.value()); return to_quantity_type::from_value((in.value() - 32.0)*(5.0/9.0)); } }; } // namespace units } // namespace boost #endif // BOOST_UNITS_CONVERT_FAHRENHEIT_TO_CELSIUS_HPP --- NEW FILE: convert_kelvin_to_fahrenheit.hpp --- // mcs::units - A C++ library for zero-overhead dimensional analysis and // unit/quantity manipulation and conversion // // Copyright (C) 2003-2007 Matthias Christian Schabel // Copyright (C) 2007 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 BOOST_UNITS_CONVERT_KELVIN_TO_FAHRENHEIT_HPP #define BOOST_UNITS_CONVERT_KELVIN_TO_FAHRENHEIT_HPP #include <boost/units/conversion.hpp> #include <boost/units/systems/si/temperature.hpp> #include <boost/units/systems/temperature/fahrenheit.hpp> #include <boost/units/systems/conversions/convert_fahrenheit_to_kelvin.hpp> namespace boost { namespace units { // convert absolute temperature in Kelvin to Fahrenheit template<class Y> class conversion_helper< quantity<unit<temperature_type,SI::system>,absolute<Y> >, quantity<unit<temperature_type,fahrenheit::system>,absolute<Y> > > { public: typedef unit<temperature_type,SI::system> unit1_type; typedef unit<temperature_type,fahrenheit::system> unit2_type; typedef quantity<unit1_type,absolute<Y> > from_quantity_type; typedef quantity<unit2_type,absolute<Y> > to_quantity_type; static to_quantity_type convert(const from_quantity_type& source) { const typename from_quantity_type::value_type& in(source.value()); return to_quantity_type::from_value((in.value()-273.16)*(9.0/5.0) + 32.0); } }; } // namespace units } // namespace boost #endif // BOOST_UNITS_CONVERT_KELVIN_TO_FAHRENHEIT_HPP --- NEW FILE: convert_celsius_to_fahrenheit.hpp --- // mcs::units - A C++ library for zero-overhead dimensional analysis and // unit/quantity manipulation and conversion // // Copyright (C) 2003-2007 Matthias Christian Schabel // Copyright (C) 2007 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 BOOST_UNITS_CONVERT_CELSIUS_TO_FAHRENHEIT_HPP #define BOOST_UNITS_CONVERT_CELSIUS_TO_FAHRENHEIT_HPP #include <boost/units/conversion.hpp> #include <boost/units/systems/si/temperature.hpp> #include <boost/units/systems/temperature/celsius.hpp> namespace boost { namespace units { // convert temperature differences in Celsius to Fahrenheit template<> struct base_unit_converter<temperature_tag,celsius::system_tag,fahrenheit::system_tag> : #ifdef BOOST_UNITS_ENABLE_IMPLICIT_UNIT_CONVERSION public implicitly_convertible, #endif public trivial_inverse_conversion { typedef double type; static type value() { return (9.0/5.0); } }; // convert absolute temperature in Celsius to Kelvin template<class Y> class conversion_helper< quantity<unit<temperature_type,celsius::system>,absolute<Y> >, quantity<unit<temperature_type,fahrenheit::system>,absolute<Y> > > { public: typedef unit<temperature_type,celsius::system> unit1_type; typedef unit<temperature_type,fahrenheit::system> unit2_type; typedef quantity<unit1_type,absolute<Y> > from_quantity_type; typedef quantity<unit2_type,absolute<Y> > to_quantity_type; static to_quantity_type convert(const from_quantity_type& source) { const typename from_quantity_type::value_type& in(source.value()); return to_quantity_type::from_value(in.value()*(9.0/5.0) + 32.0); } }; } // namespace units } // namespace boost #endif // BOOST_UNITS_CONVERT_CELSIUS_TO_FAHRENHEIT_HPP |