Ejemplo n.º 1
0
Archivo: main.cpp Proyecto: CCJY/ATCD
void printContents (const CORBA::ContainedSeq& cont)
{
  try
    {
      for (CORBA::ULong i = 0; i < cont.length(); ++i)
        {
          CORBA::Contained::Description_var topdesc = cont[i]->describe ();
          if (topdesc->kind == CORBA::dk_Interface)
            {
              CORBA::InterfaceDef_var intDef =
                CORBA::InterfaceDef::_narrow (cont[i]);

              CORBA::InterfaceDef::FullInterfaceDescription_var desc =
                intDef->describe_interface ();

              //printf ("-- %s:\n", desc->name.in ());

              for (CORBA::ULong j1 = 0; j1 < desc->operations.length (); ++j1)
                ACE_DEBUG ((LM_DEBUG,
                            "operation %C::%C\n",
                            desc->name.in (),
                            desc->operations[j1].name.in ()));

              for (CORBA::ULong j2 = 0; j2 < desc->attributes.length (); ++j2)
                ACE_DEBUG ((LM_DEBUG,
                            "attribute %C::%C\n",
                            desc->name.in (),
                            desc->attributes[j2].name.in ()));
            }
          else if (topdesc->kind == CORBA::dk_Module)
            {
              CORBA::ModuleDef_var moduleDef =
                CORBA::ModuleDef::_narrow (cont[i]);

              CORBA::ContainedSeq_var moduleContents =
                moduleDef->contents (CORBA::dk_all, 1);
              printContents (moduleContents.in ());
            }
        }
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("printContents");
      ACE_OS::exit(-1); // the test has failed!
    }
}
Ejemplo n.º 2
0
Archivo: main.cpp Proyecto: CCJY/ATCD
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  try
    {
      CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
      CORBA::Object_var object =
        orb->resolve_initial_references ("InterfaceRepository");

      if (CORBA::is_nil (object.in ()))
        {
          ACE_ERROR_RETURN ((
              LM_ERROR,
              "Null objref from resolve_initial_references\n"),
             -1);
        }

      CORBA::Repository_var  ifr =
        CORBA::Repository::_narrow (object.in ());

      if (CORBA::is_nil (ifr.in ()))
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "CORBA::Repository::_narrow failed\n"),
                            -1);
        }

      CORBA::ContainedSeq_var cont = ifr->contents (CORBA::dk_all, 0);

      printContents (cont.in ());

      orb->destroy ();
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("main");
      return -1;
    }

  return 0;
}
Ejemplo n.º 3
0
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  try
  {
    CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);

    CORBA::Object_var obj =
      orb->resolve_initial_references("InterfaceRepository");

    CORBA::Repository_var ifrRepo = CORBA::Repository::_narrow(obj.in());

    if (CORBA::is_nil(ifrRepo.in()))
    {
      ACE_DEBUG((LM_ERROR,
        ACE_TEXT("(%N) failed to narrow interface repository referece.\n")
        ));
      return -1;
    }

    CORBA::ContainedSeq_var repoContents = ifrRepo->contents(CORBA::dk_all, 1);

    ACE_DEBUG((LM_INFO,
      ACE_TEXT("%s: the interface repository contains %d elements.\n"),
      programLabel,
      repoContents->length()
      ));
    listContents(repoContents.in());

    return 0;
  }
  catch(const CORBA::Exception& ex)
  {
    std::cerr << "main() Caught CORBA::Exception : " << ex << std::endl;
  }
  return 1;
}
Ejemplo n.º 4
0
void listContents(const CORBA::ContainedSeq& repoContents)
{
  //
  // List the contents of each element.
  //
  for(unsigned int i = 0; i < repoContents.length(); ++i)
  {
    CORBA::Contained::Description_var desc = repoContents[i]->describe();
    switch(desc->kind)
    {
    case CORBA::dk_Constant:
      ACE_DEBUG((LM_INFO,
        ACE_TEXT("%s: element[%d] is a constant definition.\n"),
        programLabel,
        i + 1
        ));
      break;
    case CORBA::dk_Typedef:
      ACE_DEBUG((LM_INFO,
        ACE_TEXT("%s: element[%d] is a typedef definition.\n"),
        programLabel,
        i + 1
        ));
      break;
    case CORBA::dk_Exception:
      ACE_DEBUG((LM_INFO,
        ACE_TEXT("%s: element[%d] is an exception definition.\n"),
        programLabel,
        i + 1
        ));
      break;
    case CORBA::dk_Interface:
      {
        ACE_DEBUG((LM_INFO,
          ACE_TEXT("%s: element[%d] is an interface definition.\n")
          ACE_TEXT("%s: listing element[%d]...\n"),
          programLabel,
          i + 1,
          programLabel,
          i + 1
          ));
        CORBA::InterfaceDef_var interfaceDef =
          CORBA::InterfaceDef::_narrow(repoContents[i]);
        listInterface(interfaceDef.in());
        break;
      }
    case CORBA::dk_Module: {
      ACE_DEBUG((LM_INFO,
        ACE_TEXT("%s: element[%d] is a module definition.\n"),
        programLabel,
        i + 1
        ));
      CORBA::ModuleDef_var moduleDef =
        CORBA::ModuleDef::_narrow(repoContents[i]);
      CORBA::ContainedSeq_var moduleContents =
        moduleDef->contents(CORBA::dk_all,1);
      CORBA::String_var moduleId = moduleDef->id();
      CORBA::String_var moduleName = moduleDef->name();

      ACE_DEBUG((LM_INFO,
        ACE_TEXT("%s:\n// %s\nmodule %s\n{\n")
        ACE_TEXT("%s: the module contains %d elements.\n"),
        programLabel,
        moduleId.in(),
        moduleName.in(),
        programLabel,
        moduleContents->length()
        ));
      listContents(moduleContents.in());
      ACE_DEBUG((LM_INFO, ACE_TEXT("}\n")));
      break;
                           }
    default:
      break;
    }
  }
}