Module: Essential Networking Module Package: Networking
RWSockAddrFactoryRWSockAddrFactoryBase
#include <rw/network/RWSockAddrFactory.h>
RWSockAddrFactory builds addresses of any registered type. This class is used by the Networking classes implementation and is not normally used explicitly. The global object rwSockAddrFactory is used by functions such as RWSocket::getsockname, which do not know the type of socket address to build.
Specific address factory objects need to be registered with the factory via the general factory's registerWithFactory() method. Check RWInetAddrFactory for an example of a specific address family factory.
These singleton objects are constructed when used, so they are not dependent on the order of static initialization.
RWSockAddrFactory();
Creates a factory with no create methods attached.
virtual ~RWSockAddrFactory();
Virtual destructor.
virtual RWSockAddrBase* operator()(struct sockaddr *addr, int addrLen) const; virtual RWSockAddrBase* operator()(struct sockaddr *addr, int addrLen, int type) const; virtual RWSockAddrBase* operator()(const RWCString& str) const;
Constructs a socket address. First, you need to extract the family name from the string or extract the identifier from the sockaddr, then look up the appropriate factory object and use it. If no factory has been registered for the family, an RWNetNoNumberFactoryRegisteredError or RWNetNoNameFactoryRegisteredError exception is thrown.
The newly created socket address is allocated on the heap. The caller is responsible for deleting it. Often, this is managed by wrapping the object using an RWSockAddr. The RWCString should contain 7-bit US-ASCII data.
void registerWithFactory(const RWSockType& family, RWSockAddrFactoryBase *factory); void registerWithFactory(int family, RWSockAddrFactoryBase *factory); void registerWithFactory(const RWCString& family, RWSockAddrFactoryBase *factory);
Registers maker objects. Duplicate registration is a no-op. If you attempt to register two different factories with the same family, an exception is thrown. The variant that takes a socket type argument registers both the standard family name for that socket type and the family number. The pointer to the factory must remain valid as long as self is used to build addresses. The RWCString should contain 7-bit US-ASCII data.
void unRegister(const RWSockType&); void unRegister(int family); void unRegister(const RWCString& family);
Removes all knowledge from the factory of how to build addresses of the indicated family. This is useful if you want to explicitly replace one factory with another for the same family. Unless you first unRegister, an RWNetAlreadyRegisteredError exception is thrown. It is not an error to unregister a type that has never been registered. The RWCString should contain 7-bit US-ASCII data.
static RWSockAddrFactory& theGlobalRWSockAddrFactory();
Returns the global factory that is used by the Networking classes. This is more conveniently accessed via the rwSockAddrFactory macro. If the factory has not yet been constructed, it is constructed and the well-known families are registered. This class is now deprecated.
rwSockAddrFactory
Defined internally as a macro to obtain a reference to the factory object.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.