Using CORBA As A Client
  • Assume that an instance of Auction::Item has been created and an object reference written out to disk
  • The following code accesses that object (all the error checking code has been omitted):
      #include <fstream>
      #include <corba.h>
      #include "auction.h"
      
      int main(int argc, char** argv)
      {
          CORBA::ORB_ptr orb = CORBA::ORB_init( argc, argv );
          std::ifstream iorF("item.ior");
          std::string iorBuff;
          iorF >> iorBuff;
          CORBA::Object_var t1 = orb->string_to_object(iorBuff.c_str());
          Auction::Item_var theItem = Auction::Item::_narrow(t1);
          CORBA::String_var res = theItem->description();
          cerr << "Description = " << res << endl;
          return 0;
      }
              

Next Slide >>