mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-17 14:16:10 -06:00
71 lines
1.1 KiB
C++
71 lines
1.1 KiB
C++
#ifndef _Uniq_Uniq_h
|
|
#define _Uniq_Uniq_h
|
|
|
|
#include <CtrlLib/CtrlLib.h>
|
|
|
|
NAMESPACE_UPP
|
|
|
|
class Uniq
|
|
{
|
|
private:
|
|
|
|
// flag indicating we're inside first instance
|
|
bool isFirstInstance;
|
|
|
|
// path of named pipe
|
|
String pipePath;
|
|
|
|
#ifdef flagMT
|
|
Thread pollThread;
|
|
#endif
|
|
|
|
#ifdef PLATFORM_POSIX
|
|
// lock file to test for pipe existence
|
|
String lockPath;
|
|
int lockFile;
|
|
|
|
// send command line to callback handler
|
|
bool SendCmdLine(int pipe);
|
|
|
|
// polling callback -- either threaded or
|
|
// run by timed callback
|
|
void pollCb(void);
|
|
|
|
#else
|
|
|
|
HANDLE pipe;
|
|
OVERLAPPED overlapped;
|
|
HANDLE event;
|
|
|
|
// send command line to callback handler
|
|
bool SendCmdLine(void);
|
|
|
|
// polling callback -- either threaded or
|
|
// run by timed callback
|
|
void pollCb(void);
|
|
|
|
#endif
|
|
|
|
|
|
protected:
|
|
|
|
public:
|
|
|
|
typedef Uniq CLASSNAME;
|
|
|
|
// callback called when another app instance is run
|
|
Callback1<Vector<String> const &> WhenInstance;
|
|
|
|
Uniq();
|
|
|
|
~Uniq();
|
|
|
|
// checks whether we're inside main instance
|
|
bool IsFirstInstance(void) { return isFirstInstance; }
|
|
operator bool() { return isFirstInstance; }
|
|
};
|
|
|
|
END_UPP_NAMESPACE
|
|
|
|
#endif
|
|
|