34 #ifndef PTLIB_PROCESS_H
35 #define PTLIB_PROCESS_H
56 #define PCREATE_PROCESS(cls) \
58 instance.InternalMain();
59 #elif defined(P_RTEMS)
60 #define PCREATE_PROCESS(cls) \
62 void* POSIX_Init( void* argument) \
64 static cls instance; \
65 exit( instance.InternalMain() ); \
68 #elif defined(_WIN32_WCE)
69 #define PCREATE_PROCESS(cls) \
70 PDEFINE_WINMAIN(hInstance, , lpCmdLine, ) \
72 cls *pInstance = new cls(); \
73 pInstance->GetArguments().SetArgs(lpCmdLine); \
74 int terminationValue = pInstance->InternalMain(hInstance); \
76 return terminationValue; \
79 #define PCREATE_PROCESS(cls) \
80 int main(int argc, char ** argv, char ** envp) \
82 cls *pInstance = new cls(); \
83 pInstance->PreInitialise(argc, argv, envp); \
84 int terminationValue = pInstance->InternalMain(); \
86 return terminationValue; \
96 #define PDECLARE_PROCESS(cls,ancestor,manuf,name,major,minor,status,build) \
97 class cls : public ancestor { \
98 PCLASSINFO(cls, ancestor); \
100 cls() : ancestor(manuf, name, major, minor, status, build) { } \
102 virtual void Main(); \
146 ,
m_id(t->GetTimerId())
166 typedef std::queue<RequestType> RequestQueueType;
167 RequestQueueType m_requestQueue;
176 struct ActiveTimerInfo {
178 : m_timer(t), m_serialNumber(serialNumber) { }
182 typedef std::map<PTimer::IDType, ActiveTimerInfo> ActiveTimerInfoMap;
183 ActiveTimerInfoMap m_activeTimers;
186 struct TimerExpiryInfo {
188 : m_timerId(id), m_expireTime(expireTime), m_serialNumber(serialNumber) { }
194 struct TimerExpiryInfo_compare
195 :
public binary_function<TimerExpiryInfo, TimerExpiryInfo, bool>
197 bool operator()(
const TimerExpiryInfo & _Left,
const TimerExpiryInfo & _Right)
const
198 {
return (_Left.m_expireTime < _Right.m_expireTime); }
201 typedef std::multiset<TimerExpiryInfo, TimerExpiryInfo_compare> TimerExpiryInfoList;
202 TimerExpiryInfoList m_expiryList;
248 const char * manuf =
"",
249 const char * name =
"",
726 typedef std::map<PThreadIdentifier, PThread *>
ThreadMap;
739 #include "msos/ptlib/pprocess.h"
741 #include "unix/ptlib/pprocess.h"
758 const char * manuf =
"",
759 const char * name =
"",
760 WORD majorVersionNum = 1,
761 WORD minorVersionNum = 0,
764 ) :
PProcess(manuf, name, majorVersionNum, minorVersionNum, statusCode, buildNum, true) { }
792 #define P_DEFAULT_TRACE_OPTIONS ( PTrace::Blocks | PTrace::Timestamp | PTrace::Thread | PTrace::FileAndLine )
794 template <
unsigned level,
unsigned options = P_DEFAULT_TRACE_OPTIONS >
805 #endif // PTLIB_PROCESS_H
static PString GetLibVersion()
Get the version of the PTLib library the process is running on, eg "2.5beta3".
virtual bool OnInterrupt(bool terminating)
Callback for when a ^C (SIGINT) or termination request (SIGTERM) is received by process.
bool m_shuttingDown
Definition: pprocess.h:724
virtual const PString & GetName() const
Get the name of the process.
std::map< PThreadIdentifier, PThread * > ThreadMap
Definition: pprocess.h:726
virtual void Main()
< Dummy Main() as libraries do not have one.
Definition: pprocess.h:768
static void PreShutdown()
Internal shutdown function called directly from the ~PProcess InternalMain().
WORD buildNumber
Definition: pprocess.h:715
PTime programStartTime
Definition: pprocess.h:722
void QueueRequest(RequestType::Action action, PTimer *timer, bool isSync=true)
PString GetGroupName() const
Get the effective group name of the owner of the process, eg "root" etc.
static PString GetOSHardware()
Get the hardware the process is running on, eg "sparc".
PInt64 m_absoluteTime
Definition: pprocess.h:154
This class defines an arbitrary time interval to millisecond accuracy.
Definition: timeint.h:55
#define PCLASSINFO(cls, par)
Declare all the standard PTLib class information.
Definition: object.h:1049
Definition: pprocess.h:242
static PProcess & Current()
Get the current processes object instance.
PString productName
Definition: pprocess.h:710
This class defines an absolute time and date.
Definition: ptime.h:53
void SetIcon(const PString &icon)
bool m_library
Definition: pprocess.h:706
PFactory< PProcessStartup > PProcessStartupFactory
Definition: pprocess.h:787
This is a dictionary collection class of PString objects, keyed by another string.
Definition: pstring.h:2784
This class describes a full description for a file on the particular platform.
Definition: filepath.h:65
void SetTerminationValue(int value)
Set the termination value for the process.
Comparison
Result of the comparison operation performed by the Compare() function.
Definition: object.h:1184
static PString GetOSVersion()
Get the version of the operating system the process is running on, eg "2.0.33".
HostSystemURLHandlerInfo()
Definition: pprocess.h:673
PTimer * m_timer
Definition: pprocess.h:152
CodeStatus status
Definition: pprocess.h:714
PTimer::IDType GetNewTimerId() const
Definition: pprocess.h:134
virtual void Terminate()
Terminate the process.
Code is still very much under construction.
Definition: pprocess.h:237
RequestType(Action act, PTimer *t)
Definition: pprocess.h:143
static PString GetOSName()
Get the name of the operating system the process is running on, eg "Linux".
static void PostShutdown()
static void Initialise(unsigned level, const char *filename=NULL, unsigned options=Timestamp|Thread|Blocks)
Set the most common trace options.
PArgList & GetArguments()
Get the programme arguments.
virtual int InternalMain(void *arg=NULL)
Main function for process, called from real main after initialisation.
static PString GetOSClass()
Get the class of the operating system the process is running on, eg "unix".
static bool IsOSVersion(unsigned major, unsigned minor=0, unsigned build=0)
See if operating system is later than the version specified.
This is an array collection class of PString objects.
Definition: pstring.h:2024
WORD minorVersion
Definition: pprocess.h:713
virtual void OnThreadEnded(PThread &thread)
Callback for when a thread is ended if wqas started in the PTLib system.
void SetCommand(const PString &key, const PString &command)
PBoolean SetMaxHandles(int newLimit)
Set the maximum number of file handles for the process.
virtual PString GetConfigurationFile()
Get the default file to use in PConfig instances.
virtual const PString & GetManufacturer() const
Get the name of the manufacturer of the software.
Comparison Compare(const PObject &obj) const
Compare two process instances.
PTimerList timers
Definition: pprocess.h:730
PString manufacturer
Definition: pprocess.h:709
Code is largely complete and is under test.
Definition: pprocess.h:239
This class represents an operating system process.
Definition: pprocess.h:227
A class representing a system timer.
Definition: timer.h:181
BOOL PBoolean
Definition: object.h:102
Class to represent a directory in the operating system file system.
Definition: pdirect.h:182
WORD majorVersion
Definition: pprocess.h:712
Definition: pprocess.h:106
PProcessIdentifier m_processID
Definition: pprocess.h:732
This class implements an integer that can be atomically incremented and decremented in a thread-safe ...
Definition: critsec.h:171
Action
Definition: pprocess.h:138
PTime GetStartTime() const
Return the time at which the program was started.
static PDirectory GetOSConfigDir()
Get the configuration directory of the operating system the process is running on, eg "/etc" for Unix, "c:\windows" for Win95 or "c:\winnt\system32\drivers\etc" for NT.
static PBoolean IsInitialised()
Determine if the current processes object instance has been initialised.
This class can be used to register various URL types with the host operating system so that URLs will...
Definition: pprocess.h:670
PLibraryProcess(const char *manuf="", const char *name="", WORD majorVersionNum=1, WORD minorVersionNum=0, CodeStatus statusCode=ReleaseCode, WORD buildNum=1)
Create a new process instance.
Definition: pprocess.h:757
PProcess(const char *manuf="", const char *name="", WORD majorVersion=1, WORD minorVersion=0, CodeStatus status=ReleaseCode, WORD buildNumber=1, bool library=false)
Create a new process instance.
Class for a process that is a dynamically loaded library.
Definition: pprocess.h:748
enum PTimerList::RequestType::Action m_action
virtual void SetThreadName(const PString &name)
Change the name of the thread.
PString GetUserName() const
Get the effective user name of the owner of the process, eg "root" etc.
The character string class.
Definition: pstring.h:108
int GetMaxHandles() const
Get the maximum file handle value for the process.
This class allows the parsing of a set of program arguments.
Definition: args.h:45
PTimerList * GetTimerList()
Get the list of timers handled by the application.
PTimer::IDType m_id
Definition: pprocess.h:153
This class defines a thread of execution in the system.
Definition: thread.h:66
PStringArray configurationPaths
Definition: pprocess.h:718
virtual void OnShutdown()
Definition: pprocess.h:784
PString GetCommand(const PString &key) const
PAtomicInteger::IntegerType m_serialNumber
Definition: pprocess.h:155
Template class for generic factories of an abstract class.
Definition: pfactory.h:144
virtual PString GetThreadName() const
Get the name of the thread.
PMutex m_activeThreadMutex
Definition: pprocess.h:728
PBoolean SetUserName(const PString &username, PBoolean permanent=false)
Set the effective owner of the process.
Definition: pprocess.h:136
Definition: pprocess.h:779
static PProcessIdentifier GetCurrentProcessID()
Get the platform dependent process identifier for the currentprocess.
const PFilePath & GetFile() const
Get the processes executable image file path.
PFilePath executableFile
Definition: pprocess.h:717
Definition: pprocess.h:139
Code has all known bugs removed and is shipping.
Definition: pprocess.h:241
PBoolean SetGroupName(const PString &groupname, PBoolean permanent=false)
Set the effective group of the process.
virtual void OnStartup()
Definition: pprocess.h:783
int maxHandles
Definition: pprocess.h:720
CodeStatus
Release status for the program.
Definition: pprocess.h:235
int terminationValue
Definition: pprocess.h:707
PArgList arguments
Definition: pprocess.h:719
PAtomicBase::IntegerType IntegerType
Definition: critsec.h:174
static bool RegisterTypes(const PString &types, bool force=true)
ThreadMap m_activeThreads
Definition: pprocess.h:727
HostSystemURLHandlerInfo(const PString &t)
Definition: pprocess.h:676
void SetConfigurationPath(const PString &path)
Set the default file or set of directories to search for use in PConfig.
void PreInitialise(int argc, char **argv, char **envp)
Internal initialisation function called directly from InternalMain().
virtual void OnThreadStart(PThread &thread)
Callback for when a thread is started by the PTLib system.
Ultimate parent class for all objects in the class library.
Definition: object.h:1118
Definition: pprocess.h:140
PProcessIdentifier GetProcessID() const
Get the platform dependent process identifier for the process.
Definition: pprocess.h:425
PString type
Definition: pprocess.h:693
This class defines a thread synchronisation object.
Definition: syncpoint.h:67
virtual PString GetVersion(PBoolean full=true) const
Get the version of the software.
PSyncPoint * m_sync
Definition: pprocess.h:156
int GetTerminationValue() const
Get the termination value for the process.
unsigned IDType
Definition: timer.h:186