SST  9.0.0
StructuralSimulationToolkit
timeConverter.h
1 // Copyright 2009-2019 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-2019, 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) {
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) {
44  return time/factor;
45  }
46 
47  /**
48  * Return the factor used for conversions with Core Time
49  */
50  SimTime_t getFactor() {
51  return factor;
52  }
53 
54  private:
55  /**
56  Factor for converting between core and component time
57  */
58  SimTime_t factor;
59 
60  TimeConverter(SimTime_t fact) {
61  factor = fact;
62  }
63 
64  ~TimeConverter() {
65  }
66 
67 
68  TimeConverter() {} // Only needed to simplify serialization
69 
70 };
71 
72 } // namespace SST
73 
74 #endif //SST_CORE_TIMECONVERTER_H
SimTime_t getFactor()
Return the factor used for conversions with Core Time.
Definition: timeConverter.h:50
A class to convert between a component&#39;s view of time and the core&#39;s view of time.
Definition: timeConverter.h:25
SimTime_t convertToCoreTime(SimTime_t time)
Converts from the component&#39;s view to the core&#39;s view of time.
Definition: timeConverter.h:34
Class for creating and managing TimeConverter objects.
Definition: timeLord.h:36
SimTime_t convertFromCoreTime(SimTime_t time)
Converts from the core&#39;s view to the components&#39;s view of time.
Definition: timeConverter.h:43