Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages | Examples

VOS::RemoteVobject Class Reference

This class allows you to access remotely Vobjects as if they were local. More...

#include <vos/corelibs/vos/remotevobject.hh>

Inheritance diagram for VOS::RemoteVobject:

VOS::VobjectImplementation VOS::Vobject VOS::ObjectExciseListener VOS::RefCounted VOS::RemoteMetaObject VOS::RemoteSite VOS::RemoteSocketSite VOS::RemoteStreamSite List of all members.

Public Member Functions

Static Public Member Functions

Protected Member Functions


Detailed Description

This class allows you to access remotely Vobjects as if they were local.

Definition at line 43 of file remotevobject.hh.


Constructor & Destructor Documentation

RemoteVobject::RemoteVobject const string &  name,
RemoteSite remotesite
[protected]
 

Definition at line 39 of file remotevobject.cc.

RemoteVobject::~RemoteVobject  )  [virtual]
 

Definition at line 61 of file remotevobject.cc.


Member Function Documentation

void RemoteVobject::acquire  )  [virtual]
 

Increment the reference count.

Reimplemented from VOS::RefCounted.

Reimplemented in VOS::RemoteMetaObject.

Definition at line 624 of file remotevobject.cc.

void RemoteVobject::addChildListener ChildChangeListener cl,
bool  notifyImmediately = true
[virtual]
 

Adds some object callback to be notified when the child list changes.

The child listener will immediately be issued a notifyChildInserted() for each child.

Parameters:
cl The listener object. If this object is also a RefCounted object, reference counting will be done correctly.
notifyImmediately if true, notify listener immediately (before returning). otherwise defer until a future update

Reimplemented from VOS::VobjectImplementation.

Reimplemented in VOS::RemoteMetaObject.

Definition at line 545 of file remotevobject.cc.

void RemoteVobject::addParentListener ParentChangeListener pl,
bool  notifyImmediately = true
[virtual]
 

Adds some object callback to be notified when the parent set changes.

Parameters:
pl the listener object notifyImmediately if true, notify listener immediately (before returning). otherwise defer until a future update If this object is also a RefCounted object, reference counting will be done correctly.

Reimplemented from VOS::VobjectImplementation.

Reimplemented in VOS::RemoteMetaObject.

Definition at line 531 of file remotevobject.cc.

void RemoteVobject::addType const string &  type  )  [virtual]
 

Adds a new type to this object's type set.

This only changes the stored set of type name strings and does not necessarily affect the actual code behind the object. See the Local Site class for information about extending the actual functionality of an existing meta objects.

Parameters:
s the type string

Implements VOS::Vobject.

Reimplemented in VOS::RemoteMetaObject.

Definition at line 607 of file remotevobject.cc.

void RemoteVobject::addTypeListener TypeChangeListener tl,
bool  notifyImmediately = true
[virtual]
 

Adds some object callback to be notified when the type set changes.

Parameters:
tl the listener object.
notifyImmediately if true, notify listener immediately (before returning). otherwise defer until a future update If this object is also a RefCounted object, reference counting will be done correctly.

Reimplemented from VOS::VobjectImplementation.

Reimplemented in VOS::RemoteMetaObject.

Definition at line 516 of file remotevobject.cc.

Vobject::ParentChildRelation & RemoteVobject::findChild const string &  path  )  throw (NoSuchObjectError, AccessControlError, RemoteError) [virtual]
 

Find a child.

This searchs for a single parent-child relation in the immediate child list of this object. It is distinguished from findObject in that it returns the full parent-child relation structure, and that it only accepts two forms of input: the child name, or the #position. See setChild() for more information about the possible numerical values of positions.

Parameters:
path either the child name or #position
Returns:
the ParentChildRelation structure representing the relation of this parent and the requested child. NOTE YOU MUST CALL release() WHEN DONE OR USE A rREF() BLOCK
Exceptions:
NoSuchObjectError if the path is illegal
AccessControlError if the site reported the user is not allowed that information

Reimplemented from VOS::VobjectImplementation.

Reimplemented in VOS::RemoteMetaObject.

Definition at line 397 of file remotevobject.cc.

Vobject & RemoteVobject::findObject const string &  path  )  throw (NoSuchSiteError, NoSuchObjectError, URL::BadURLError, AccessControlError, RemoteError) [virtual]
 

Searchs and returns some object similarly to findObjectFromRoot().

However, if the path does not start with the string "vop://" the path will be intepreted as relative to this object. For example, "foo/bar" will find the first child object named "foo" of this object, then the first child named "bar" of the "foo" object and return it. If there is a leading slash, the path is relative to the object's site, so "/foo/bar" does not necessarily mean the same thing. Note that there should never be a slash at the end, so "foo/" is NOT a legal path. Finally, instead of using child names, one may use "\#position", starting from zero. So "\#0" refers to the first child of this object, "\#1" to the second etc. Obviously if the number in #position is larger than the number of children, an exception will be raised. See setChild() for more information about the possible numerical values of positions.

Parameters:
path the path to the object we want to find
Returns:
the object, if found. NOTE YOU MUST CALL release() WHEN DONE OR USE A rREF() BLOCK
Exceptions:
NoSuchSiteError The DNS lookup for the site failed, the site is not listening on the expected port, or the site otherwise could not be connected to (only thrown if there is a site specified in the path.)
NoSuchObjectError if that object path does not exist on the site
URL::BadURLError if there is a syntax error in the supplied URL
AccessControlError if the site reported that the user is not allowed that information

Reimplemented from VOS::VobjectImplementation.

Reimplemented in VOS::RemoteMetaObject.

Definition at line 81 of file remotevobject.cc.

const deque< Vobject::ParentChildRelation * > & RemoteVobject::getChildren  )  throw (AccessControlError, RemoteError) [virtual]
 

Get the set of parent-child relationships in which this object is the parent.

Returns:
a set of parent-child relations
Warning:
You should always assign the results of getChildren to a variable. Do NOT do this:
       for(Vobject::ChildList::const_iterator i = v->getChildren().begin();
            i != v->getChildren().end(); i++) {
            ...
       }
Instead, you should do this:
       const ChildList& cl = v->getChildren();
       for(Vobject::ChildList::const_iterator i = cl.begin(); i != cl.end(); i++) {
            ...
       }
The reason for this is that if vobj is remote, each call to getChildren() may trigger a remote call. In addition to being inefficient, this will wipe and replace the child list you are in the midst of using, which will probably invalidate the iterator and cause your program to crash.

Reimplemented from VOS::VobjectImplementation.

Reimplemented in VOS::RemoteMetaObject.

Definition at line 118 of file remotevobject.cc.

const set< Vobject::ParentChildRelation *, Vobject::ParentChildRelation::Cmp > & RemoteVobject::getParents  )  throw (AccessControlError, RemoteError) [virtual]
 

Get the set of parent-child relationships in which this object is the child.

Returns:
a set of parent-child relations

Reimplemented from VOS::VobjectImplementation.

Reimplemented in VOS::RemoteMetaObject.

Definition at line 138 of file remotevobject.cc.

const set< string > & RemoteVobject::getTypes  )  throw (AccessControlError, RemoteError) [virtual]
 

Return a set of type names for the types supported by this object.

Returns:
the set of type names

Reimplemented from VOS::VobjectImplementation.

Reimplemented in VOS::RemoteMetaObject.

Definition at line 370 of file remotevobject.cc.

LocalSite & RemoteVobject::initFields Vobject v,
Message m,
const string &  method,
bool  withnonce
[static]
 

Convenience function which initializes various message fields when sending out a message.

Parameters:
v the remote object emitting this message
m the message to be filled in
method the method field
withnonce whether to generate a nonce or not
Returns:
The local site which this remote object's site is peered to. This is useful because you often want to do something like
    vRef<Message> m = new Message();
        vRef<LocalSite> ls = initFields(this, &m, "my-method", true);
        // fill in some other fields here
    sendMessage(&m);
    vRef<Site> site = getSite();
        vRef<Message> thereply = ls->waitFor(m->getNonce(), dynamic_cast<RemoteSite*>(&site));
        // do stuff with 'thereply'
NOTE YOU MUST CALL release() WHEN DONE OR USE A rREF() BLOCK (as shown above)
Note:
Here is what this method actually does:
        m->setType("message");
        LocalSite& ls = dynamic_cast<RemoteSite*>(&(v->getSite()))->getLocalPeer();
        m->setFrom(ls.getURL().getString());
        m->setTo(v->getURL().getString());
        m->setMethod(method);
        if(withnonce) m->generateNonce();
See also LocalVobject::initReply()

Definition at line 65 of file remotevobject.cc.

Referenced by addChildListener(), addParentListener(), addType(), addTypeListener(), VOS::RemoteSite::createMetaObject(), removeChildListener(), removeParentListener(), removeTypeListener(), and VOS::RemoteSocketSite::secureConnection().

void RemoteVobject::insertChild int  position,
const string &  contextual_name,
Vobject child
throw (AccessControlError, RemoteError) [virtual]
 

Insert a child at some position with a new object.

If the position is positive, the object is inserted such that it now occupies that position, and all objects starting from the previous occupant of that position onward are moved up one. If the position in negative, the object is similarly inserted so that it now occupies that position. For example, position -1 will append the object to the end of the list, position -2 will insert the object in the second-to-last position, etc. See setChild() for more information on positions.

Parameters:
position the position
contextual_name This is the name, specific to this parent-child relation, used for refering to this object by path.
child the child object, in question
Exceptions:
AccessControl if this object (when it is remote) doesn't approve of this action.

Implements VOS::Vobject.

Reimplemented in VOS::RemoteMetaObject.

Definition at line 477 of file remotevobject.cc.

void RemoteVobject::release  )  [virtual]
 

Decrement the reference count.

The object will be deleted if (count == 0)

Reimplemented from VOS::RefCounted.

Reimplemented in VOS::RemoteMetaObject, and VOS::RemoteSite.

Definition at line 630 of file remotevobject.cc.

void RemoteVobject::removeChild int  position  )  throw (AccessControlError, RemoteError) [virtual]
 

Remove the child at some position.

See setChild() for more information on positions.

Parameters:
position the position
Exceptions:
AccessControl if this object (when it is remote) doesn't approve of this action.

Implements VOS::Vobject.

Reimplemented in VOS::RemoteMetaObject.

Definition at line 495 of file remotevobject.cc.

void RemoteVobject::removeChildListener ChildChangeListener cl  )  [virtual]
 

Removes an existing object callback, previously added with addChildListener().

Parameters:
cl the listener object If this object is also a RefCounted object, reference counting will be done correctly.

Reimplemented from VOS::VobjectImplementation.

Reimplemented in VOS::RemoteMetaObject.

Definition at line 591 of file remotevobject.cc.

void RemoteVobject::removeParentListener ParentChangeListener pl  )  [virtual]
 

Removes an existing object callback, previously added with addParentListener().

Parameters:
pl the listener object If this object is also a RefCounted object, reference counting will be done correctly.

Reimplemented from VOS::VobjectImplementation.

Reimplemented in VOS::RemoteMetaObject.

Definition at line 575 of file remotevobject.cc.

void RemoteVobject::removeTypeListener TypeChangeListener tl  )  [virtual]
 

Removes an existing object callback, previously added with addTypeListener().

Parameters:
tl the listener object If this object is also a RefCounted object, reference counting will be done correctly.

Reimplemented from VOS::VobjectImplementation.

Reimplemented in VOS::RemoteMetaObject.

Definition at line 559 of file remotevobject.cc.

void RemoteVobject::sendMessage MessageBlock m  )  [virtual]
 

Sends a block of messages to the object.

This may trigger immediate processing of the message if the object is local.

Parameters:
m A pointer to the message which is being sent. Its reference count will be increased as necssary.

Implements VOS::Vobject.

Reimplemented in VOS::RemoteMetaObject, VOS::RemoteSite, VOS::RemoteSocketSite, and VOS::RemoteStreamSite.

Definition at line 56 of file remotevobject.cc.

void RemoteVobject::sendMessage Message m  )  [virtual]
 

Sends a message to the object.

This may trigger immediate processing of the message if the object is local.

Parameters:
m A pointer to the message which is being sent. Its reference count will be increased as necssary.

Implements VOS::Vobject.

Reimplemented in VOS::RemoteMetaObject, VOS::RemoteSite, VOS::RemoteSocketSite, and VOS::RemoteStreamSite.

Definition at line 51 of file remotevobject.cc.

Referenced by addChildListener(), addParentListener(), addType(), addTypeListener(), removeChildListener(), removeParentListener(), and removeTypeListener().

void RemoteVobject::sendUpdateMessage Message m  )  [virtual]
 

Gets the next message the update object has received.

Update messages are special in that they consist of messages sent from remote sites to update changes to our local cache.

Parameters:
m A pointer to the message which is being sent. Its reference count will be increased as necssary.

Reimplemented from VOS::VobjectImplementation.

Reimplemented in VOS::RemoteMetaObject, and VOS::RemoteSite.

Definition at line 329 of file remotevobject.cc.

void RemoteVobject::setChild int  position,
const string &  contextual_name,
Vobject child
throw (AccessControlError, RemoteError) [virtual]
 

Note:
supplying a NULL for child means release child object but do not delete parent-child relation...

Implements VOS::Vobject.

Reimplemented in VOS::RemoteMetaObject, and VOS::RemoteSite.

Definition at line 422 of file remotevobject.cc.


The documentation for this class was generated from the following files:
Generated on Tue Aug 12 03:56:06 2003 for Interreality Project - VOS by doxygen 1.3.2