Line data Source code
1 : #ifndef OPENDDS_DCPS_LOGADDR_H 2 : #define OPENDDS_DCPS_LOGADDR_H 3 : 4 : #include "dcps_export.h" 5 : #include "PoolAllocator.h" 6 : #include "NetworkAddress.h" 7 : 8 : #include <dds/Versioned_Namespace.h> 9 : 10 : #include <ace/INET_Addr.h> 11 : 12 : #include <cstddef> 13 : 14 : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL 15 : 16 : namespace OpenDDS { 17 : namespace DCPS { 18 : 19 : class OpenDDS_Dcps_Export LogAddr { 20 : public: 21 : enum Option {Ip, Port, Host, IpPort, HostPort, IpPortHost}; 22 : 23 : static const size_t BufSize; 24 : static const String ip(const ACE_INET_Addr& addr); 25 : static const String port(const ACE_INET_Addr& addr); 26 : static const String host(const ACE_INET_Addr& addr); 27 : 28 : explicit LogAddr(const ACE_INET_Addr& addr, Option opt = IpPort); 29 : explicit LogAddr(const NetworkAddress& addr, Option opt = IpPort); 30 : 31 : const String& str() const { return addr_; } 32 0 : const char* c_str() const { return addr_.c_str(); } 33 : 34 : private: 35 : void init_addr(const ACE_INET_Addr& addr, Option opt); 36 : 37 : String addr_; 38 : }; 39 : 40 : } // namespace DCPS 41 : } // namespace OpenDDS 42 : 43 : OPENDDS_END_VERSIONED_NAMESPACE_DECL 44 : 45 : #endif // OPENDDS_DCPS_LOGADDR_H