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

apps/tutorials/vostut7client.cc

Go to the documentation of this file.
00001 /* Seventh VOS tutorial.  Creating your own MetaObjects
00002 
00003    This tutorial covers:
00004    - Accessing our hello object remotely
00005 
00006    This file (vostut7client.cc) is released into the public domain.  No
00007    restrictions are placed on its use, distribution or inclusion into
00008    other works.
00009 */
00010 
00011 #include "vostut7hello.hh"
00012 
00013 int main(int argc, char** argv)
00014 {
00015     Hello::registerExtenders();
00016 
00017     LocalSocketSite site(&NoAccessControl::static_);
00018 
00019     try {
00020         /* Use a path from the command line (or the default). */
00021         string siteurl;
00022         if(argc > 1) siteurl = argv[1];
00023         else siteurl = "vop://localhost:4231";
00024 
00025         LOG("helloclient", 1, "Acquiring remote object at " << siteurl);
00026 
00027         vRef<Vobject> v = Vobject::findObjectFromRoot(siteurl + "/hello");
00028 
00029         Hello& h = MetaObject::meta_cast<Hello&>(*v);
00030 
00031          LOG("helloclient", 1, "Saying 'Good day to you sir.'");
00032 
00033          // Call the hello method.  From the application's point of
00034          // view, it doesn't matter that it's a remote object.
00035          // Everything happens behind the scenes.
00036 
00037          string s = h.hello("Good day to you sir.");
00038 
00039          LOG("helloclient", 1, "Got back: '" << s << "'");
00040 
00041     } catch(Vobject::NoSuchObjectError x){
00042         LOG("helloclient", 1, "NoSuchObjectError " << x.what());
00043     } catch(Vobject::NoSuchSiteError x){
00044         LOG("helloclient", 1, "NoSuchSiteError " << x.what());
00045     } catch(Vobject::AccessControlError x){
00046         LOG("helloclient", 1, "AccessControlError " << x.what());
00047     } catch(Vobject::RemoteError x){
00048         LOG("helloclient", 1, "RemoteError " << x.what());
00049     } catch(URL::BadURLError x){
00050         LOG("helloclient", 1, "BadURLError " << x.what());
00051     } catch(bad_cast){
00052         LOG("helloclient", 1, "Bad cast");
00053     }
00054     return 0;
00055 }
00056 

Generated on Tue Aug 12 03:55:36 2003 for Interreality Project - VOS by doxygen 1.3.2