SST  11.0.0
StructuralSimulationToolkit
timeConverter.h
1 // Copyright 2009-2021 NTESS. Under the terms
2 // of Contract DE-NA0003525 with NTESS, the U.S.
3 // Government retains certain rights in this software.
4 //
5 // Copyright (c) 2009-2021, NTESS
6 // All rights reserved.
7 //
8 // This file is part of the SST software package. For license
9 // information, see the LICENSE file in the top level directory of the
10 // distribution.
11 
12 #ifndef SST_CORE_TIMECONVERTER_H
13 #define SST_CORE_TIMECONVERTER_H
14 
15 #include "sst/core/sst_types.h"
16 
17 namespace SST {
18 
19 class TimeLord;
20 
21 /**
22  A class to convert between a component's view of time and the
23  core's view of time.
24 */
26 
27  friend class TimeLord;
28 
29  public:
30  /**
31  Converts from the component's view to the core's view of time.
32  \param time time to convert to core time
33  */
34  SimTime_t convertToCoreTime(SimTime_t time) const {
35  return time * factor;
36  }
37 
38  /**
39  Converts from the core's view to the components's view of time.
40  The result is truncated, not rounded.
41  \param time time to convert from core time
42  */
43  SimTime_t convertFromCoreTime(SimTime_t time) const {
44  return time/factor;
45  }
46 
47  /**
48  * Return the factor used for conversions with Core Time
49  */
50  SimTime_t getFactor() const {
51  return factor;
52  }
53 
54  /**
55  Return the period represented by this TimeConverter as a
56  UnitAlgebra
57  */
58  UnitAlgebra getPeriod() const ; // Implemented in timeLord.cc
59 
60  private:
61  /**
62  Factor for converting between core and component time
63  */
64  SimTime_t factor;
65 
66  TimeConverter(SimTime_t fact) {
67  factor = fact;
68  }
69 
70  ~TimeConverter() {
71  }
72 
73 
74  TimeConverter() {} // Only needed to simplify serialization
75 
76 };
77 
78 } // namespace SST
79 
80 #endif //SST_CORE_TIMECONVERTER_H
A class to convert between a component's view of time and the core's view of time.
Definition: timeConverter.h:25
SimTime_t getFactor() const
Return the factor used for conversions with Core Time.
Definition: timeConverter.h:50
SimTime_t convertToCoreTime(SimTime_t time) const
Converts from the component's view to the core's view of time.
Definition: timeConverter.h:34
SimTime_t convertFromCoreTime(SimTime_t time) const
Converts from the core's view to the components's view of time.
Definition: timeConverter.h:43
UnitAlgebra getPeriod() const
Return the period represented by this TimeConverter as a UnitAlgebra.
Definition: timeLord.cc:127
Class for creating and managing TimeConverter objects.
Definition: timeLord.h:38
Performs Unit math in full precision.
Definition: unitAlgebra.h:107