cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
osaTimeServer.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3 
4 /*
5 
6  Author(s): Peter Kazanzides
7  Created on: 2008-12-30
8 
9  (C) Copyright 2008-2011 Johns Hopkins University (JHU), All Rights Reserved.
10 
11 --- begin cisst license - do not edit ---
12 
13 This software is provided "as is" under an open source license, with
14 no warranty. The complete license can be found in license.txt and
15 http://www.cisst.org/cisst/license.txt.
16 
17 --- end cisst license ---
18 */
19 
20 
26 #ifndef _osaTimeServer_h
27 #define _osaTimeServer_h
28 
31 
32 // Always include last
34 
35 // PKAZ: move this to osaGetTime.h
37  long sec; // seconds
38  long nsec; // nano-seconds
39 
40  osaAbsoluteTime() : sec(0L), nsec(0L) {}
41  osaAbsoluteTime(long seconds, long nanoseconds) : sec(seconds), nsec(nanoseconds) {}
43 
45  double ToSeconds(void) const;
46 
48  void FromSeconds(double timeInSeconds);
49 };
50 
51 
74 {
76 
77  friend class osaTimeServerTest;
78 
80  enum {INTERNALS_SIZE = 32};
81  char Internals[INTERNALS_SIZE];
82 
85  static unsigned int SizeOfInternals(void);
86 
89  void Synchronize(void);
90 
91 public:
93  osaTimeServer();
95  ~osaTimeServer();
96 
100  void SetTimeOrigin(void);
101 
105  void SetTimeOriginFrom(const osaTimeServer *other);
106 
110  bool GetTimeOrigin(osaAbsoluteTime & origin) const;
111 
114  double GetRelativeTime(void) const;
115 
118  double GetAbsoluteTimeInSeconds(void) const;
119 
122  osaAbsoluteTime GetAbsoluteTime(void) const;
123 
125  double EstimateDrift(void) const;
126 
132  void RelativeToAbsolute(double relative, osaAbsoluteTime & absolute) const;
133 
139  double AbsoluteToRelative(const osaAbsoluteTime & absolute) const;
140 };
141 
142 
144 
145 
146 #endif // _osaTimeServer_h
147 
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
~osaAbsoluteTime()
Definition: osaTimeServer.h:42
Base class for high level objects.
Definition: cmnGenericObject.h:51
Class register definitions and log macros.
osaAbsoluteTime()
Definition: osaTimeServer.h:40
osaAbsoluteTime(long seconds, long nanoseconds)
Definition: osaTimeServer.h:41
Defines cmnGenericObject.
Macros to export the symbols of cisstOSAbstraction (in a Dll).
#define CMN_DECLARE_SERVICES(hasDynamicCreation, lod)
Definition: cmnClassRegisterMacros.h:116
Class for relative time.
Definition: osaTimeServer.h:73
long sec
Definition: osaTimeServer.h:37
const int CMN_NO_DYNAMIC_CREATION
Definition: cmnClassRegisterMacros.h:328
long nsec
Definition: osaTimeServer.h:38
#define CMN_DECLARE_SERVICES_INSTANTIATION(className)
Definition: cmnClassRegisterMacros.h:202
Definition: osaTimeServer.h:36
#define CMN_LOG_ALLOW_DEFAULT
Definition: cmnLogLoD.h:76