// --------------------------------------------------------------------------- // This software is in the public domain, furnished "as is", without technical // support, and with no warranty, express or implied, as to its usefulness for // any purpose. // // IPCTarget.H // The destination of an IPC message. // // Author: Leserman // --------------------------------------------------------------------------- #ifndef _IPCTarget_H #define _IPCTarget_H #ifdef IDENT_H static const char* const IPCTarget_H_Id = "$Id: IPC_Target.H,v 1.11 1996/03/23 00:19:41 kelly Exp $"; #endif #include "commonDefs.h" // bool #include "TextString.H" // TextString #include "Dict.H" // Dict #include // pid_t #include // in_addr class IPC_Target { public: // Interprets named (nonymous) or stringified (anonymous) targets. IPC_Target(const TextString& targetName); // Make valid socket address but leave the DMQ target 0. IPC_Target(const in_addr& addr, pid_t pid); // Make the DMQ target but leave the socket target invalid. IPC_Target(unsigned long dmqTarget); // Make a null IPC target. IPC_Target(); // DMQ query/change unsigned long dmqTarget() const { return _dmqTarget; } void dmqTarget(unsigned long target) { _dmqTarget = dmqTarget; } // Socket query/change const in_addr& ipAddr() const { return _ipAddr; } void ipAddr(const in_addr& addr) { _ipAddr = ipAddr; } pid_t pid() const { return _pid; } void pid(pid_t pid) { _pid = pid; } // Null query bool isNull() const { return _targetType == NULL_TARGET; } // Comparisons bool operator==(const IPC_Target& rhs) const; bool operator!=(const IPC_Target& rhs) const; bool operator<(const IPC_Target& rhs) const // For hashing into a Dict operator unsigned long() const; // Render as a string. See also operator<<, defined outside the class. const TextString& textString() const; operator TextString() const; private: void initializeSocketAddr(); void initializeSocketAddr(const in_addr& addr, pid_t pid); enum TargetType { NULL_TARGET, DMQ, SOCKET, BOTH, NAMED }; TargetType _targetType; unsigned long _dmqTarget; in_addr _ipAddr; pid_t _pid; TextString _name; static void buildTargetDict(); static bool _initialized; static Dict _namedTargetDict; }; // Render as a string onto a stream. ostream& operator<<(ostream&, const IPC_Target&); #endif