/* 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_ISeekable_HPP
#define NMM_ISeekable_HPP

#include "nmm/nmm_prefix.hpp"

#include "nmm/comm/Interface.hpp"
#include "nmm/comm/messaging/Event.hpp"
#include "nmm/comm/messaging/IllegalStateException.hpp"
#include <memory>

/* Network-Integrated Multimedia Middleware (NMM)
 * http://www.motama.com/nmm.html
 *
 * Copyright (C) 2006-2007
 * Motama GmbH, Saarbruecken, Germany
 * http://www.motama.com
 *
 * See file LICENCE for terms and conditions of usage
 *
 */

#include "nmm/utils/time/Rational.hpp"
#include "nmm/utils/time/Interval.hpp"

#include "visibility.hpp"

namespace NMM
{
  /** Interface contains methods to check and use seek mechanisms.
   */

  class DLLEXPORT ISeekable : virtual public NMM::Interface { 
  public:
    ISeekable() : NMM::Interface(ISeekable::ISeekable_type, "NMM") { };

    ISeekable(NMM::NMMObject& parent) : NMM::Interface (parent, ISeekable::ISeekable_type, "NMM") { };

    virtual ~ISeekable() {};

    static const char* ISeekable_type;

    virtual  string getInterfaceType() const { return ISeekable_type; }

    NMM::Interface* copy() const { return new ISeekable(*this); }
    static void used(); 
    static const char* hasPercentSeek_event;
    static const char* seekPercent_event;
    static const char* seekPercentTo_event;
    static const char* hasBytesSeek_event;
    static const char* seekBytes_event;
    static const char* seekBytesTo_event;
    static NMM::Event* create_seekBytesTo(const nmm_uint64& bytes);
    static const char* hasTimeSeek_event;
    static const char* seekTime_event;
    static const char* seekTimeTo_event;
    /** Tests if implementing object supports seeking by percent.
     *   
     * This method can be used to test if the implementing supports
     * seeking by percentage.
     *
     * @return true iff percantage seeking is supported.
     */

    virtual nmm_bool hasPercentSeek() const
      throw(const NMM::SerializedException&);
    /** Seeks relative from current positon by percent.
     *
     * This method seeks relative from the current position in
     * percent.
     *
     * @param percent The offset to seek in a Rational from -1 to 1.
     */

    virtual void seekPercent(const Rational& percent)
      throw(const NMM::SerializedException&);
    /** Seeks absolut to the given position in percent.
     *
     * This method seeks absolute to the given position in percent.
     *
     * @param percent The position to seek to in a Rational from 0 to 1.
     */

    virtual void seekPercentTo(const Rational& percent)
      throw(const NMM::SerializedException&);
    /** Tests if implementing object supports seeking by bytes.
     *
     * This method can be used to test if this interface supports
     * seeking by bytes.
     *
     * @return true iff bytewise seeking is supported.
     */

    virtual nmm_bool hasBytesSeek() const
      throw(const NMM::SerializedException&);
    /** Seeks relative from current position by bytes.
     *
     * This method seeks relative from the current position in
     * bytes.
     *
     * @param offset The offset to seek.
     */

    virtual void seekBytes(const nmm_int64& offset)
      throw(const NMM::SerializedException&);
  /* instream (protected) and non-instream (public) */        /** Seeks absolut to the given position in bytes.
     *
     * This method seeks absolute to the given position in percent.
     *
     * @param bytes The position to seek to.
     */

    virtual void seekBytesTo(const nmm_uint64& bytes) /* in-stream */ 
      throw(const NMM::SerializedException&);
  /* non-instream (public) */        /** Tests if implementing object supports seeking by time.
     *
     * This method can be used to test if this interface supports
     * seeking by Time.
     *
     * @return true iff seeking by Time is supported.
     */

    virtual nmm_bool hasTimeSeek() const
      throw(const NMM::SerializedException&);
    /** Seeks relative from current positon by time.
     *
     * This method seeks relative from the current position in
     * Time.
     *
     * @param interval The Interval to seek.
     */

    virtual void seekTime(const Interval& interval)
      throw(const NMM::SerializedException&);
    /** Seeks absolut to given position in time.
     *
     * This method seeks absolute to the given position in Time.
     *
     * @param time The Time to seek to.
     */

    virtual void seekTimeTo(const Time& time)
      throw(const NMM::SerializedException&);


  };

  typedef auto_ptr<ISeekable> ISeekable_var;




}

#include "nmm/nmm_suffix.hpp"

#endif
