1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
#pragma once
#include "glGrib/Shell.h"
#include "glGrib/Options.h"
#include <string>
#include <vector>
#include <map>
#include <list>
#include <functional>
#include <thread>
#include <mutex>
namespace glGrib
{
class ShellInterpreter : public Shell
{
public:
void setup (const OptionsShell &) override;
void start (class WindowSet *) override;
void run () override;
static ShellInterpreter & getInstance ()
{
if (shellinterp == nullptr)
shellinterp = new ShellInterpreter ();
return *shellinterp;
}
void runWset ();
void stop (const std::vector<std::string> &);
void start (int, const char * []);
void start (const std::vector<std::string> &);
void execute (const std::vector<std::string> &) override;
void lock () override { mutex.lock (); }
void unlock () override { mutex.unlock (); }
void wait () override { if (getWindowSet ()) thread.join (); }
private:
ShellInterpreter ();
~ShellInterpreter () {}
ShellInterpreter & operator= (const ShellInterpreter &) { return *this; }
ShellInterpreter (const ShellInterpreter &) {}
static ShellInterpreter * shellinterp;
glGrib::Options gopts;
volatile bool hasstarted = false;
std::thread thread;
std::mutex mutex;
};
}
|