#ifndef _MARIONETTE_H
#define _MARIONETTE_H

#include <cstdint>
#include <atomic>
#include <memory>
#include <component.h>

namespace smo {

class MarionetteThread;

namespace mrntt {

class MarionetteComponent
:	public Component
{
public:
	MarionetteComponent(const std::shared_ptr<ComponentThread> &thread);
	~MarionetteComponent() = default;

public:
	typedef std::function<void(bool)> mrnttLifetimeMgmtOpCbFn;
	void initializeReq(Callback<mrnttLifetimeMgmtOpCbFn> callback);
	void finalizeReq(Callback<mrnttLifetimeMgmtOpCbFn> callback);

private:
	class MrnttLifetimeMgmtOp;
};

extern std::atomic<int> exitCode;
void exitMarionetteLoop();
void marionetteFinalizeReqCb(bool success);
extern mrntt::MarionetteComponent mrntt;

} // namespace mrntt

struct CrtCommandLineArgs
{
    CrtCommandLineArgs(int argc, char *argv[], char *envp[])
    :   argc(argc), argv(argv), envp(envp)
    {}

    int argc;
    char **argv;
    char **envp;

    static void set(int argc, char *argv[], char *envp[]);
};

} // namespace smo

#endif // _MARIONETTE_H
