[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[certi-cvs] certi libHLA/sha1.h libHLA/HLAbuffer.hh libHLA/...
From: |
certi-cvs |
Subject: |
[certi-cvs] certi libHLA/sha1.h libHLA/HLAbuffer.hh libHLA/... |
Date: |
Sun, 21 Mar 2010 17:10:12 +0000 |
CVSROOT: /sources/certi
Module name: certi
Changes by: Eric NOULARD <erk> 10/03/21 17:10:11
Modified files:
libHLA : sha1.h HLAbuffer.hh CMakeLists.txt
libCERTI : CMakeLists.txt
RTIA : CMakeLists.txt RTIA.cc RTIA.hh
test/utility : CertiUtilTests.cc
Added files:
libHLA : WinClock.hh TestClocks.cc Clock.cc libhla.hh
ClockFactory.cc PosixClock.hh WinClock.cc
WinPerfClock.hh PosixClock.cc
GettimeofdayClock.hh WinPerfClock.cc
TSCClock.hh TSCClock.cc GettimeofdayClock.cc
Clock.hh
Removed files:
libCERTI : TSCClock.cc WinPerfClock.hh TSCClock.hh
PosixClock.hh WinClock.hh GettimeofdayClock.hh
WinClock.cc Clock.cc GettimeofdayClock.cc
Clock.hh ClockFactory.cc WinPerfClock.cc
PosixClock.cc
Log message:
Moving Clock classes to libHLA
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/sha1.h?cvsroot=certi&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/HLAbuffer.hh?cvsroot=certi&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/CMakeLists.txt?cvsroot=certi&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/WinClock.hh?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/TestClocks.cc?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/Clock.cc?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/libhla.hh?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/ClockFactory.cc?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/PosixClock.hh?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/WinClock.cc?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/WinPerfClock.hh?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/PosixClock.cc?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/GettimeofdayClock.hh?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/WinPerfClock.cc?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/TSCClock.hh?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/TSCClock.cc?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/GettimeofdayClock.cc?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/Clock.hh?cvsroot=certi&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/CMakeLists.txt?cvsroot=certi&r1=1.31&r2=1.32
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/TSCClock.cc?cvsroot=certi&r1=4.4&r2=0
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/WinPerfClock.hh?cvsroot=certi&r1=4.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/TSCClock.hh?cvsroot=certi&r1=4.3&r2=0
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/PosixClock.hh?cvsroot=certi&r1=4.4&r2=0
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/WinClock.hh?cvsroot=certi&r1=4.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/GettimeofdayClock.hh?cvsroot=certi&r1=4.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/WinClock.cc?cvsroot=certi&r1=4.2&r2=0
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/Clock.cc?cvsroot=certi&r1=4.5&r2=0
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/GettimeofdayClock.cc?cvsroot=certi&r1=4.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/Clock.hh?cvsroot=certi&r1=4.10&r2=0
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/ClockFactory.cc?cvsroot=certi&r1=4.2&r2=0
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/WinPerfClock.cc?cvsroot=certi&r1=4.2&r2=0
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/PosixClock.cc?cvsroot=certi&r1=4.4&r2=0
http://cvs.savannah.gnu.org/viewcvs/certi/RTIA/CMakeLists.txt?cvsroot=certi&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/certi/RTIA/RTIA.cc?cvsroot=certi&r1=3.32&r2=3.33
http://cvs.savannah.gnu.org/viewcvs/certi/RTIA/RTIA.hh?cvsroot=certi&r1=3.20&r2=3.21
http://cvs.savannah.gnu.org/viewcvs/certi/test/utility/CertiUtilTests.cc?cvsroot=certi&r1=1.17&r2=1.18
Patches:
Index: libHLA/sha1.h
===================================================================
RCS file: /sources/certi/certi/libHLA/sha1.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- libHLA/sha1.h 24 Jan 2010 17:10:28 -0000 1.3
+++ libHLA/sha1.h 21 Mar 2010 17:10:10 -0000 1.4
@@ -60,7 +60,7 @@
/*
* If you do not have the ISO standard stdint.h header file, then you
- * must typdef the following:
+ * must typedef the following:
* name meaning
* uint32_t unsigned 32 bit integer
* uint8_t unsigned 8 bit integer (i.e., unsigned char)
Index: libHLA/HLAbuffer.hh
===================================================================
RCS file: /sources/certi/certi/libHLA/HLAbuffer.hh,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- libHLA/HLAbuffer.hh 22 May 2009 06:32:06 -0000 1.10
+++ libHLA/HLAbuffer.hh 21 Mar 2010 17:10:10 -0000 1.11
@@ -11,7 +11,7 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
-// $Id: HLAbuffer.hh,v 1.10 2009/05/22 06:32:06 gotthardp Exp $
+// $Id: HLAbuffer.hh,v 1.11 2010/03/21 17:10:10 erk Exp $
// ----------------------------------------------------------------------------
#ifndef _HLATYPES_BUFFER_HH
@@ -22,29 +22,7 @@
#include <stdexcept>
#include <cstdlib>
-#ifdef _MSC_VER
-typedef unsigned __int64 uint64_t;
-typedef signed __int64 int64_t;
-typedef unsigned __int32 uint32_t;
-typedef signed __int32 int32_t;
-typedef unsigned __int16 uint16_t;
-typedef signed __int16 int16_t;
-typedef unsigned __int8 uint8_t;
-typedef signed __int8 int8_t;
-#else
-#include <inttypes.h>
-#endif
-
-#if defined(_WIN32)
- #pragma warning(disable: 4251)
- #if defined(HLA_EXPORTS)
- #define HLA_EXPORT __declspec(dllexport)
- #else
- #define HLA_EXPORT __declspec(dllimport)
- #endif
-#else
- #define HLA_EXPORT
-#endif
+#include "libhla.hh"
namespace libhla {
@@ -182,5 +160,5 @@
#endif // _HLATYPES_BUFFER_HH
-// $Id: HLAbuffer.hh,v 1.10 2009/05/22 06:32:06 gotthardp Exp $
+// $Id: HLAbuffer.hh,v 1.11 2010/03/21 17:10:10 erk Exp $
Index: libHLA/CMakeLists.txt
===================================================================
RCS file: /sources/certi/certi/libHLA/CMakeLists.txt,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- libHLA/CMakeLists.txt 16 Jan 2010 20:17:14 -0000 1.5
+++ libHLA/CMakeLists.txt 21 Mar 2010 17:10:10 -0000 1.6
@@ -1,14 +1,50 @@
+SET(LIBHLA_EXPORTED_INCLUDES libhla.hh)
-SET(CERTI_TYPES1516_SRCS
+SET(LIBHLA_TYPES1516_SRCS
HLAbuffer.hh HLAbuffer.cc
)
+LIST(APPEND LIBHLA_EXPORTED_INCLUDES
+ HLAtypesIEEE1516.hh
+ HLAbuffer.hh
+ HLAbasicType.hh
+ HLAenumeratedType.hh
+ HLAfixedArray.hh
+ HLAvariableArray.hh
+ HLAfixedRecord.hh
+ HLAvariantRecord.hh)
+
enable_language(C)
-SET(CERTI_UTILITY_SRCS sha1.c sha1.h)
+SET(LIBHLA_HASH_SRCS sha1.c)
+LIST(APPEND LIBHLA_EXPORTED_INCLUDES sha1.h)
set_source_files_properties(sha1.c sha1.h PROPERTIES LANGUAGE "C")
+SET(LIBHLA_CLOCK_SRCS
+ Clock.cc
+ ClockFactory.cc)
+LIST(APPEND LIBHLA_EXPORTED_INCLUDES Clock.hh)
+
+IF (HAVE_POSIX_CLOCK)
+ LIST(APPEND LIBHLA_CLOCK_SRCS PosixClock.cc)
+ LIST(APPEND LIBHLA_EXPORTED_INCLUDES PosixClock.hh)
+ENDIF(HAVE_POSIX_CLOCK)
+
+IF (HAVE_GETTIMEOFDAY)
+ LIST(APPEND LIBHLA_CLOCK_SRCS GettimeofdayClock.cc)
+ LIST(APPEND LIBHLA_EXPORTED_INCLUDES GettimeofdayClock.hh)
+ENDIF(HAVE_GETTIMEOFDAY)
+
+IF (HAVE_TSC_CLOCK)
+ LIST(APPEND LIBHLA_CLOCK_SRCS TSCClock.cc)
+ LIST(APPEND LIBHLA_EXPORTED_INCLUDES TSCClock.hh)
+ENDIF(HAVE_TSC_CLOCK)
+
+IF (HAVE_WIN_CLOCK)
+ LIST(APPEND LIBHLA_CLOCK_SRCS WinClock.cc WinPerfClock.cc)
+ LIST(APPEND LIBHLA_EXPORTED_INCLUDES WinClock.hh WinPerfClock.hh)
+ENDIF(HAVE_WIN_CLOCK)
-SOURCE_GROUP("Source Files\\Types1516" FILES ${CERTI_TYPES1516_SRCS})
+SOURCE_GROUP("Source Files\\Types1516" FILES ${LIBHLA_TYPES1516_SRCS})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
@@ -21,34 +57,30 @@
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
ADD_LIBRARY(HLA
- ${CERTI_TYPES1516_SRCS}
- ${CERTI_UTILITY_SRCS}
+ ${LIBHLA_TYPES1516_SRCS}
+ ${LIBHLA_HASH_SRCS}
+ ${LIBHLA_CLOCK_SRCS}
+ ${LIBHLA_EXPORTED_INCLUDES}
)
+IF (HAVE_POSIX_CLOCK)
+ TARGET_LINK_LIBRARIES(HLA ${RT_LIBRARY})
+ENDIF (HAVE_POSIX_CLOCK)
+
SET_TARGET_PROPERTIES(HLA PROPERTIES PROJECT_LABEL LibHLA)
SET_TARGET_PROPERTIES(HLA PROPERTIES VERSION 1.0.0 SOVERSION 1)
-SET(TestHLAtypes_SRCS
- TestHLAtypes.cc
-)
-
-ADD_EXECUTABLE(TestHLAtypes ${TestHLAtypes_SRCS})
-
+ADD_EXECUTABLE(TestHLAtypes TestHLAtypes.cc)
TARGET_LINK_LIBRARIES(TestHLAtypes HLA)
+ADD_TEST(LibHLAtypes TestHLAtypes)
-ADD_TEST(HLAtypes TestHLAtypes)
+ADD_EXECUTABLE(TestClocks TestClocks.cc)
+TARGET_LINK_LIBRARIES(TestClocks HLA)
+ADD_TEST(LibHLAClocks TestClocks)
INSTALL(FILES
- HLAtypesIEEE1516.hh
- HLAbuffer.hh
- HLAbasicType.hh
- HLAenumeratedType.hh
- HLAfixedArray.hh
- HLAvariableArray.hh
- HLAfixedRecord.hh
- HLAvariantRecord.hh
- sha1.h
+ ${LIBHLA_EXPORTED_INCLUDES}
DESTINATION include)
INSTALL(PROGRAMS
Index: libCERTI/CMakeLists.txt
===================================================================
RCS file: /sources/certi/certi/libCERTI/CMakeLists.txt,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- libCERTI/CMakeLists.txt 14 Mar 2010 12:06:37 -0000 1.31
+++ libCERTI/CMakeLists.txt 21 Mar 2010 17:10:10 -0000 1.32
@@ -73,8 +73,6 @@
AuditFile.cc AuditFile.hh
AuditLine.cc AuditLine.hh
BasicMessage.cc BasicMessage.hh
-Clock.cc Clock.hh
-ClockFactory.cc
MessageBuffer.cc MessageBuffer.hh
M_Classes.cc M_Classes.hh
Message.cc Message_RW.cc Message.hh
@@ -86,31 +84,6 @@
TreeNamedAndHandledSet.hh
)
-IF (HAVE_POSIX_CLOCK)
- SET(CERTI_SUPPORT_SRCS
- ${CERTI_SUPPORT_SRCS}
- PosixClock.cc PosixClock.hh)
-ENDIF(HAVE_POSIX_CLOCK)
-
-IF (HAVE_GETTIMEOFDAY)
- SET(CERTI_SUPPORT_SRCS
- ${CERTI_SUPPORT_SRCS}
- GettimeofdayClock.cc GettimeofdayClock.hh)
-ENDIF(HAVE_GETTIMEOFDAY)
-
-IF (HAVE_TSC_CLOCK)
- SET(CERTI_SUPPORT_SRCS
- ${CERTI_SUPPORT_SRCS}
- TSCClock.cc TSCClock.hh)
-ENDIF(HAVE_TSC_CLOCK)
-
-IF (HAVE_WIN_CLOCK)
- SET(CERTI_SUPPORT_SRCS
- ${CERTI_SUPPORT_SRCS}
- WinClock.cc WinClock.hh
- WinPerfClock.cc WinPerfClock.hh)
-ENDIF(HAVE_WIN_CLOCK)
-
SET(CERTI_SOCKET_SRCS
SocketServer.cc
SocketTCP.cc
@@ -254,10 +227,6 @@
DESTINATION lib)
ENDIF (MINGW)
-IF (HAVE_POSIX_CLOCK)
- TARGET_LINK_LIBRARIES(CERTI ${RT_LIBRARY})
-ENDIF (HAVE_POSIX_CLOCK)
-
SET_TARGET_PROPERTIES(CERTI PROPERTIES VERSION 1.0.0 SOVERSION 1)
INSTALL(TARGETS CERTI
Index: RTIA/CMakeLists.txt
===================================================================
RCS file: /sources/certi/certi/RTIA/CMakeLists.txt,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- RTIA/CMakeLists.txt 31 Aug 2009 14:18:55 -0000 1.8
+++ RTIA/CMakeLists.txt 21 Mar 2010 17:10:11 -0000 1.9
@@ -19,8 +19,11 @@
TimeManagement.cc TimeManagement.hh
)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/libHLA)
+
ADD_EXECUTABLE(rtia ${rtia_SRCS})
TARGET_LINK_LIBRARIES(rtia CERTI)
+TARGET_LINK_LIBRARIES(rtia HLA)
INSTALL(TARGETS rtia
RUNTIME DESTINATION bin
Index: RTIA/RTIA.cc
===================================================================
RCS file: /sources/certi/certi/RTIA/RTIA.cc,v
retrieving revision 3.32
retrieving revision 3.33
diff -u -b -r3.32 -r3.33
--- RTIA/RTIA.cc 14 Mar 2010 15:35:53 -0000 3.32
+++ RTIA/RTIA.cc 21 Mar 2010 17:10:11 -0000 3.33
@@ -18,14 +18,11 @@
// along with this program ; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// $Id: RTIA.cc,v 3.32 2010/03/14 15:35:53 gotthardp Exp $
+// $Id: RTIA.cc,v 3.33 2010/03/21 17:10:11 erk Exp $
// ----------------------------------------------------------------------------
#include <config.h>
#include "RTIA.hh"
-
-#include "Clock.hh"
-
#include <assert.h>
#include <math.h>
#include <limits.h>
@@ -37,7 +34,7 @@
RTIA::RTIA(int RTIA_port, int RTIA_fd) {
- clock = Clock::getBestClock();
+ clock = libhla::clock::Clock::getBestClock();
// No SocketServer is passed to the RootObject (RTIA use case)
// socket server are passed to RootObject iff we are in RTIG.
@@ -180,4 +177,4 @@
}} // namespace certi/rtia
-// $Id: RTIA.cc,v 3.32 2010/03/14 15:35:53 gotthardp Exp $
+// $Id: RTIA.cc,v 3.33 2010/03/21 17:10:11 erk Exp $
Index: RTIA/RTIA.hh
===================================================================
RCS file: /sources/certi/certi/RTIA/RTIA.hh,v
retrieving revision 3.20
retrieving revision 3.21
diff -u -b -r3.20 -r3.21
--- RTIA/RTIA.hh 14 Mar 2010 15:35:53 -0000 3.20
+++ RTIA/RTIA.hh 21 Mar 2010 17:10:11 -0000 3.21
@@ -18,7 +18,7 @@
// along with this program ; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// $Id: RTIA.hh,v 3.20 2010/03/14 15:35:53 gotthardp Exp $
+// $Id: RTIA.hh,v 3.21 2010/03/21 17:10:11 erk Exp $
// ----------------------------------------------------------------------------
#ifndef _CERTI_RTIA_HH
@@ -33,11 +33,10 @@
#include "DeclarationManagement.hh"
#include "DataDistribution.hh"
#include "Statistics.hh"
+#include "Clock.hh"
namespace certi {
-class Clock;
-
namespace rtia {
/**
@@ -84,7 +83,7 @@
OwnershipManagement *owm ;
DeclarationManagement *dm ;
DataDistribution *ddm ;
- Clock* clock ;
+ libhla::clock::Clock* clock ;
Statistics stat ;
void saveAndRestoreStatus(Message::Type type)
@@ -132,4 +131,4 @@
#endif // _CERTI_RTIA_HH
-// $Id: RTIA.hh,v 3.20 2010/03/14 15:35:53 gotthardp Exp $
+// $Id: RTIA.hh,v 3.21 2010/03/21 17:10:11 erk Exp $
Index: test/utility/CertiUtilTests.cc
===================================================================
RCS file: /sources/certi/certi/test/utility/CertiUtilTests.cc,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- test/utility/CertiUtilTests.cc 7 Mar 2010 22:15:42 -0000 1.17
+++ test/utility/CertiUtilTests.cc 21 Mar 2010 17:10:11 -0000 1.18
@@ -32,35 +32,6 @@
#include <cstring>
#include <cstdio>
-#include "Clock.hh"
-void clockTests(certi::Clock& aClock) {
- uint64_t tick1;
- uint64_t tick2;
- cout << "Testing clock <" << aClock.getName() << "> BEGIN..." <<endl;
- cout << " Clock resolution is: " << aClock.getResolution() << "
nano-seconds" <<endl;
- tick1 = aClock.getCurrentTicksValue();
- tick2 = aClock.getCurrentTicksValue();
- cout << " Tick1 = " << tick1 << endl;
- cout << " Tick2 = " << tick2 << endl;
- cout << " Delta = " << aClock.getDeltaNanoSecond(tick1,tick2) << "
nano-seconds" <<endl;
- cout << "Testing clock <" << aClock.getName() << "> END." <<endl;
-}
-#ifdef HAVE_TSC_CLOCK
-#include "TSCClock.hh"
-#endif
-#ifdef HAVE_POSIX_CLOCK
-#include "PosixClock.hh"
-#endif
-#ifdef HAVE_GETTIMEOFDAY
-#include "GettimeofdayClock.hh"
-#endif
-
-#ifdef HAVE_WIN_CLOCK
-#include "WinClock.hh"
-#include "WinPerfClock.hh"
-#endif
-
-
void messageBufferTests(certi::MessageBuffer& MsgBuf) {
certi::MessageBuffer MsgBuf2;
std::string stdstr = "a std:string";
@@ -247,19 +218,6 @@
int
main(int argc, char **argv)
{
-#ifdef HAVE_POSIX_CLOCK
- certi::PosixClock posixClk;
-#endif
-#ifdef HAVE_GETTIMEOFDAY
- certi::GettimeofdayClock gettimeofdayClock;
-#endif
-#ifdef HAVE_TSC_CLOCK
- certi::TSCClock tscClk;
-#endif
-#ifdef HAVE_WIN_CLOCK
- certi::WinClock WinClk;
- certi::WinPerfClock WinPerfClk;
-#endif
certi::MessageBuffer MsgBuf;
@@ -275,23 +233,6 @@
cout << endl;
messageBufferTests(MsgBuf);
-#ifdef HAVE_TSC_CLOCK
- clockTests(tscClk);
-#endif
-#ifdef HAVE_POSIX_CLOCK
- clockTests(posixClk);
-#endif
-#ifdef HAVE_GETTIMEOFDAY
- clockTests(gettimeofdayClock);
-#endif
-#ifdef HAVE_WIN_CLOCK
- clockTests(WinClk);
- clockTests(WinPerfClk);
-#endif
-
- certi::Clock *myClock = certi::Clock::getBestClock () ;
- clockTests(*myClock);
- delete myClock ;
cout << "CERTI Utility Test->END." <<endl;
/* getchar(); */
return 0;
Index: libHLA/WinClock.hh
===================================================================
RCS file: libHLA/WinClock.hh
diff -N libHLA/WinClock.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libHLA/WinClock.hh 21 Mar 2010 17:10:10 -0000 1.1
@@ -0,0 +1,42 @@
+#ifndef WinClock_HH_
+#define WinClock_HH_
+
+#include "Clock.hh"
+
+namespace libhla {
+namespace clock {
+/**
+ */
+class HLA_EXPORT WinClock : public Clock
+{
+public:
+ WinClock();
+ /**
+ * Get the clock resolution in nano-seconds.
+ * @return the clock resolution in nano-seconds
+ */
+ virtual double getResolution();
+ /**
+ * Get the current ticks value.
+ * @return the current ticks value
+ */
+ virtual uint64_t getCurrentTicksValue();
+ /**
+ * Convert a number of ticks into a double value
+ * representing nanoseconds.
+ * @param[in] ticks the number of tick to convert
+ * @return the nano-seconds value
+ */
+ virtual double tick2NanoSecond(const uint64_t ticks);
+ virtual ~WinClock();
+
+private:
+ /**
+ * The WinClock resolution in nano-seconds
+ */
+ double resolution;
+
+};
+} /* end namespace clock */
+} /* end namespace libhla */
+#endif /*WinClock_HH_*/
Index: libHLA/TestClocks.cc
===================================================================
RCS file: libHLA/TestClocks.cc
diff -N libHLA/TestClocks.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libHLA/TestClocks.cc 21 Mar 2010 17:10:10 -0000 1.1
@@ -0,0 +1,98 @@
+// ----------------------------------------------------------------------------
+// CERTI - HLA RunTime Infrastructure
+// Copyright (C) 2002-2005 ONERA
+//
+// This file is part of CERTI
+//
+// CERTI is free software ; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation ; either version 2 of the License, or
+// (at your option) any later version.
+//
+// CERTI is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY ; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program ; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// ----------------------------------------------------------------------------
+#include <iostream>
+using std::cout;
+using std::cerr;
+using std::endl;
+
+#include "config.h"
+#include <cassert>
+#include <string>
+#include <cstring>
+#include <cstdio>
+#include "Clock.hh"
+void clockTests(libhla::clock::Clock& aClock) {
+ uint64_t tick1;
+ uint64_t tick2;
+ cout << "Testing clock <" << aClock.getName() << "> BEGIN..." <<endl;
+ cout << " Clock resolution is: " << aClock.getResolution() << "
nano-seconds" <<endl;
+ tick1 = aClock.getCurrentTicksValue();
+ tick2 = aClock.getCurrentTicksValue();
+ cout << " Tick1 = " << tick1 << endl;
+ cout << " Tick2 = " << tick2 << endl;
+ cout << " Delta = " << aClock.getDeltaNanoSecond(tick1,tick2) << "
nano-seconds" <<endl;
+ cout << "Testing clock <" << aClock.getName() << "> END." <<endl;
+}
+#ifdef HAVE_TSC_CLOCK
+#include "TSCClock.hh"
+#endif
+#ifdef HAVE_POSIX_CLOCK
+#include "PosixClock.hh"
+#endif
+#ifdef HAVE_GETTIMEOFDAY
+#include "GettimeofdayClock.hh"
+#endif
+
+#ifdef HAVE_WIN_CLOCK
+#include "WinClock.hh"
+#include "WinPerfClock.hh"
+#endif
+
+
+int
+main(int argc, char **argv)
+{
+#ifdef HAVE_POSIX_CLOCK
+ libhla::clock::PosixClock posixClk;
+#endif
+#ifdef HAVE_GETTIMEOFDAY
+ libhla::clock::GettimeofdayClock gettimeofdayClock;
+#endif
+#ifdef HAVE_TSC_CLOCK
+ libhla::clock::TSCClock tscClk;
+#endif
+#ifdef HAVE_WIN_CLOCK
+ libhla::clock::WinClock WinClk;
+ libhla::clock::WinPerfClock WinPerfClk;
+#endif
+
+#ifdef HAVE_TSC_CLOCK
+ clockTests(tscClk);
+#endif
+#ifdef HAVE_POSIX_CLOCK
+ clockTests(posixClk);
+#endif
+#ifdef HAVE_GETTIMEOFDAY
+ clockTests(gettimeofdayClock);
+#endif
+#ifdef HAVE_WIN_CLOCK
+ clockTests(WinClk);
+ clockTests(WinPerfClk);
+#endif
+
+ libhla::clock::Clock *myClock = libhla::clock::Clock::getBestClock () ;
+ clockTests(*myClock);
+ delete myClock ;
+ cout << "LibHLA Clock Test->END." <<endl;
+ /* getchar(); */
+ return 0;
+}
Index: libHLA/Clock.cc
===================================================================
RCS file: libHLA/Clock.cc
diff -N libHLA/Clock.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libHLA/Clock.cc 21 Mar 2010 17:10:10 -0000 1.1
@@ -0,0 +1,49 @@
+// ----------------------------------------------------------------------------
+// CERTI - HLA RunTime Infrastructure
+// Copyright (C) 2002-2005 ONERA
+//
+// This program is free software ; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public License
+// as published by the Free Software Foundation ; either version 2 of
+// the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY ; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program ; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// ----------------------------------------------------------------------------
+
+#include "Clock.hh"
+namespace libhla {
+namespace clock {
+
+Clock::Clock(const std::string& newName)
+{
+ name = newName;
+}
+
+uint64_t
+Clock::getDeltaTicks(const uint64_t previousTicks) {
+ return (getCurrentTicksValue()-previousTicks);
+}
+
+double Clock::getDeltaNanoSecond(const uint64_t firstTicks, const uint64_t
secondTicks) {
+ return tick2NanoSecond(secondTicks-firstTicks);
+}
+
+double
+Clock::getDeltaNanoSecond(const uint64_t previousTicks) {
+ return tick2NanoSecond(getDeltaTicks(previousTicks));
+}
+
+
+Clock::~Clock()
+{
+}
+
+} /* end namespace clock */
+} /* end namespace libhla */
Index: libHLA/libhla.hh
===================================================================
RCS file: libHLA/libhla.hh
diff -N libHLA/libhla.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libHLA/libhla.hh 21 Mar 2010 17:10:10 -0000 1.1
@@ -0,0 +1,93 @@
+// ----------------------------------------------------------------------------
+// CERTI - HLA RunTime Infrastructure
+// Copyright (C) 2002-2005 ONERA
+//
+// This program is free software ; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public License
+// as published by the Free Software Foundation ; either version 2 of
+// the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY ; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program ; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// $Id: libhla.hh,v 1.1 2010/03/21 17:10:10 erk Exp $
+// ----------------------------------------------------------------------------
+
+#ifndef LIBHLA_HH_INCLUDED
+#define LIBHLA_HH_INCLUDED
+
+#ifdef _MSC_VER
+typedef unsigned __int64 uint64_t;
+typedef signed __int64 int64_t;
+typedef unsigned __int32 uint32_t;
+typedef signed __int32 int32_t;
+typedef unsigned __int16 uint16_t;
+typedef signed __int16 int16_t;
+typedef unsigned __int8 uint8_t;
+typedef signed __int8 int8_t;
+#else
+#include <inttypes.h>
+#endif
+
+#if defined(_WIN32)
+ #pragma warning(disable: 4251)
+ #if defined(HLA_EXPORTS)
+ #define HLA_EXPORT __declspec(dllexport)
+ #else
+ #define HLA_EXPORT __declspec(dllimport)
+ #endif
+#else
+ #define HLA_EXPORT
+#endif
+
+#include <string>
+#include <sstream>
+
+/**
+ * @defgroup libHLA The libHLA library.
+ * @ingroup CERTI_Libraries
+ * The HLA library contains RTI-agnostic functions and classes
+ * that may be used by a federate application.
+ */
+namespace libhla {
+
+/**
+ * Helper class to simplify string construction. Implemented as
+ * a stringstream wrapper.
+ *
+ * For example:
+ * throw AttributeNotDefined(stringize() << "value: " << number);
+ */
+template<typename C>
+struct basic_stringize
+{
+ template<typename T>
+ basic_stringize<C> & operator << (const T& t)
+ {
+ m_s << t;
+ return *this;
+ }
+
+ // note: must not return reference
+ operator const std::basic_string<C>() const
+ {
+ return m_s.str();
+ }
+
+private:
+ std::basic_stringstream<C> m_s;
+};
+
+typedef basic_stringize<char> stringize;
+typedef basic_stringize<wchar_t> wstringize;
+
+} // namespace libhla
+
+#endif // LIBHLA_HH_INCLUDED
+
Index: libHLA/ClockFactory.cc
===================================================================
RCS file: libHLA/ClockFactory.cc
diff -N libHLA/ClockFactory.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libHLA/ClockFactory.cc 21 Mar 2010 17:10:10 -0000 1.1
@@ -0,0 +1,68 @@
+// ----------------------------------------------------------------------------
+// CERTI - HLA RunTime Infrastructure
+// Copyright (C) 2002-2005 ONERA
+//
+// This program is free software ; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public License
+// as published by the Free Software Foundation ; either version 2 of
+// the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY ; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program ; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// ----------------------------------------------------------------------------
+
+#include "config.h"
+#include "Clock.hh"
+
+#ifdef HAVE_TSC_CLOCK
+#include "TSCClock.hh"
+#endif
+#ifdef HAVE_POSIX_CLOCK
+#include "PosixClock.hh"
+#endif
+#ifdef HAVE_GETTIMEOFDAY
+#include "GettimeofdayClock.hh"
+#endif
+
+#ifdef HAVE_WIN_CLOCK
+#include "WinClock.hh"
+#include "WinPerfClock.hh"
+#endif
+
+namespace libhla {
+namespace clock {
+
+ Clock * Clock::getBestClock () {
+#ifdef _WIN32
+#ifdef HAVE_WIN_CLOCK
+ return new WinPerfClock ( ) ;
+#else
+ return new WinClock() ;
+#endif
+#else
+#ifdef HAVE_TSC_CLOCK
+ return new TSCClock () ;
+#else
+
+#ifdef HAVE_POSIX_CLOCK
+ return new PosixClock () ;
+
+#else
+#ifdef HAVE_GETTIMEOFDAY
+ return new GettimeofdayClock () ;
+#else
+ return NULL ;
+#endif
+#endif
+#endif
+#endif
+ } /* end of getBestClock */
+
+} /* end namespace clock */
+} /* end namespace libhla */
Index: libHLA/PosixClock.hh
===================================================================
RCS file: libHLA/PosixClock.hh
diff -N libHLA/PosixClock.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libHLA/PosixClock.hh 21 Mar 2010 17:10:10 -0000 1.1
@@ -0,0 +1,52 @@
+#ifndef POSIXCLOCK_HH_
+#define POSIXCLOCK_HH_
+
+#include "Clock.hh"
+#include <time.h>
+
+namespace libhla {
+namespace clock {
+
+/**
+ * A Clock implemented using POSIX clock_xxxxx API.
+ */
+class HLA_EXPORT PosixClock : public Clock
+{
+public:
+ /**
+ * Build a POSIX clock using clock id.
+ * @param[in] clockId the POSIX clock identifier which may be
+ * - CLOCK_REALTIME (default value)
+ * - CLOCK_MONOTONIC
+ * - CLOCK_PROCESS_CPUTIME_ID
+ * - CLOCK_THREAD_CPUTIME_ID
+ * - CLOCK_REALTIME_HR
+ * - CLOCK_MONOTONIC_HR
+ */
+ PosixClock(clockid_t newClockId=CLOCK_REALTIME);
+ /**
+ * Get the clock resolution in nano-seconds.
+ * @return the clock resolution in nano-seconds
+ */
+ virtual double getResolution();
+ /**
+ * Get the current ticks value.
+ * @return the current ticks value
+ */
+ virtual uint64_t getCurrentTicksValue();
+ /**
+ * Convert a number of ticks into a double value
+ * representing nanoseconds.
+ * @param[in] ticks the number of tick to convert
+ * @return the nano-seconds value
+ */
+ virtual double tick2NanoSecond(const uint64_t ticks);
+ virtual ~PosixClock();
+private:
+ struct timespec resolution;
+ clockid_t clockId;
+};
+
+} /* end namespace clock */
+} /* end namespace libhla */
+#endif /*POSIXCLOCK_HH_*/
Index: libHLA/WinClock.cc
===================================================================
RCS file: libHLA/WinClock.cc
diff -N libHLA/WinClock.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libHLA/WinClock.cc 21 Mar 2010 17:10:10 -0000 1.1
@@ -0,0 +1,33 @@
+#include "WinClock.hh"
+#include <iostream>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+namespace certi {
+
+WinClock::WinClock() : Clock("WinClock")
+{
+ resolution = 1.0e9 / CLOCKS_PER_SEC ;
+}
+
+double WinClock::getResolution()
+{
+ return resolution;
+}
+
+uint64_t WinClock::getCurrentTicksValue()
+{
+ return static_cast<uint64_t>(clock());
+}
+
+double WinClock::tick2NanoSecond(const uint64_t ticks)
+{
+return resolution*ticks;
+}
+
+WinClock::~WinClock()
+{
+}
+
+}
Index: libHLA/WinPerfClock.hh
===================================================================
RCS file: libHLA/WinPerfClock.hh
diff -N libHLA/WinPerfClock.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libHLA/WinPerfClock.hh 21 Mar 2010 17:10:10 -0000 1.1
@@ -0,0 +1,45 @@
+#ifndef WinPerfClock_HH_
+#define WinPerfClock_HH_
+
+#include "Clock.hh"
+
+namespace libhla {
+namespace clock {
+
+}
+/**
+ */
+class HLA_EXPORT WinPerfClock : public Clock
+{
+public:
+ WinPerfClock();
+ /**
+ * Get the clock resolution in nano-seconds.
+ * @return the clock resolution in nano-seconds
+ */
+ virtual double getResolution();
+ /**
+ * Get the current ticks value.
+ * @return the current ticks value
+ */
+ virtual uint64_t getCurrentTicksValue();
+ /**
+ * Convert a number of ticks into a double value
+ * representing nanoseconds.
+ * @param[in] ticks the number of tick to convert
+ * @return the nano-seconds value
+ */
+ virtual double tick2NanoSecond(const uint64_t ticks);
+ virtual ~WinPerfClock();
+
+private:
+ /**
+ * The WinPerfClock resolution in nano-seconds
+ */
+ double resolution;
+
+};
+
+} /* end namespace clock */
+} /* end namespace libhla */
+#endif /*WinPerfClock_HH_*/
Index: libHLA/PosixClock.cc
===================================================================
RCS file: libHLA/PosixClock.cc
diff -N libHLA/PosixClock.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libHLA/PosixClock.cc 21 Mar 2010 17:10:10 -0000 1.1
@@ -0,0 +1,36 @@
+#include "PosixClock.hh"
+
+#include <stdlib.h>
+
+namespace libhla {
+namespace clock {
+
+PosixClock::PosixClock(clockid_t newClockId) : Clock("PosixClock")
+{
+ clockId = newClockId;
+ clock_getres(newClockId, &resolution);
+}
+
+double
+PosixClock::getResolution() {
+ return resolution.tv_sec*1e9 + resolution.tv_nsec;
+}
+
+uint64_t PosixClock::getCurrentTicksValue() {
+ struct timespec current;
+ /* convert struct timespec to number of nano-second */
+ clock_gettime(clockId, ¤t);
+ return current.tv_sec*1000000000 + current.tv_nsec;
+}
+
+double
+PosixClock::tick2NanoSecond(const uint64_t ticks) {
+ return ticks;
+}
+
+PosixClock::~PosixClock()
+{
+}
+
+} /* end namespace clock */
+} /* end namespace libhla */
Index: libHLA/GettimeofdayClock.hh
===================================================================
RCS file: libHLA/GettimeofdayClock.hh
diff -N libHLA/GettimeofdayClock.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libHLA/GettimeofdayClock.hh 21 Mar 2010 17:10:10 -0000 1.1
@@ -0,0 +1,67 @@
+// ----------------------------------------------------------------------------
+// CERTI - HLA RunTime Infrastructure
+// Copyright (C) 2002-2005 ONERA
+// Copyright (C) 2009 Mathias Froehlich
+//
+// This file is part of CERTI-libCERTI
+//
+// CERTI-libCERTI is free software ; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public License
+// as published by the Free Software Foundation ; either version 2 of
+// the License, or (at your option) any later version.
+//
+// CERTI-libCERTI is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY ; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program ; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA
+//
+// $Id: GettimeofdayClock.hh,v 1.1 2010/03/21 17:10:10 erk Exp $
+// ----------------------------------------------------------------------------
+
+#ifndef CERTI_GETTIMEOFDAYCLOCK_HH_
+#define CERTI_GETTIMEOFDAYCLOCK_HH_
+
+#include "Clock.hh"
+#include <time.h>
+
+namespace libhla {
+namespace clock {
+
+/**
+ * A Clock implemented using gettimeofday.
+ */
+class HLA_EXPORT GettimeofdayClock : public Clock
+{
+public:
+ /**
+ * Build a UNIX clock.
+ */
+ GettimeofdayClock();
+ /**
+ * Get the clock resolution in nano-seconds.
+ * @return the clock resolution in nano-seconds
+ */
+ virtual double getResolution();
+ /**
+ * Get the current ticks value.
+ * @return the current ticks value
+ */
+ virtual uint64_t getCurrentTicksValue();
+ /**
+ * Convert a number of ticks into a double value
+ * representing nanoseconds.
+ * @param[in] ticks the number of tick to convert
+ * @return the nano-seconds value
+ */
+ virtual double tick2NanoSecond(const uint64_t ticks);
+ virtual ~GettimeofdayClock();
+};
+
+} /* end of clock namespace */
+} /* and of libhla namespace */
+#endif /*CERTI_GETTIMEOFDAYCLOCK_HH_*/
Index: libHLA/WinPerfClock.cc
===================================================================
RCS file: libHLA/WinPerfClock.cc
diff -N libHLA/WinPerfClock.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libHLA/WinPerfClock.cc 21 Mar 2010 17:10:10 -0000 1.1
@@ -0,0 +1,38 @@
+#include "WinPerfClock.hh"
+#include <windows.h>
+
+namespace libhla {
+namespace clock {
+
+WinPerfClock::WinPerfClock() : Clock("WinPerfClock")
+{
+LARGE_INTEGER freq;
+if (QueryPerformanceFrequency(&freq))
+ {
+ resolution = 1.0e9 / static_cast<double>(freq.QuadPart);
+ }
+else resolution = 0.0 ;
+}
+
+double WinPerfClock::getResolution()
+{
+return resolution;
+}
+
+uint64_t WinPerfClock::getCurrentTicksValue()
+{
+ LARGE_INTEGER tick;
+ QueryPerformanceCounter(&tick);
+ return static_cast<uint64_t>(tick.QuadPart);
+}
+
+double WinPerfClock::tick2NanoSecond(const uint64_t ticks)
+{
+return resolution*ticks;
+}
+
+WinPerfClock::~WinPerfClock()
+{
+}
+} /* end namespace clock */
+} /* end namespace libhla */
Index: libHLA/TSCClock.hh
===================================================================
RCS file: libHLA/TSCClock.hh
diff -N libHLA/TSCClock.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libHLA/TSCClock.hh 21 Mar 2010 17:10:10 -0000 1.1
@@ -0,0 +1,67 @@
+#ifndef TSCCLOCK_HH_
+#define TSCCLOCK_HH_
+
+#include "Clock.hh"
+
+namespace libhla {
+namespace clock {
+/**
+ * The TSCClock is a Clock using the Time Stamp Counter
+ * which may be found in Pentium-like processors
+ * http://en.wikipedia.org/wiki/Time_Stamp_Counter
+ * Note that using TSC on a symmetric (or multi-core)
+ * multi-processor system may gives unexpected results
+ * moreover TSC behavior may be biaised if processor
+ * supports dynamic frequency scaling such as Pentium M
+ * used on mobile device.
+ * If you want a more "robust" Clock class you may use PosixClock.
+ */
+class HLA_EXPORT TSCClock : public Clock
+{
+public:
+ TSCClock();
+ /**
+ * Get the clock resolution in nano-seconds.
+ * @return the clock resolution in nano-seconds
+ */
+ virtual double getResolution();
+ /**
+ * Get the current ticks value.
+ * @return the current ticks value
+ */
+ virtual uint64_t getCurrentTicksValue();
+ /**
+ * Convert a number of ticks into a double value
+ * representing nanoseconds.
+ * @param[in] ticks the number of tick to convert
+ * @return the nano-seconds value
+ */
+ virtual double tick2NanoSecond(const uint64_t ticks);
+ virtual ~TSCClock();
+private:
+ /**
+ * Get processor frequency
+ * @return the processor frequency in MHz
+ */
+ static double getProcessorFrequency();
+
+ /**
+ * Read the Time Stamp Counter using
+ * rdtsc assembly instruction
+ */
+ inline uint64_t readTSC() {
+ uint64_t tsc;
+ __asm__ __volatile__("rdtsc" : "=A" (tsc));
+ return tsc;
+ };
+
+ /**
+ * The TSC clock resolution in nano-seconds
+ */
+ double resolution;
+
+};
+
+} /* end namespace clock */
+} /* end namespace libhla */
+#endif /*TSCCLOCK_HH_*/
Index: libHLA/TSCClock.cc
===================================================================
RCS file: libHLA/TSCClock.cc
diff -N libHLA/TSCClock.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libHLA/TSCClock.cc 21 Mar 2010 17:10:10 -0000 1.1
@@ -0,0 +1,52 @@
+#include "TSCClock.hh"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+namespace libhla {
+namespace clock {
+
+TSCClock::TSCClock() : Clock("TSCClock")
+{
+ resolution = 1.0e3/getProcessorFrequency();
+}
+
+double
+TSCClock::getResolution() {
+ return resolution;
+}
+
+uint64_t
+TSCClock::getCurrentTicksValue() {
+ return readTSC();
+}
+
+double
+TSCClock::tick2NanoSecond(const uint64_t ticks) {
+ return resolution*ticks;
+}
+
+TSCClock::~TSCClock()
+{
+}
+
+double TSCClock::getProcessorFrequency() {
+ FILE* fdcpu;
+ char left[256], right[256];
+ double freq = -1.0;
+
+ fdcpu = fopen("/proc/cpuinfo","r");
+
+ while (EOF != fscanf(fdcpu,"%s : %s \n",left,right) ) {
+
+ if (strstr(left,"MHz")) {
+ freq=atof(right);
+ break;
+ }
+ }
+ fclose(fdcpu);
+ return freq;
+}
+
+} /* end namespace clock */
+} /* end namespace libhla */
Index: libHLA/GettimeofdayClock.cc
===================================================================
RCS file: libHLA/GettimeofdayClock.cc
diff -N libHLA/GettimeofdayClock.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libHLA/GettimeofdayClock.cc 21 Mar 2010 17:10:10 -0000 1.1
@@ -0,0 +1,61 @@
+// ----------------------------------------------------------------------------
+// CERTI - HLA RunTime Infrastructure
+// Copyright (C) 2002-2005 ONERA
+// Copyright (C) 2009 Mathias Froehlich
+//
+// This file is part of CERTI-libCERTI
+//
+// CERTI-libCERTI is free software ; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public License
+// as published by the Free Software Foundation ; either version 2 of
+// the License, or (at your option) any later version.
+//
+// CERTI-libCERTI is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY ; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program ; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA
+//
+// $Id: GettimeofdayClock.cc,v 1.1 2010/03/21 17:10:10 erk Exp $
+// ----------------------------------------------------------------------------
+
+#include "GettimeofdayClock.hh"
+
+#include <sys/time.h>
+#include <iostream>
+
+namespace libhla {
+namespace clock {
+
+GettimeofdayClock::GettimeofdayClock() : Clock("GettimeofdayClock")
+{
+}
+
+double
+GettimeofdayClock::getResolution() {
+ return 1000;
+}
+
+uint64_t GettimeofdayClock::getCurrentTicksValue() {
+ struct timeval tv;
+ if (-1 == gettimeofday(&tv, 0))
+ std::cerr << "Cannot get current timestamp!" << std::endl;
+ /* convert struct timespec to number of micro-seconds */
+ return tv.tv_sec*1000000 + tv.tv_usec;
+}
+
+double
+GettimeofdayClock::tick2NanoSecond(const uint64_t ticks) {
+ return 1e3*ticks;
+}
+
+GettimeofdayClock::~GettimeofdayClock()
+{
+}
+
+} /* end of clock namespace */
+} /* and of libhla namespace */
Index: libHLA/Clock.hh
===================================================================
RCS file: libHLA/Clock.hh
diff -N libHLA/Clock.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libHLA/Clock.hh 21 Mar 2010 17:10:10 -0000 1.1
@@ -0,0 +1,105 @@
+// ----------------------------------------------------------------------------
+// CERTI - HLA RunTime Infrastructure
+// Copyright (C) 2002-2005 ONERA
+//
+// This program is free software ; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public License
+// as published by the Free Software Foundation ; either version 2 of
+// the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY ; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this program ; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// ----------------------------------------------------------------------------
+
+#ifndef CLOCK_HH_
+#define CLOCK_HH_
+
+#include <string>
+#include "libhla.hh"
+
+namespace libhla {
+namespace clock {
+
+/**
+ * An abstract Clock class.
+ * Clock abstraction which tries to use high-resolution
+ * system clock in order to be able to help user to
+ * profile it's application using simple clock API.
+ * Derived class will use effective clock API like
+ * POSIX clock_xxxx functions:
+ * http://www.opengroup.org/onlinepubs/000095399/functions/clock_getres.html
+ * or other hardware assisted clock like Pentium TSC.
+ */
+class HLA_EXPORT Clock
+{
+public:
+ /**
+ * The Clock default constructor.
+ * @param[in] newName the clock name
+ */
+ Clock(const std::string& newName);
+ /**
+ * Get the clock name.
+ * @return the clock name
+ */
+ const std::string& getName() const {return name;};
+ /**
+ * Get the clock resolution in nano-seconds.
+ * @return the clock resolution in nano-seconds
+ */
+ virtual double getResolution() = 0;
+ /**
+ * Get the current ticks value.
+ * @return the current ticks value
+ */
+ virtual uint64_t getCurrentTicksValue() = 0;
+ /**
+ * Get the delta between current ticks value and
+ * the one provided as argument.
+ * @param[in] previousTicks a previous ticks value
+ * @return the delta tick value
+ */
+ virtual uint64_t getDeltaTicks(const uint64_t previousTicks);
+ /**
+ * Convert a number of ticks into a double value
+ * representing nanoseconds.
+ * @param[in] ticks the number of tick to convert
+ * @return the nano-seconds value
+ */
+ virtual double tick2NanoSecond(const uint64_t ticks) = 0;
+ /**
+ * Get delta between the provided ticks values in nano-seconds.
+ * @param[in] firstTicks the first tick value
+ * @param[in] secondTicks the second (later) tick value
+ * @return the delta time between the two ticks value in nano-seconds.
+ */
+ virtual double getDeltaNanoSecond(const uint64_t firstTicks, const
uint64_t secondTicks);
+
+ /**
+ * Get delta between current ticks value and
+ * the one provided as argument as nano-second value
+ * @param[in] previousTicks
+ */
+ virtual double getDeltaNanoSecond(const uint64_t previousTicks);
+
+ virtual ~Clock();
+
+ /**
+ * Retrieve the best possible clock.
+ * @return the obtained clock
+ */
+ static Clock* getBestClock ();
+protected:
+ std::string name;
+};
+
+} /* end namespace clock */
+} /* end namespace libhla */
+
+#endif /*CLOCK_HH_*/
Index: libCERTI/TSCClock.cc
===================================================================
RCS file: libCERTI/TSCClock.cc
diff -N libCERTI/TSCClock.cc
--- libCERTI/TSCClock.cc 27 Jun 2008 08:22:11 -0000 4.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,50 +0,0 @@
-#include "TSCClock.hh"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-namespace certi {
-
-TSCClock::TSCClock() : Clock("TSCClock")
-{
- resolution = 1.0e3/getProcessorFrequency();
-}
-
-double
-TSCClock::getResolution() {
- return resolution;
-}
-
-uint64_t
-TSCClock::getCurrentTicksValue() {
- return readTSC();
-}
-
-double
-TSCClock::tick2NanoSecond(const uint64_t ticks) {
- return resolution*ticks;
-}
-
-TSCClock::~TSCClock()
-{
-}
-
-double TSCClock::getProcessorFrequency() {
- FILE* fdcpu;
- char left[256], right[256];
- double freq = -1.0;
-
- fdcpu = fopen("/proc/cpuinfo","r");
-
- while (EOF != fscanf(fdcpu,"%s : %s \n",left,right) ) {
-
- if (strstr(left,"MHz")) {
- freq=atof(right);
- break;
- }
- }
- fclose(fdcpu);
- return freq;
-}
-
-}
Index: libCERTI/WinPerfClock.hh
===================================================================
RCS file: libCERTI/WinPerfClock.hh
diff -N libCERTI/WinPerfClock.hh
--- libCERTI/WinPerfClock.hh 10 Oct 2008 11:29:07 -0000 4.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,40 +0,0 @@
-#ifndef WinPerfClock_HH_
-#define WinPerfClock_HH_
-
-#include "Clock.hh"
-
-namespace certi {
-/**
- */
-class CERTI_EXPORT WinPerfClock : public Clock
-{
-public:
- WinPerfClock();
- /**
- * Get the clock resolution in nano-seconds.
- * @return the clock resolution in nano-seconds
- */
- virtual double getResolution();
- /**
- * Get the current ticks value.
- * @return the current ticks value
- */
- virtual uint64_t getCurrentTicksValue();
- /**
- * Convert a number of ticks into a double value
- * representing nanoseconds.
- * @param[in] ticks the number of tick to convert
- * @return the nano-seconds value
- */
- virtual double tick2NanoSecond(const uint64_t ticks);
- virtual ~WinPerfClock();
-
-private:
- /**
- * The WinPerfClock resolution in nano-seconds
- */
- double resolution;
-
-};
-}
-#endif /*WinPerfClock_HH_*/
Index: libCERTI/TSCClock.hh
===================================================================
RCS file: libCERTI/TSCClock.hh
diff -N libCERTI/TSCClock.hh
--- libCERTI/TSCClock.hh 9 Oct 2008 20:22:38 -0000 4.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,64 +0,0 @@
-#ifndef TSCCLOCK_HH_
-#define TSCCLOCK_HH_
-
-#include "Clock.hh"
-
-namespace certi {
-/**
- * The TSCClock is a Clock using the Time Stamp Counter
- * which may be found in Pentium-like processors
- * http://en.wikipedia.org/wiki/Time_Stamp_Counter
- * Note that using TSC on a symmetric (or multi-core)
- * multi-processor system may gives unexpected results
- * moreover TSC behavior may be biaised if processor
- * supports dynamic frequency scaling such as Pentium M
- * used on mobile device.
- * If you want a more "robust" Clock class you may use PosixClock.
- */
-class CERTI_EXPORT TSCClock : public Clock
-{
-public:
- TSCClock();
- /**
- * Get the clock resolution in nano-seconds.
- * @return the clock resolution in nano-seconds
- */
- virtual double getResolution();
- /**
- * Get the current ticks value.
- * @return the current ticks value
- */
- virtual uint64_t getCurrentTicksValue();
- /**
- * Convert a number of ticks into a double value
- * representing nanoseconds.
- * @param[in] ticks the number of tick to convert
- * @return the nano-seconds value
- */
- virtual double tick2NanoSecond(const uint64_t ticks);
- virtual ~TSCClock();
-private:
- /**
- * Get processor frequency
- * @return the processor frequency in MHz
- */
- static double getProcessorFrequency();
-
- /**
- * Read the Time Stamp Counter using
- * rdtsc assembly instruction
- */
- inline uint64_t readTSC() {
- uint64_t tsc;
- __asm__ __volatile__("rdtsc" : "=A" (tsc));
- return tsc;
- };
-
- /**
- * The TSC clock resolution in nano-seconds
- */
- double resolution;
-
-};
-}
-#endif /*TSCCLOCK_HH_*/
Index: libCERTI/PosixClock.hh
===================================================================
RCS file: libCERTI/PosixClock.hh
diff -N libCERTI/PosixClock.hh
--- libCERTI/PosixClock.hh 9 Oct 2008 20:22:38 -0000 4.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,50 +0,0 @@
-#ifndef POSIXCLOCK_HH_
-#define POSIXCLOCK_HH_
-
-#include "Clock.hh"
-#include <time.h>
-
-namespace certi {
-
-/**
- * A Clock implemented using POSIX clock_xxxxx API.
- */
-class CERTI_EXPORT PosixClock : public Clock
-{
-public:
- /**
- * Build a POSIX clock using clock id.
- * @param[in] clockId the POSIX clock identifier which may be
- * - CLOCK_REALTIME (default value)
- * - CLOCK_MONOTONIC
- * - CLOCK_PROCESS_CPUTIME_ID
- * - CLOCK_THREAD_CPUTIME_ID
- * - CLOCK_REALTIME_HR
- * - CLOCK_MONOTONIC_HR
- */
- PosixClock(clockid_t newClockId=CLOCK_REALTIME);
- /**
- * Get the clock resolution in nano-seconds.
- * @return the clock resolution in nano-seconds
- */
- virtual double getResolution();
- /**
- * Get the current ticks value.
- * @return the current ticks value
- */
- virtual uint64_t getCurrentTicksValue();
- /**
- * Convert a number of ticks into a double value
- * representing nanoseconds.
- * @param[in] ticks the number of tick to convert
- * @return the nano-seconds value
- */
- virtual double tick2NanoSecond(const uint64_t ticks);
- virtual ~PosixClock();
-private:
- struct timespec resolution;
- clockid_t clockId;
-};
-
-}
-#endif /*POSIXCLOCK_HH_*/
Index: libCERTI/WinClock.hh
===================================================================
RCS file: libCERTI/WinClock.hh
diff -N libCERTI/WinClock.hh
--- libCERTI/WinClock.hh 10 Oct 2008 07:34:54 -0000 4.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,40 +0,0 @@
-#ifndef WinClock_HH_
-#define WinClock_HH_
-
-#include "Clock.hh"
-
-namespace certi {
-/**
- */
-class CERTI_EXPORT WinClock : public Clock
-{
-public:
- WinClock();
- /**
- * Get the clock resolution in nano-seconds.
- * @return the clock resolution in nano-seconds
- */
- virtual double getResolution();
- /**
- * Get the current ticks value.
- * @return the current ticks value
- */
- virtual uint64_t getCurrentTicksValue();
- /**
- * Convert a number of ticks into a double value
- * representing nanoseconds.
- * @param[in] ticks the number of tick to convert
- * @return the nano-seconds value
- */
- virtual double tick2NanoSecond(const uint64_t ticks);
- virtual ~WinClock();
-
-private:
- /**
- * The WinClock resolution in nano-seconds
- */
- double resolution;
-
-};
-}
-#endif /*WinClock_HH_*/
Index: libCERTI/GettimeofdayClock.hh
===================================================================
RCS file: libCERTI/GettimeofdayClock.hh
diff -N libCERTI/GettimeofdayClock.hh
--- libCERTI/GettimeofdayClock.hh 16 Oct 2009 21:34:24 -0000 4.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,65 +0,0 @@
-// ----------------------------------------------------------------------------
-// CERTI - HLA RunTime Infrastructure
-// Copyright (C) 2002-2005 ONERA
-// Copyright (C) 2009 Mathias Froehlich
-//
-// This file is part of CERTI-libCERTI
-//
-// CERTI-libCERTI is free software ; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public License
-// as published by the Free Software Foundation ; either version 2 of
-// the License, or (at your option) any later version.
-//
-// CERTI-libCERTI is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY ; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this program ; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA
-//
-// $Id: GettimeofdayClock.hh,v 4.1 2009/10/16 21:34:24 erk Exp $
-// ----------------------------------------------------------------------------
-
-#ifndef CERTI_GETTIMEOFDAYCLOCK_HH_
-#define CERTI_GETTIMEOFDAYCLOCK_HH_
-
-#include "Clock.hh"
-#include <time.h>
-
-namespace certi {
-
-/**
- * A Clock implemented using gettimeofday.
- */
-class CERTI_EXPORT GettimeofdayClock : public Clock
-{
-public:
- /**
- * Build a UNIX clock.
- */
- GettimeofdayClock();
- /**
- * Get the clock resolution in nano-seconds.
- * @return the clock resolution in nano-seconds
- */
- virtual double getResolution();
- /**
- * Get the current ticks value.
- * @return the current ticks value
- */
- virtual uint64_t getCurrentTicksValue();
- /**
- * Convert a number of ticks into a double value
- * representing nanoseconds.
- * @param[in] ticks the number of tick to convert
- * @return the nano-seconds value
- */
- virtual double tick2NanoSecond(const uint64_t ticks);
- virtual ~GettimeofdayClock();
-};
-
-}
-#endif /*POSIXCLOCK_HH_*/
Index: libCERTI/WinClock.cc
===================================================================
RCS file: libCERTI/WinClock.cc
diff -N libCERTI/WinClock.cc
--- libCERTI/WinClock.cc 10 Oct 2008 11:29:06 -0000 4.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,33 +0,0 @@
-#include "WinClock.hh"
-#include <iostream>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-
-namespace certi {
-
-WinClock::WinClock() : Clock("WinClock")
-{
- resolution = 1.0e9 / CLOCKS_PER_SEC ;
-}
-
-double WinClock::getResolution()
-{
- return resolution;
-}
-
-uint64_t WinClock::getCurrentTicksValue()
-{
- return static_cast<uint64_t>(clock());
-}
-
-double WinClock::tick2NanoSecond(const uint64_t ticks)
-{
-return resolution*ticks;
-}
-
-WinClock::~WinClock()
-{
-}
-
-}
Index: libCERTI/Clock.cc
===================================================================
RCS file: libCERTI/Clock.cc
diff -N libCERTI/Clock.cc
--- libCERTI/Clock.cc 19 Nov 2009 18:15:32 -0000 4.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,47 +0,0 @@
-// ----------------------------------------------------------------------------
-// CERTI - HLA RunTime Infrastructure
-// Copyright (C) 2002-2005 ONERA
-//
-// This program is free software ; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public License
-// as published by the Free Software Foundation ; either version 2 of
-// the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY ; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this program ; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-// ----------------------------------------------------------------------------
-
-#include "Clock.hh"
-namespace certi {
-
-Clock::Clock(const std::string& newName)
-{
- name = newName;
-}
-
-uint64_t
-Clock::getDeltaTicks(const uint64_t previousTicks) {
- return (getCurrentTicksValue()-previousTicks);
-}
-
-double Clock::getDeltaNanoSecond(const uint64_t firstTicks, const uint64_t
secondTicks) {
- return tick2NanoSecond(secondTicks-firstTicks);
-}
-
-double
-Clock::getDeltaNanoSecond(const uint64_t previousTicks) {
- return tick2NanoSecond(getDeltaTicks(previousTicks));
-}
-
-
-Clock::~Clock()
-{
-}
-
-}
Index: libCERTI/GettimeofdayClock.cc
===================================================================
RCS file: libCERTI/GettimeofdayClock.cc
diff -N libCERTI/GettimeofdayClock.cc
--- libCERTI/GettimeofdayClock.cc 16 Oct 2009 21:34:24 -0000 4.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,60 +0,0 @@
-// ----------------------------------------------------------------------------
-// CERTI - HLA RunTime Infrastructure
-// Copyright (C) 2002-2005 ONERA
-// Copyright (C) 2009 Mathias Froehlich
-//
-// This file is part of CERTI-libCERTI
-//
-// CERTI-libCERTI is free software ; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public License
-// as published by the Free Software Foundation ; either version 2 of
-// the License, or (at your option) any later version.
-//
-// CERTI-libCERTI is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY ; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this program ; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA
-//
-// $Id: GettimeofdayClock.cc,v 4.1 2009/10/16 21:34:24 erk Exp $
-// ----------------------------------------------------------------------------
-
-#include "GettimeofdayClock.hh"
-
-#include <sys/time.h>
-
-#include "Exception.hh"
-
-namespace certi {
-
-GettimeofdayClock::GettimeofdayClock() : Clock("GettimeofdayClock")
-{
-}
-
-double
-GettimeofdayClock::getResolution() {
- return 1000;
-}
-
-uint64_t GettimeofdayClock::getCurrentTicksValue() {
- struct timeval tv;
- if (-1 == gettimeofday(&tv, 0))
- throw RTIinternalError("Cannot get current timestamp!");
- /* convert struct timespec to number of micro-seconds */
- return tv.tv_sec*1000000 + tv.tv_usec;
-}
-
-double
-GettimeofdayClock::tick2NanoSecond(const uint64_t ticks) {
- return 1e3*ticks;
-}
-
-GettimeofdayClock::~GettimeofdayClock()
-{
-}
-
-}
Index: libCERTI/Clock.hh
===================================================================
RCS file: libCERTI/Clock.hh
diff -N libCERTI/Clock.hh
--- libCERTI/Clock.hh 19 Nov 2009 18:15:32 -0000 4.10
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,105 +0,0 @@
-// ----------------------------------------------------------------------------
-// CERTI - HLA RunTime Infrastructure
-// Copyright (C) 2002-2005 ONERA
-//
-// This program is free software ; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public License
-// as published by the Free Software Foundation ; either version 2 of
-// the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY ; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this program ; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-// ----------------------------------------------------------------------------
-
-#ifndef CLOCK_HH_
-#define CLOCK_HH_
-
-
-
-#include <string>
-#include "certi.hh"
-
-namespace certi {
-
-/**
- * An abstract Clock class.
- * Clock abstraction which tries to use high-resolution
- * system clock in order to be able to help user to
- * profile it's application using simple clock API.
- * Derived class will use effective clock API like
- * POSIX clock_xxxx functions:
- * http://www.opengroup.org/onlinepubs/000095399/functions/clock_getres.html
- * or other hardware assisted clock like Pentium TSC.
- */
-class CERTI_EXPORT Clock
-{
-public:
- /**
- * The Clock default constructor.
- * @param[in] newName the clock name
- */
- Clock(const std::string& newName);
- /**
- * Get the clock name.
- * @return the clock name
- */
- const std::string& getName() const {return name;};
- /**
- * Get the clock resolution in nano-seconds.
- * @return the clock resolution in nano-seconds
- */
- virtual double getResolution() = 0;
- /**
- * Get the current ticks value.
- * @return the current ticks value
- */
- virtual uint64_t getCurrentTicksValue() = 0;
- /**
- * Get the delta between current ticks value and
- * the one provided as argument.
- * @param[in] previousTicks a previous ticks value
- * @return the delta tick value
- */
- virtual uint64_t getDeltaTicks(const uint64_t previousTicks);
- /**
- * Convert a number of ticks into a double value
- * representing nanoseconds.
- * @param[in] ticks the number of tick to convert
- * @return the nano-seconds value
- */
- virtual double tick2NanoSecond(const uint64_t ticks) = 0;
- /**
- * Get delta between the provided ticks values in nano-seconds.
- * @param[in] firstTicks the first tick value
- * @param[in] secondTicks the second (later) tick value
- * @return the delta time between the two ticks value in nano-seconds.
- */
- virtual double getDeltaNanoSecond(const uint64_t firstTicks, const
uint64_t secondTicks);
-
- /**
- * Get delta between current ticks value and
- * the one provided as argument as nano-second value
- * @param[in] previousTicks
- */
- virtual double getDeltaNanoSecond(const uint64_t previousTicks);
-
- virtual ~Clock();
-
- /**
- * Retrieve the best possible clock.
- * @return the obtained clock
- */
- static Clock* getBestClock ();
-protected:
- std::string name;
-};
-
-}
-
-#endif /*CLOCK_HH_*/
Index: libCERTI/ClockFactory.cc
===================================================================
RCS file: libCERTI/ClockFactory.cc
diff -N libCERTI/ClockFactory.cc
--- libCERTI/ClockFactory.cc 16 Oct 2009 21:34:24 -0000 4.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,65 +0,0 @@
-// ----------------------------------------------------------------------------
-// CERTI - HLA RunTime Infrastructure
-// Copyright (C) 2002-2005 ONERA
-//
-// This program is free software ; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public License
-// as published by the Free Software Foundation ; either version 2 of
-// the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY ; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this program ; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-// ----------------------------------------------------------------------------
-
-#include "config.h"
-#include "Clock.hh"
-
-#ifdef HAVE_TSC_CLOCK
-#include "TSCClock.hh"
-#endif
-#ifdef HAVE_POSIX_CLOCK
-#include "PosixClock.hh"
-#endif
-#ifdef HAVE_GETTIMEOFDAY
-#include "GettimeofdayClock.hh"
-#endif
-
-#ifdef HAVE_WIN_CLOCK
-#include "WinClock.hh"
-#include "WinPerfClock.hh"
-#endif
-
-namespace certi {
-
- Clock * Clock::getBestClock () {
-#ifdef _WIN32
-#ifdef HAVE_WIN_CLOCK
- return new WinPerfClock ( ) ;
-#else
- return new WinClock() ;
-#endif
-#else
-#ifdef HAVE_TSC_CLOCK
- return new TSCClock () ;
-#else
-
-#ifdef HAVE_POSIX_CLOCK
- return new PosixClock () ;
-
-#else
-#ifdef HAVE_GETTIMEOFDAY
- return new GettimeofdayClock () ;
-#else
- return NULL ;
-#endif
-#endif
-#endif
-#endif
- } /* end of getBestClock */
-}
Index: libCERTI/WinPerfClock.cc
===================================================================
RCS file: libCERTI/WinPerfClock.cc
diff -N libCERTI/WinPerfClock.cc
--- libCERTI/WinPerfClock.cc 24 Nov 2009 21:44:47 -0000 4.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,37 +0,0 @@
-#include "WinPerfClock.hh"
-#include <windows.h>
-
-namespace certi {
-
-WinPerfClock::WinPerfClock() : Clock("WinPerfClock")
-{
-LARGE_INTEGER freq;
-if (QueryPerformanceFrequency(&freq))
- {
- resolution = 1.0e9 / static_cast<double>(freq.QuadPart);
- }
-else resolution = 0.0 ;
-}
-
-double WinPerfClock::getResolution()
-{
-return resolution;
-}
-
-uint64_t WinPerfClock::getCurrentTicksValue()
-{
- LARGE_INTEGER tick;
- QueryPerformanceCounter(&tick);
- return static_cast<uint64_t>(tick.QuadPart);
-}
-
-double WinPerfClock::tick2NanoSecond(const uint64_t ticks)
-{
-return resolution*ticks;
-}
-
-WinPerfClock::~WinPerfClock()
-{
-}
-
-}
Index: libCERTI/PosixClock.cc
===================================================================
RCS file: libCERTI/PosixClock.cc
diff -N libCERTI/PosixClock.cc
--- libCERTI/PosixClock.cc 23 Jun 2008 13:25:05 -0000 4.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,34 +0,0 @@
-#include "PosixClock.hh"
-
-#include <stdlib.h>
-
-namespace certi {
-
-PosixClock::PosixClock(clockid_t newClockId) : Clock("PosixClock")
-{
- clockId = newClockId;
- clock_getres(newClockId, &resolution);
-}
-
-double
-PosixClock::getResolution() {
- return resolution.tv_sec*1e9 + resolution.tv_nsec;
-}
-
-uint64_t PosixClock::getCurrentTicksValue() {
- struct timespec current;
- /* convert struct timespec to number of nano-second */
- clock_gettime(clockId, ¤t);
- return current.tv_sec*1000000000 + current.tv_nsec;
-}
-
-double
-PosixClock::tick2NanoSecond(const uint64_t ticks) {
- return ticks;
-}
-
-PosixClock::~PosixClock()
-{
-}
-
-}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [certi-cvs] certi libHLA/sha1.h libHLA/HLAbuffer.hh libHLA/...,
certi-cvs <=