/*****************************************************************************
 * $LastChangedDate: 2011-04-23 21:07:07 -0400 (Sat, 23 Apr 2011) $
 * @file
 * @author  Jim E. Brooks  http://www.palomino3d.org
 * @brief   Top-level program.
 *//*
 * LEGAL:   COPYRIGHT (C) 2007 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
 *****************************************************************************/

#ifndef PROGRAM_PROGRAM_HH
#define PROGRAM_PROGRAM_HH 1

#define GET_PROGRAM() program::global::gProgram

#include <list>
#include "control/module.hh"
using namespace control;
#include "view/module.hh"
using namespace view;

namespace program {

////////////////////////////////////////////////////////////////////////////////
/// @brief The top-level of the program.
///
/// Control and Lua define the "current" Craft.
///
class Program
{
public:
                        Program( void );
                        ~Program();

// Program control:
    void                Run( int argc, char** argv );
    void                Reset( void );
    void                FlushSceneGraph( void );
    void                SetPause( bool pause_ );  // pause() is a syscall
    bool                IfPaused( void );

// Simulator's command queue:
    void                EnqueueCommand( const string& cmd );  // command queue
    string              DequeueCommand( void );

private:
    void                Tick( const Milliseconds millisecElapsed );
#if DEBUG
    void                SelfChecks( void );
#endif

private:
    /// @brief Timer-tick.
    ///
    CLASS_TICK_FUNCTOR_BASIC

// Data:
private:
    typedef std::list<string> CommandQueue;
    bool                    mPause;
    CommandQueue            mCommandQueue;
};

// Define global.
#if PROGRAM_MODULE_CC
namespace global { Program gProgram; }
#else
namespace global { extern Program gProgram; }
#endif

} // namespace program

#endif // PROGRAM_PROGRAM_HH
