Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef TRENDERERP_INCLUDE
Toshihiro Shimizu 890ddd
#define TRENDERERP_INCLUDE
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <qobject></qobject>
Toshihiro Shimizu 890ddd
#include <qmetatype></qmetatype>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "trenderer.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//! This is a private class used to convey the TRenderer::startRendering
Shinya Kitaoka 120a6e
//! methods into Qt queued slots. This is necessary since these methods
Shinya Kitaoka 120a6e
//! implicitly
Shinya Kitaoka 120a6e
//! perform event processing, which could cause trouble in case they are invoked
Shinya Kitaoka 120a6e
//! from
Toshihiro Shimizu 890ddd
//! events which must respect a strict ordering.
Toshihiro Shimizu 890ddd
//! \n \n
Toshihiro Shimizu 890ddd
//! For example, suppose that a render must be invoked upon a mousePressEvent,
Shinya Kitaoka 120a6e
//! and that such event must have been completely processed before the
Shinya Kitaoka 120a6e
//! corrispondant
Shinya Kitaoka 120a6e
//! mouseReleaseEvent is invoked - calling the startRendering method *directly*
Shinya Kitaoka 120a6e
//! by
Shinya Kitaoka 120a6e
//! the mousePressEvent may cause the mouseReleaseEvent to be processed before
Shinya Kitaoka 120a6e
//! the
Toshihiro Shimizu 890ddd
//! former's end.
Shinya Kitaoka d1f6c4
class TRendererStartInvoker final : public QObject {
Shinya Kitaoka 120a6e
  Q_OBJECT
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  struct StartInvokerRenderData {
Shinya Kitaoka 120a6e
    unsigned long m_renderId;
Shinya Kitaoka 120a6e
    const RenderDataVector *m_renderDataVector;
Shinya Kitaoka 120a6e
  };
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TRendererStartInvoker() {
Shinya Kitaoka 120a6e
    qRegisterMetaType<startinvokerrenderdata>("StartInvokerRenderData");</startinvokerrenderdata>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    connect(this, SIGNAL(startRender(TRendererImp *, StartInvokerRenderData)),
Shinya Kitaoka 120a6e
            this, SLOT(doStartRender(TRendererImp *, StartInvokerRenderData)),
Shinya Kitaoka 120a6e
            Qt::QueuedConnection);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  ~TRendererStartInvoker() {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  static TRendererStartInvoker *instance() {
Shinya Kitaoka 120a6e
    static TRendererStartInvoker theInstance;
Shinya Kitaoka 120a6e
    return &theInstance;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void emitStartRender(TRendererImp *renderer, StartInvokerRenderData rd);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
Q_SIGNALS:
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void startRender(TRendererImp *, StartInvokerRenderData);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public Q_SLOTS:
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void doStartRender(TRendererImp *, StartInvokerRenderData rd);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // TRENDERERP_INCLUDE