- Main Page
- Namespaces
- Classes
- Files
- Related Pages

# /Users/fpy/titan-1-5-MBARI/Mers/Interfaces/SystemTimeService.cpp

    00001
    00002 //
    00003 // Copyright (c) 2004           Model-based Embedded and Robotic Systems Group
    00004 // All Rights Reserved          Massachusetts Institute of Technology
    00005 //
    00006 // This software is provided as is. Model-based Embedded and Robotic Systems
    00007 // (MERS) group does not assume any responsibility.
    00008 //
    00009 // Organization:        Model-based Embedded and Robotic Systems Group
    00010 //                                      Massachusetts Institute of Technology
    00011 //
    00013
    00014 #include "SystemTimeService.h"
    00015
    00016 #ifdef _MSC_VER
    00017 // VC++ includes
    00018 #include <sys/types.h>
    00019 #include <sys/timeb.h>
    00020 #else
    00021 // gcc includes
    00022 #include <sys/time.h>
    00023 #endif
    00024
    00025 using namespace Mers::Interfaces;
    00026 using Mers::Utils::Lang::ReferencedObject;
    00027
    00029
    00030 double SystemTimeService::time()
    00031 {
    00032 #ifdef _MSC_VER
    00033         // VC++ time functions.
    00034         struct _timeb timeptr;
    00035         _ftime( &timeptr );
    00036         return timeptr.time + ((double) timeptr.millitm) / 1e3;
    00037 #else
    00038         // Assume gcc
    00039         struct timeval tv;
    00040         gettimeofday( &tv, NULL );
    00041         return tv.tv_sec + ((double) tv.tv_usec) / 1e6;
    00042 #endif
    00043
    00044 }
    00045
    00047