/* Network-Integrated Multimedia Middleware (NMM)
 * http://www.motama.com/nmm.html
 *  
 * Copyright (C) 2006-2007
 * Motama GmbH, Saarbruecken, Germany
 * http://www.motama.com
 *  
 * This file is part of NMM. 
 * 
 * NMM 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; only version 2 of the License.      
 * 
 * NMM 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 NMM; if not, write to the Free Software Foundation,    
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */


#ifndef _NMM_CLOCK_HPP_
#define _NMM_CLOCK_HPP_

#include "nmm/nmm_prefix.hpp"

#include "Time.hpp"

#include "nmm_timeval.hpp"

#include "visibility.hpp"

namespace NMM {

  //! This is a first and simple implementation of a media stream clock.
  /*!
   * A clock object keeps on counting the nanoseconds since the time of 
   * its creation. In the constructor, its initial clock value is set to
   * zero. This clock uses the system-clock to compute the time value.
   * You can query the time of the creation of a clock object by calling
   * the getSystemStartTime - method.
   */
  class DLLEXPORT Clock {

  private:

    struct timeval systime;         //! The system time at the moment.
    struct timeval systemstarttime; //! The system time at the time
                                    //! the clock is generated.
    struct timeval diff;            //! Internally used to compute the 
                                    //! difference between both values.

  public:

    //! The main constructor.
    /*! 
     * Returns a clock object with a time value of zero.
     */
    Clock();

    //! The main destructor.
    ~Clock();

    //! Returns the clock's time value.
    //! @return clock's time value.
    Time getTime();

    /*!
     * Returns the starttime of the clock referring to the internal system
     * clock.
     *
     * @return clock's start time
     */
    inline struct timeval getSystemStartTime() const {return systemstarttime;}
  };
}

#include "nmm/nmm_suffix.hpp"

#endif // _NMM_CLOCK_HPP_
