/* 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_USER_TIME_HPP_
#define _NMM_USER_TIME_HPP_

#include "nmm/nmm_prefix.hpp"

#include <iosfwd>

#include <nmm/nmm_types.hpp>

#include "visibility.hpp"

#undef min //for some reason under windows "min" is a macro!!
namespace NMM {
  
  class Interval;
  class Time;
  
  //! Provides an easily readable time format. 
  /*!
   * Time and Interval are used for internal computations referring 
   * to time. UserTime can be used to display those values.
   */
  class DLLEXPORT UserTime {
  public:
    nmm_int32 hour;       //!< The hours
    nmm_int32 min;        //!< The minutes
    nmm_int32 sec;        //!< The seconds
    nmm_int32 msec;       //!< The milliseconds

    //! The default constructor.
    UserTime() : hour(0), min(0), sec(0), msec(0) {};
    
    //! Creates a UserTime that has an equal value as a given Time.
    UserTime(const Time& time);
    
    //! Creates a UserTime that has an equal value as a given Interval.
    //! 
    //! @param interval that is copied 
    UserTime(const Interval& interval);
    
    //! Output UserTime to standard stream.
    /*!
     *  Outputs the formatted user time to a stream, optionally with seconds and
     *  microseconds.
     * 
     * @param stream that is used to write the the UserTime to. 
     * @param with_seconds if true seconds are also written to output stream
     * @param with_microseconds if true microseconds are also written to output stream
     */
    void output(std::ostream& stream, bool with_seconds = false, bool with_microseconds = false) const;
  };

  //! The output operator for UserTime.
  /*!
   *  This is equivalent to calling output(stream, true, true).
   * 
   * @param stream output stream that is used to write UserTime
   * @param time that is written to output stream
   * @return reference to output stream
   */
  DLLEXPORT std::ostream& operator<< (std::ostream& stream, const UserTime& time);
  
}

#include "nmm/nmm_suffix.hpp"

#endif // _NMM_USER_TIME_HPP_
