/home/tetron/hack/vos/apps/tutorials/vostut5client.cc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include <vos/vos/vos.hh>
00015
00016 using namespace VUtil;
00017 using namespace VOS;
00018
00019 void listTypes(Vobject* vob);
00020
00021 int main(int argc, char** argv)
00022 {
00023 std::cout << "VOS Tutorial 5 Client\n\n";
00024
00025 Site localsite;
00026 localsite.addSiteExtension(new LocalVipSiteExtension());
00027
00028 std::string siteurl;
00029 if(argc > 1) siteurl = argv[1];
00030 else siteurl = "vip://localhost:4231";
00031
00032
00033
00034
00035
00036
00037 try {
00038 vRef<Vobject> position = Vobject::findObjectFromRoot(siteurl + "/planet/position");
00039
00040 listTypes(position);
00041
00042
00043
00044
00045
00046
00047
00048
00049 vRef<Property> positionproperty = meta_cast<Property>(position);
00050
00051 std::cout << "vostut5client: The property value of " << positionproperty->getURLstr()
00052 << " is now " << positionproperty->read() << std::endl;
00053
00054 } catch(std::runtime_error& e) {
00055 std::cout << "Error! " << e.what() << "\n";
00056 }
00057 }
00058
00059 void listTypes(Vobject* vob)
00060 {
00061 std::cout << "Types for " << vob->getURLstr() << ": ";
00062 for(TypeSetIterator types = vob->getTypes(); types.hasMore(); types++)
00063 {
00064 if(!types.atStart()) std::cout << ", ";
00065 std::cout << (*types);
00066 }
00067 std::cout << "\n";
00068 }
00069