Changeset 68:f9c7fc0f8d5e in rrlib_si_units


Ignore:
Timestamp:
11.01.2019 17:55:04 (4 months ago)
Author:
Max Reichardt <max.reichardt@…>
Branch:
17.03
Parents:
62:fbe593c8b8c8 (diff), 67:7fe4085c903f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Phase:
public
Message:

Merge with 14.08

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • rtti.cpp

    r64 r68  
    3333//---------------------------------------------------------------------- 
    3434#include "rrlib/si_units/si_units.h" 
     35#include "rrlib/rtti_conversion/tStaticCastOperation.h" 
     36#include "rrlib/rtti/tStaticTypeRegistration.h" 
    3537 
    3638//---------------------------------------------------------------------- 
     
    6769//---------------------------------------------------------------------- 
    6870 
    69 rtti::tType cINIT_TYPES[] = 
    70 { 
    71   rtti::tDataType<tLength<double>>(), 
    72   rtti::tDataType<tLength<float>>(), 
    73   rtti::tDataType<tMass<double>>(), 
    74   rtti::tDataType<tMass<float>>(), 
    75   rtti::tDataType<tTime<double>>(), 
    76   rtti::tDataType<tTime<float>>(), 
    77   rtti::tDataType<tElectricCurrent<double>>(), 
    78   rtti::tDataType<tElectricCurrent<float>>(), 
    79   rtti::tDataType<tTemperature<double>>(), 
    80   rtti::tDataType<tTemperature<float>>(), 
    81   rtti::tDataType<tAmountOfSubstance<double>>(), 
    82   rtti::tDataType<tAmountOfSubstance<float>>(), 
    83   rtti::tDataType<tLuminousIntensity<double>>(), 
    84   rtti::tDataType<tLuminousIntensity<float>>(), 
     71rtti::tStaticTypeRegistration init_type = rtti::tStaticTypeRegistration("rrlib_si_units"). 
     72    Add<tLength<>>("rrlib.si_units.Length", "Quantity<m, double>"). 
     73    Add<tMass<>>("rrlib.si_units.Mass", "Quantity<kg, double>"). 
     74    Add<tTime<>>("rrlib.si_units.Time", "Quantity<s, double>"). 
     75    Add<tElectricCurrent<>>("rrlib.si_units.ElectricCurrent", "Quantity<A, double>"). 
     76    Add<tTemperature<>>("rrlib.si_units.Temperature", "Quantity<K, double>"). 
     77    Add<tAmountOfSubstance<>>("rrlib.si_units.AmountOfSubstance"). 
     78    Add<tLuminousIntensity<>>("rrlib.si_units.LuminousIntensity"). 
    8579 
    86   rtti::tDataType<tFrequency<double>>(), 
    87   rtti::tDataType<tFrequency<float>>(), 
    88   rtti::tDataType<tForce<double>>(), 
    89   rtti::tDataType<tForce<float>>(), 
    90   rtti::tDataType<tPressure<double>>(), 
    91   rtti::tDataType<tPressure<float>>(), 
     80    Add<tFrequency<>>("rrlib.si_units.Frequency", "Quantity<1/s, double>"). 
     81    Add<tForce<>>("rrlib.si_units.Force", "Quantity<N, double>"). 
     82    Add<tPressure<>>("rrlib.si_units.Pressure", "Quantity<Pa, double>"). 
    9283 
    93   rtti::tDataType<tVelocity<double>>(), 
    94   rtti::tDataType<tVelocity<float>>(), 
    95   rtti::tDataType<tAcceleration<double>>(), 
    96   rtti::tDataType<tAcceleration<float>>(), 
     84    Add<tVelocity<>>("rrlib.si_units.Velocity", "Quantity<m/s, double>"). 
     85    Add<tAcceleration<>>("rrlib.si_units.Acceleration", "Quantity<m/s^2, double>"). 
     86    Add<tAngularVelocity<>>("rrlib.si_units.AngularVelocity", "Quantity<1/s, Angle>"). 
     87    Add<tAngularAcceleration<>>("rrlib.si_units.AngularAcceleration", "Quantity<1/s^2, Angle>"). 
    9788 
    98   rtti::tDataType<tAngularVelocity<double, math::angle::Radian>>(), 
    99   rtti::tDataType<tAngularVelocity<float, math::angle::Radian>>(), 
    100   rtti::tDataType<tAngularVelocity<double, math::angle::Degree>>(), 
    101   rtti::tDataType<tAngularVelocity<float, math::angle::Degree>>(), 
    102 }; 
     89    Add<tQuantity<tNoUnit, rrlib::math::tAngleRad>>("rrlib.si_units.Angle", "Quantity<, rrlib.math.Angle<double, rrlib.math.angle.Radian, rrlib.math.angle.Signed>>"); 
     90 
     91auto& cTYPE_CASTS = rrlib::rtti::conversion::tStaticCastOperation::Register<rrlib::time::tDuration, rrlib::si_units::tTime<>, true>(); 
    10392 
    10493//---------------------------------------------------------------------- 
  • tQuantity.h

    r57 r68  
    334334} 
    335335 
     336template <typename TUnit, typename TValue> 
     337std::istream &operator >> (std::istream &stream, tQuantity<TUnit, TValue>& quantity) 
     338{ 
     339  TValue value = 0; 
     340  stream >> value; 
     341  std::ostringstream unit_string; 
     342  unit_string << TUnit(); 
     343  internal::ReadSIUnit(stream, unit_string); 
     344  quantity = value; 
     345  return stream; 
     346} 
     347 
    336348#ifdef _LIB_RRLIB_SERIALIZATION_PRESENT_ 
    337349 
     
    355367inline serialization::tStringOutputStream &operator << (serialization::tStringOutputStream &stream, tQuantity<TUnit, TValue> quantity) 
    356368{ 
    357   std::stringstream str; 
    358   str << quantity; 
    359   stream << str.str(); 
     369  stream.GetWrappedStringStream() << quantity; 
    360370  return stream; 
    361371} 
Note: See TracChangeset for help on using the changeset viewer.