|
|
@@ -31,6 +31,7 @@ |
|
|
|
|
|
|
|
#include <string> |
|
|
|
#include <vector> |
|
|
|
#include <mutex> |
|
|
|
|
|
|
|
namespace CodeDweller { |
|
|
|
|
|
|
@@ -88,11 +89,10 @@ namespace CodeDweller { |
|
|
|
public: |
|
|
|
|
|
|
|
/// Get the instance of the singleton. |
|
|
|
static Service& getInstance() |
|
|
|
{ |
|
|
|
static Service service; |
|
|
|
return service; |
|
|
|
} |
|
|
|
// |
|
|
|
// \returns a reference to the singleton. |
|
|
|
// |
|
|
|
static Service& getInstance(); |
|
|
|
|
|
|
|
/// Callback functor interface. |
|
|
|
class Callback { |
|
|
@@ -116,12 +116,33 @@ namespace CodeDweller { |
|
|
|
// |
|
|
|
int main(int argc, char *argv[]); |
|
|
|
|
|
|
|
/// Register a callback for receipt of Pause. |
|
|
|
// |
|
|
|
// \param[in] pauseFunctor is the function object to invoke when |
|
|
|
// Pause is received. |
|
|
|
// |
|
|
|
void onPauseCall(Callback &pauseFunctor); |
|
|
|
|
|
|
|
/// Register a callback for receipt of Resume. |
|
|
|
// |
|
|
|
// \param[in] resumeFunctor is the function object to invoke when |
|
|
|
// Resume is received. |
|
|
|
// |
|
|
|
void onResumeCall(Callback &resumeFunctor); |
|
|
|
|
|
|
|
/// Register a callback for receipt of Restart. |
|
|
|
// |
|
|
|
// \param[in] restartFunctor is the function object to invoke when |
|
|
|
// Restart is received. |
|
|
|
// |
|
|
|
void onRestartCall(Callback &restartFunctor); |
|
|
|
|
|
|
|
/// Register a callback for receipt of Stop. |
|
|
|
// |
|
|
|
// \param[in] stopFunctor is the function object to invoke when |
|
|
|
// Stop is received. |
|
|
|
// |
|
|
|
void onStopCall(Callback *stopFunctor); |
|
|
|
void onStopCall(Callback &stopFunctor); |
|
|
|
|
|
|
|
/// Check whether Pause was received. |
|
|
|
// |
|
|
@@ -197,6 +218,9 @@ namespace CodeDweller { |
|
|
|
// |
|
|
|
int run(); |
|
|
|
|
|
|
|
/// Mutex to serialize access to the object. |
|
|
|
static std::mutex objectMutex; |
|
|
|
|
|
|
|
/// Thread start function to receive messages. |
|
|
|
void processMessages(); |
|
|
|
|
|
|
@@ -224,6 +248,15 @@ namespace CodeDweller { |
|
|
|
/// True if Stop message was received. |
|
|
|
bool stopReceived; |
|
|
|
|
|
|
|
/// Functions to invoke when the Pause is received. |
|
|
|
std::vector<Callback *> pauseCallbacks; |
|
|
|
|
|
|
|
/// Functions to invoke when the Resume is received. |
|
|
|
std::vector<Callback *> resumeCallbacks; |
|
|
|
|
|
|
|
/// Functions to invoke when the Restart is received. |
|
|
|
std::vector<Callback *> restartCallbacks; |
|
|
|
|
|
|
|
/// Functions to invoke when the Stop is received. |
|
|
|
std::vector<Callback *> stopCallbacks; |
|
|
|
|