/* 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_IControllerImpl_HPP
#define NMM_IControllerImpl_HPP

#include "nmm/nmm_prefix.hpp"

#include "nmm/comm/NMMObject.hpp"
#include "IController.hpp"


#include "visibility.hpp"

namespace NMM
{
  /** Method Call Delay Measurement.
   */

  class DLLEXPORT IPingImpl  : public virtual NMM::NMMObject { 
  public:
    IPingImpl() { addInterface(new IPing(*this)); registerEvents(); };

    virtual ~IPingImpl() {};

  protected:
    /** Measure the delay of a method call.
     * This method can be used to estimate the delay between method call and execution.
     * The clocks on the host which calls the method and the host which executes the method
     * must be synchronized.
     * @return the system time when the method call was executed
     */

    virtual Time ping() = 0;


  private:
    void registerEvents();
  };
  /** Interface of a synchronization controller.
   * This is the interface of a synchronization controller. A controllers is attached to a synchronized source
   * or sink and adds synchronization functionality. The controller performs all interface communication with
   * the synchronizer.
   */

  class DLLEXPORT IControllerImpl  : virtual public IPingImpl { 
  public:
    IControllerImpl() { addInterface(new IController(*this)); registerEvents(); };

    virtual ~IControllerImpl() {};

  protected:
    /** Set the controller mode.
     *
     * @param mode The controller mode
     */

    virtual Result setMode(const IController::Mode& mode) = 0;
    /** Enable or disable discarding of buffers.
     * If the controller is in @c ONLINE mode, this method controls whether the controller may discard buffers
     * which can not be presented in time. Enabled by default.
     *
     * @param enable @c true to enable, @c false to disable discarding of buffers
     */

    virtual Result permitDiscardBuffers(const nmm_bool& enable) = 0;
    /** Pause this controller.
     *
     * @return @c SUCCESS if the operation succeeded, @c FAILURE otherwise
     */

    virtual Result pause() = 0;
    /** Wake up this controller after pause.
     *
     * @return @c SUCCESS if the operation succeeded, @c FAILURE otherwise
     */

    virtual Result wakeup() = 0;
    /** Reset this controller.
     *
     * @return @c SUCCESS if the operation succeeded, @c FAILURE otherwise
     */

    virtual Result reset() = 0;
    /** Enable or disable invalidation of all buffers.
     * If invalidation of all buffers is enabled, then all buffers are flagged as invalid and are not presented.
     * Disabled by default.
     *
     * @param enable @c true to enable, @c false to disable invalidation of all buffers
     */

    virtual void setBuffersInvalid(const nmm_bool& enable) = 0;
    /** Enable or disable invalidation of all buffers after a specific timestamp.
     * If invalidation of all buffers is enabled, then all buffers are flagged as invalid and are not presented.
     * Disabled by default.
     * This method enables or disables invalidation of all buffers after a specific buffer timestamp.
     *
     * @param enable @c true to enable, @c false to disable invalidation of all buffers
     * @param timestamp Buffer timestamp which provides the @c sync_time after which the change becomes active
     */

    virtual void setBuffersInvalidTimed(const nmm_bool& enable, const Timestamp& timestamp) = 0;


  private:
    void registerEvents();
  };

}

#include "nmm/nmm_suffix.hpp"

#endif
