Basic Notes

  • A file is devided into several sections, each section can consist of several blocks.
  • Insert two empty lines between sections.
  • Insert one empty line between blocks.

Example/Template

#pragma once


#include <signalzeug/Signal.h>

#include <reflectionzeug/Object.h>
#include <reflectionzeug/Variant.h>

#include <globjects/Texture.h>

#include <gloperate/gloperate_api.h>


namespace glbinding {
    class Binding;
}

namespace globjects {
    class Texture;
    class Buffer;
}


namespace gloperate
{


class ViewerContext;
class Surface;
class Pipeline;


/**
*  @brief
*    Timer class for executing timed tasks
*/
class GLOPERATE_API Timer
{
public:
    enum Type
    {
        ContinuousTimer, ///< Fire at regular intervals
        RandomTimer      ///< Fire at random intervals
    };


public:
    signalzeug::Signal<> fired; ///< Called when the timer interval has elapsed


public:
    /**
    *  @brief
    *    Get global instance
    *
    *  @return
    *    Global timer instance (never null)
    */
    static Timer * instance();


public:
    /**
    *  @brief
    *    Constructor
    *
    *  @param[in] viewerContext
    *    Viewer context to which the surface belongs (must NOT be null!)
    */
    Timer(ViewerContext * viewerContext);

    /**
    *  @brief
    *    Destructor
    */
    virtual ~Timer();

    /**
    *  @brief
    *    Check if timer is currently active
    *
    *  @return
    *    'true' if timer is active, else 'false'
    */
    bool isActive() const;

    /**
    *  @brief
    *    Start timer
    *
    *  @param[in] interval
    *    Interval (in seconds, 0.0 for continuous update in each main loop iteration)
    *  @param[in] singleShot
    *    If 'true', the timer fires only once, otherwise it will be restarted continously
    */
    void start(float interval, bool singleShot = false);

    /**
    *  @brief
    *    Stop timer
    */
    void stop();

    /**
    *  @brief
    *    Get interval
    *
    *  @return
    *    Interval (in seconds)
    */
    float interval() const;

    /**
    *  @brief
    *    Get remaining time
    *
    *  @return
    *    Remaining time (in seconds)
    */
    float remainingTime() const;

    /**
    *  @brief
    *    Update timer
    *
    *  @param[in] delta
    *    Time delta (in seconds)
    */
    void update(float delta);


protected:
    /**
    *  @brief
    *    Called when the timer has been updated
    */
    virtual void onUpdate();


protected:
    ViewerContext * m_viewerContext; ///< Viewer context to which the timer belongs
    bool            m_active;        ///< 'true' if timer is active, else 'false'
    bool            m_singleShot;    ///< 'true' if timer fires only once, else 'false'
    float           m_interval;      ///< Interval (in seconds)
    float           m_remaining;     ///< Remaining time (in seconds)
};


} // namespace gloperate