Poco::Remoting

class ORB

Library: Remoting
Package: Remoting
Header: Poco/Remoting/ORB.h

Description

The object broker is a singleton which manages listeners, RemoteObjects, Skeletons and proxy creation. A Client will typically use findObject to retrieve an object. It is recommended to use the various helper classes generated by the code generator to retrieve an instance of an object. Example: Assume you have a class MyClass. Create a configuration file containing Remoting/RemoteObject.h, Remoting/Proxy.h, Remoting/Skeleton.h, MyClass.h (see RemoteGen example config file). Start the RemoteGen application which generates the following files:

IMyClass, MyClassHelper, MyClassProxy, MyClassProxyFactory, MyClassSkeleton, MyClassRemoteObject

Use MyClassHelper::find(uri) to retrieve the object behind the given endpoint (if proxy or local object is decided transparently in the ORB). The returned object will be of type AutoPtr<IMyClass> which has the same interface as MyClass.

Member Summary

Member Functions: findObject, getSkeleton, instance, invoke, registerClass, registerListener, registerObject, registerProxyFactory, registerSkeleton, shutdown, unregisterClass, unregisterListener, unregisterObject, unregisterProxyFactory, unregisterSkeleton

Types

IdentifiablePtr

typedef Poco::AutoPtr < Identifiable > IdentifiablePtr;

ListenerObjects

typedef std::map < std::string, std::set < std::string > > ListenerObjects;

A map that stores for each listener end points the set of object uris registered to it.

ListenerPtr

typedef Poco::SharedPtr < Listener > ListenerPtr;

Listeners

typedef std::map < std::string, ListenerPtr > Listeners;

RemoteObjectPtr

typedef Poco::AutoPtr < RemoteObject > RemoteObjectPtr;

RemoteObjects

typedef std::map < std::string, RemoteObjectPtr > RemoteObjects;

SkeletonInfo

typedef std::pair < SkeletonPtr, TransportRemoteObjects > SkeletonInfo;

SkeletonPtr

typedef Poco::AutoPtr < Skeleton > SkeletonPtr;

Skeletons

typedef std::map < Identifiable::TypeId, SkeletonInfo > Skeletons;

TransportRemoteObjects

typedef std::map < std::string, RemoteObjects > TransportRemoteObjects;

Maps transports string to a map of oid->RemoteObject

Constructors

Destructor

~ORB protected

~ORB();

Destroys the ORB.

Member Functions

findObject

IdentifiablePtr findObject(
    const std::string & uri
);

The uri must have the following format: scheme://serverName/transport/typeId/objectId Don't use directly, use the generated helper class for the given object type which performs the cast from IdentifiablePtr to the object type automatically.

getSkeleton

SkeletonPtr getSkeleton(
    const Identifiable::TypeId & tid
);

Returns a skeleton for the given type or an exception if not found.

instance static

static ORB & instance();

Returns a reference to the global ORB.

invoke

bool invoke(
    const std::string & uriPath,
    std::istream & in,
    std::ostream & out,
    Transport & transport
);

Mostly used by skeletons. Returns false if the object was not found. It is up to the calling transport to handle this error!

registerClass

void registerClass(
    const Identifiable::TypeId & tid,
    ProxyFactory * pProxy,
    Skeleton * pSkel
);

Registers a proxy factory for the given class and the skeleton. Takes ownership of all pointers. Duplicate registration of a class is ignored!

registerListener

void registerListener(
    Listener * pListener
);

Registers listeners at the ORB, ORB takes ownership of the listener object. The local endpoint of the Listeners must be unique and will result in an exception if not. In this case, the ORB will delete the pointer to the object.

registerObject

void registerObject(
    ORB::RemoteObjectPtr pRO,
    const std::string & uri
);

Adds an remote Object to the ORB: a class must have already been registered for the type! Duplicate registration of an object yields an exception! If the registration fails due to the ORB being in shutdown mode, an exception is thrown. A classhandler for the object must exist, a listener also. Takes ownership of the RemoteObject.

registerProxyFactory

void registerProxyFactory(
    const Identifiable::TypeId & tid,
    ProxyFactory * pProxy
);

Registers a proxy factory for the given class. Takes ownership of all pointers. Duplicate registration of a class is ignored!

registerSkeleton

void registerSkeleton(
    const Identifiable::TypeId & tid,
    Skeleton * pSkel
);

Registers a skeleton for the given class. Takes ownership of all pointers. Duplicate registration of a class is ignored!

shutdown

void shutdown();

Stops all listeners and removes them plus all objects and skeletons from the orb

unregisterClass

void unregisterClass(
    const Identifiable::TypeId & tid,
    bool autoRemoveObjects = false
);

Unregisters a proxy factory for the given type and its skeleton, if found. If objects are still registered and autoRemoveObjects is false, it will fail with a RemotingException.

unregisterListener

void unregisterListener(
    const std::string & listenerEndPoint,
    bool autoRemoveObjects = false
);

Unregisters listeners at the ORB, if found. Will automatically removes all objects associated with that listener if autoRemoveObjects is set to true, otherwise it will check if objects are still registered and will fail with a RemotingException

unregisterObject inline

void unregisterObject(
    const std::string & uri
);

Removes a remote Object from the ORB, if found. Skeleton and Transport must still exist!

unregisterProxyFactory inline

void unregisterProxyFactory(
    const Identifiable::TypeId & tid
);

Unregisters a proxy factory for the given type, if found.

unregisterSkeleton inline

void unregisterSkeleton(
    const Identifiable::TypeId & tid,
    bool autoRemoveObjects = false
);

Unregisters a skeleton for the given type, if found. If objects are still registered and autoRemoveObjects is false, it will fail with a RemotingException.