• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

sst/core/timeConverter.h

00001 // Copyright 2009-2010 Sandia Corporation. Under the terms
00002 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
00003 // Government retains certain rights in this software.
00004 // 
00005 // Copyright (c) 2009-2010, Sandia Corporation
00006 // All rights reserved.
00007 // 
00008 // This file is part of the SST software package. For license
00009 // information, see the LICENSE file in the top level directory of the
00010 // distribution.
00011 
00012 
00013 #ifndef SST_TIMECONVERTER_H
00014 #define SST_TIMECONVERTER_H
00015 
00016 #include <sst/core/sst_types.h>
00017 
00018 namespace SST {
00019 
00020 class TimeLord;
00021 
00022 /**
00023    A class to convert between a component's view of time and the
00024    core's view of time.
00025 */
00026 class TimeConverter {
00027 
00028     friend class TimeLord;
00029   
00030  public:
00031     /**
00032        Converts from the component's view to the core's view of time.
00033        \param time time to convert to core time
00034      */
00035     SimTime_t convertToCoreTime(SimTime_t time) {
00036         return time * factor;
00037     }
00038     
00039     /**
00040        Converts from the core's view to the components's view of time.
00041        The result is truncated, not rounded.
00042        \param time time to convert from core time
00043      */
00044     SimTime_t convertFromCoreTime(SimTime_t time) {
00045         return time/factor;
00046     }
00047 
00048     SimTime_t getFactor() {
00049         return factor;
00050     }    
00051     
00052  private:
00053     /**
00054        Factor for converting between core and component time
00055     */
00056     SimTime_t factor;
00057     
00058     TimeConverter(SimTime_t fact) {
00059         factor = fact;
00060     }
00061 
00062     ~TimeConverter() {
00063     }
00064     
00065 
00066     // Boost serialization from here down
00067     TimeConverter() {}   // Only needed to simplify serialization
00068 
00069     friend class boost::serialization::access;
00070     template<class Archive>
00071     void serialize(Archive & ar, const unsigned int version ) {
00072         ar & BOOST_SERIALIZATION_NVP(factor);
00073     }
00074 };    
00075 
00076 } // namespace SST
00077 
00078 BOOST_CLASS_EXPORT_KEY(SST::TimeConverter)
00079 
00080 #endif

Generated on Fri Oct 22 2010 11:02:21 for SST by  doxygen 1.7.1