Esempio n. 1
1
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      Server_ORBInitializer2 *temp_initializer = 0;
      ACE_NEW_RETURN (temp_initializer,
                      Server_ORBInitializer2,
                      -1);  // No exceptions yet!
      PortableInterceptor::ORBInitializer_var orb_initializer =
        temp_initializer;

      PortableInterceptor::register_orb_initializer (orb_initializer.in ());

      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

      CORBA::Object_var poa_object =
        orb->resolve_initial_references("RootPOA");

      PortableServer::POA_var root_poa =
        PortableServer::POA::_narrow (poa_object.in ());

      if (CORBA::is_nil (root_poa.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Panic: nil RootPOA\n"),
                          -1);

      PortableServer::POAManager_var poa_manager =
        root_poa->the_POAManager ();

      CORBA::PolicyList policies (2);
      policies.length (2);

      policies[0] =
        root_poa->create_id_assignment_policy (PortableServer::USER_ID);

      policies[1] =
        root_poa->create_lifespan_policy (PortableServer::PERSISTENT);

      PortableServer::POA_var my_poa =
        root_poa->create_POA ("my_poa",
                              poa_manager.in (),
                              policies);

      // Creation of the new POA is over, so destroy the Policy_ptr's.
      for (CORBA::ULong i = 0; i < policies.length (); ++i)
        {
          CORBA::Policy_ptr policy = policies[i];
          policy->destroy ();
        }


      if (parse_args (argc, argv) != 0)
        return -1;

      Hello *hello_impl = 0;
      ACE_NEW_RETURN (hello_impl,
                      Hello (orb.in (), Test::Hello::_nil (), my_id_number),
                      -1);
      PortableServer::ServantBase_var owner (hello_impl);

      PortableServer::ObjectId_var server_id =
        PortableServer::string_to_ObjectId ("server_id");

      my_poa->activate_object_with_id (server_id.in (),
                                       hello_impl);

      CORBA::Object_var hello =
        my_poa->id_to_reference (server_id.in ());

      CORBA::String_var ior =
        orb->object_to_string (hello.in ());

      // Output the IOR to the <ior_output_file>
      FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
      if (output_file == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot open output file for writing IOR: %s\n",
                           ior_output_file),
                           -1);
      ACE_OS::fprintf (output_file, "%s", ior.in ());
      ACE_OS::fclose (output_file);

      poa_manager->activate ();

      orb->run ();

      root_poa->destroy (1, 1);

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

  return 0;
}
Esempio n. 2
0
int main(int argc, char **argv) {
	QApplication App1(argc, argv);
	QPushButton Hello("Hello", 0);
	App1.setMainWidget(&Hello);
	Hello.show();
	return App1.exec();
}
Esempio n. 3
0
int main() {
    GoString gs = Hello();
    printf("str: %s\n", gs.p);
    printf("n: %d\n", (int)gs.n);
    getchar();
    return 0;
}
Esempio n. 4
0
/* show "welcome [back] to DynaHack" message at program startup */
static void welcome(
    boolean new_game)	/* false => restoring an old game */
{
    char buf[BUFSZ];
    boolean currentgend = Upolyd ? u.mfemale : flags.female;

    /*
     * The "welcome back" message always describes your innate form
     * even when polymorphed or wearing a helm of opposite alignment.
     * Alignment is shown unconditionally for new games; for restores
     * it's only shown if it has changed from its original value.
     * Sex is shown for new games except when it is redundant; for
     * restores it's only shown if different from its original value.
     */
    *buf = '\0';
    if (new_game || u.ualignbase[A_ORIGINAL] != u.ualignbase[A_CURRENT])
	sprintf(eos(buf), "%s", align_str(u.ualignbase[A_ORIGINAL]));
    if (!urole.name.f &&
	    (new_game ? (urole.allow & ROLE_GENDMASK) == (ROLE_MALE|ROLE_FEMALE) :
	     currentgend != u.initgend))
	sprintf(eos(buf), "%s", genders[currentgend].adj + 2);

    pline(new_game ? "%s,%s,欢迎来到LoongHack!  你是%s%s%s。"
		   : "%s,%s,%s%s%s,欢迎回到LoongHack!",
	  Hello(NULL), plname, buf, urace.adj,
	  (currentgend && urole.name.f) ? urole.name.f : urole.name.m + 2);

    if (*level->levname)
	pline("You named this level: %s.", level->levname);
}
Esempio n. 5
0
Test::Hello_var
prepare_tests (CORBA::ORB_ptr orb, PortableServer::POA_ptr root_poa)
{
  register_factories(orb);

  CORBA::Object_var objectman =
    orb->resolve_initial_references ("ORBPolicyManager");

  CORBA::PolicyManager_var policy_manager =
    CORBA::PolicyManager::_narrow (objectman.in ());

  PortableServer::POA_var my_compress_poa = 0;
  CORBA::PolicyList policies(4);
  policies.length(4);

  try
    {
      policies[0] = create_compressor_id_level_list_policy (orb);
      policies[1] = create_low_value_policy (orb);
      policies[2] = create_compression_enabled_policy (orb);
      policies[3] = create_min_ratio_policy (orb);

      my_compress_poa = root_poa->create_POA("My_Compress_Poa", 0, policies);
    }
  catch(const CORBA::PolicyError&)
    {
      policies.length(0);
      my_compress_poa = root_poa->create_POA("My_Compress_Poa", 0, policies);
    }

  policy_manager->set_policy_overrides (policies, CORBA::ADD_OVERRIDE);

  CORBA::Object_var pcobject =
    orb->resolve_initial_references ("PolicyCurrent");

  CORBA::PolicyCurrent_var policy_current =
    CORBA::PolicyCurrent::_narrow (pcobject.in ());

  policy_current->set_policy_overrides (policies, CORBA::ADD_OVERRIDE);

  PortableServer::POAManager_var poa_manager = my_compress_poa->the_POAManager ();

  Hello *hello_impl = 0;
  ACE_NEW_RETURN (hello_impl,
                  Hello (orb),
                  0);
  PortableServer::ServantBase_var owner_transfer(hello_impl);

  PortableServer::ObjectId_var id =
    my_compress_poa->activate_object (hello_impl);

  CORBA::Object_var object = my_compress_poa->id_to_reference (id.in ());

  Test::Hello_var hello = Test::Hello::_narrow (object.in ());

  poa_manager->activate ();

  return hello._retn ();
}
Esempio n. 6
0
    void testMultipleSlotConnections()
    {
        boost::signals2::signal<void ()> sig;

        sig.connect(Hello());
        sig.connect(World());

        sig();
    }
Esempio n. 7
0
int main(int argc, char* argv[])
{
    int thread_count = strtol(argv[1], NULL, 10);

# pragma omp parallel num_threads(thread_count)
    Hello();

    return 0;
}
Esempio n. 8
0
int
main (int argc, char *argv[])
{
	try {
		CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "");

		CORBA::Object_var poa_object = orb->resolve_initial_references("RootPOA");

		PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in ());

		if (CORBA::is_nil (root_poa.in ()))
			ACE_ERROR_RETURN ((LM_ERROR,
					   " (%N|%l) Panic: nil RootPOA\n"),
					  1);

		PortableServer::POAManager_var poa_manager = root_poa->the_POAManager ();

		Hello *hello_impl;
		ACE_NEW_RETURN (hello_impl,
				Hello (orb.in ()),
				1);
		PortableServer::ServantBase_var owner_transfer(hello_impl);

		Test::Hello_var hello =	hello_impl->_this ();

		//
		// Register the server object in the IOR table
		//

		// Turn the object reference into an IOR string
		CORBA::String_var ior_string = orb->object_to_string(hello.in());

		// Get a reference to the IOR Table and bind the hello object
		CORBA::Object_var table_obj = orb->resolve_initial_references("IORTable");
		IORTable::Table_var ior_table = IORTable::Table::_narrow(table_obj.in());
		ior_table->bind(::Test::Hello::IOR_TABLE_KEY, ior_string.in());

		poa_manager->activate ();

		ACE_DEBUG ((LM_DEBUG, "(%N|%l) server - event loop beginning\n"));

		orb->run ();

		ACE_DEBUG ((LM_DEBUG, "(%N|%l) server - event loop finished\n"));

		root_poa->destroy (1, 1);

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

	return 0;
}
void StepManiaLanServer::ParseData(PacketFunctions& Packet, const unsigned int clientNum)
{
	int command = Packet.Read1();
	switch (command)
	{
	case NSCPing:
		// No Operation
		SendValue(NSServerOffset + NSCPingR, clientNum);
		break;
	case NSCPingR:
		// No Operation response
		break;
	case NSCHello:
		// Hello
		Hello(Packet, clientNum);
		break;
	case NSCGSR:
		// Start Request
		Client[clientNum]->StartRequest(Packet);
		CheckReady();  //This is what ACTUALLY starts the games
		break;
	case NSCGON:
		// GameOver 
		GameOver(Packet, clientNum);
		break;
	case NSCGSU:
		// StatsUpdate
		Client[clientNum]->UpdateStats(Packet);
		if (!Client[clientNum]->lowerJudge)
			CheckLowerJudge(clientNum);
		break;
	case NSCSU:
		// Style Update
		Client[clientNum]->StyleUpdate(Packet);
		SendUserList();
		break;
	case NSCCM:
		// Chat message
		AnalizeChat(Packet, clientNum);
		break;
	case NSCRSG:
		SelectSong(Packet, clientNum);
		break;
	case NSCSMS:
		ScreenNetMusicSelectStatus(Packet, clientNum);
		break;
	case NSCUPOpts:
		Client[clientNum]->Player[0].options = Packet.ReadNT();		
		Client[clientNum]->Player[1].options = Packet.ReadNT();		
		break;
	default:
		break;
	}
}	 
Esempio n. 10
0
int
Server_Task::svc (void)
{
    try
    {
        CORBA::Object_var poa_object =
            this->sorb_->resolve_initial_references("RootPOA");

        PortableServer::POA_var root_poa =
            PortableServer::POA::_narrow (poa_object.in ());

        if (CORBA::is_nil (root_poa.in ()))
            ACE_ERROR_RETURN ((LM_ERROR,
                               " (%P|%t) Panic: nil RootPOA\n"),
                              1);

        PortableServer::POAManager_var poa_manager =
            root_poa->the_POAManager ();

        Hello *hello_impl = 0;
        ACE_NEW_RETURN (hello_impl,
                        Hello (this->sorb_.in (),
                               ACE_Thread::self ()),
                        1);

        PortableServer::ServantBase_var owner_transfer(hello_impl);

        Test::Hello_var hello =
            hello_impl->_this ();

        CosNaming::NamingContext_var example_nc;
        CosNaming::Name name;
        name.length(1);
        name[0].id = CORBA::string_dup("Hello");
        root_context_->rebind(name, hello.in());

        poa_manager->activate ();

        // Signal the main thread before we call orb->run ();
        this->me_.signal ();

        ACE_Time_Value runtime (10);
        this->sorb_->run (runtime);

        ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));
    }
    catch (const CORBA::Exception& ex)
    {
        ex._tao_print_exception ("Exception caught:");
        return 1;
    }

    return 0;
}
void main(){
for(i=0;i<3;i++){
	for(j=0;j<5;j++){
   		s+=a[j][i];
  	}
  	v[i]=s/5;
   	s=0;
}
int av=Hello();
	printf("total:%d\n",av);
	return 0;
}
    virtual void hello(const Hello_t & arg)
    {
        // Header
        wsa_.request(TO_TS_URL, SOAP_NAMESPACE_OF_wsd"/Hello");
        wsa_.addAppSequence();

        // Body
        Wsa::Request<wsd__HelloType> req(RemoteDiscoveryBindingProxy::soap, arg);
        req.MetadataVersion = arg.version;
        if (Hello(&req, NULL) != 0)
            throw SoapException(RemoteDiscoveryBindingProxy::soap);
    }
int main()
{
//[ hello_world_multi_code_snippet
  boost::signals2::signal<void ()> sig;

  sig.connect(Hello());
  sig.connect(World());

  sig();
//]

  return 0;
};
Esempio n. 14
0
/*ARGSUSED*/
STATIC_OVL void
newmail(struct mail_info *info)
{
    struct monst *md;
    coord start, stop;
    boolean message_seen = FALSE;

    /* Try to find good starting and stopping places. */
    if (!md_start(&start) || !md_stop(&stop,&start)) goto give_up;

    /* Make the daemon.  Have it rush towards the hero. */
    if (!(md = makemon(&mons[PM_MAIL_DAEMON], start.x, start.y, NO_MM_FLAGS)))
        goto give_up;
    if (!md_rush(md, stop.x, stop.y)) goto go_back;

    message_seen = TRUE;
    verbalize("%s, %s!  %s.", Hello(md), plname, info->display_txt);

    if (info->message_typ) {
        struct obj *obj = mksobj(SCR_MAIL, FALSE, FALSE);
        if (info->message_typ == MSG_HINT) obj->spe = MAIL_HINT;
        if (distu(md->mx,md->my) > 2)
            verbalize("Catch!");
        display_nhwindow(WIN_MESSAGE, FALSE);
        if (info->object_nam) {
            obj = oname(obj, info->object_nam);
            if (info->response_cmd) {	/*(hide extension of the obj name)*/
                int namelth = info->response_cmd - info->object_nam - 1;
                if ( namelth <= 0 || namelth >= (int) obj->onamelth )
                    warning("mail delivery screwed up");
                else
                    *(ONAME(obj) + namelth) = '\0';
                /* Note: renaming object will discard the hidden command. */
            }
        }
        obj = hold_another_object(obj, "Oops!",
                                  (const char *)0, (const char *)0);
    }

    /* zip back to starting location */
go_back:
    (void) md_rush(md, start.x, start.y);
    mongone(md);
    /* deliver some classes of messages even if no daemon ever shows up */
give_up:
    if (!message_seen && info->message_typ == MSG_OTHER)
        pline("Hark!  \"%s.\"", info->display_txt);
}
Esempio n. 15
0
    void testOrderedSlotConnections()
    {
        boost::signals2::signal<void ()> sig;

        sig.connect(1, World()); // connect with group 1
        sig.connect(0, Hello()); // connect with group 0

        //sig.connect(GoodMorning(), boost::signals2::at_front);
        sig.connect(GoodMorning()); // ungrouped

        // slots are invoked this order:
        // 1) ungrouped slots connected with boost::signals2::at_front
        // 2) grouped slots according to ordering of their groups
        // 3) ungrouped slots connected with boost::signals2::at_back

        sig();
    }
Esempio n. 16
0
void CKadHandler::SendHello(CKadNode* pNode, CComChannel* pChannel, bool bReq)
{
	SKadData* pData = pChannel->GetData<SKadData>();

	CVariant Hello(CVariant::EMap);

	CVariant Addr;
	TMyAddressMap AddressMap = GetParent<CKademlia>()->Fwh()->AddrPool();
	for(TMyAddressMap::const_iterator I = AddressMap.begin(); I != AddressMap.end(); I++)
		Addr.Append(I->second.ToVariant());
	Hello["ADDR"] = Addr;

	pNode->SetLastHello();

	if(GetParent<CKademlia>()->Cfg()->GetBool("DebugRT"))
		LogLine(LOG_DEBUG, L"Sending 'Hello %s' to %s", bReq ? L"Request" : L"Response", pNode->GetID().ToHex().c_str());
	pChannel->QueuePacket(bReq ? KAD_HELLO_REQUEST : KAD_HELLO_RESPONSE, Hello);
}
Esempio n. 17
0
 void GboxInstance::HandleMessage(const pp::Var& var_message) {
   if (!var_message.is_string()) return;
   std::string message = var_message.AsString();
   pp::Var var_reply;
   if (message == kHelloString) {
     theLog.info("message: '%s'", message.c_str());
     Hello();
   } else if (message == kPaintMethodId) {
     Paint();
   } else if (message == kClockMethodId) {
     Clock();
   } else if (message == "quiet") {
     theLog.info("message: '%s'", message.c_str());
     Quiet();
   } else {
     theLog.info("other message: '%s'", message.c_str());
     Other(message);
   }
 }
Esempio n. 18
0
int main(int argc, char **argv)
{
  //
  //  If --enable-mpi, an MPI communicator is used, otherwise a serial
  //  stub communicator is used.  
  //
#ifdef EPETRA_MPI
  MPI_Init(&argc,&argv);
  Epetra_MpiComm Comm (MPI_COMM_WORLD);
#else
  Epetra_SerialComm Comm;
#endif

  //
  //  Print out a summary line followed by a "Hello" line from each process
  //

  if (Comm.MyPID()==0)
    cout << New_Package_Version() << endl << endl;

  Newp_Hello Hello( Comm ) ; 
  Hello.Print( cout );


  //
  //  If --enable-newp_swahili is set, HAVE_NEWP_SWAHILI is set in 
  //    New_Package_config.h which is included by Newp_Hello.h and hence:
  //      Print out a summary line followed by a "Jambo" line from each process
  //
#ifdef HAVE_NEWP_SWAHILI
  Newp_Jambo Jambo( Comm ) ; 
  Jambo.Print( cout );
#endif

#ifdef EPETRA_MPI
  MPI_Finalize();
#endif
  return 0;
}
Esempio n. 19
0
int main()
{
//[ hello_world_ordered_code_snippet
  boost::signals2::signal<void ()> sig;

  sig.connect(1, World());  // connect with group 1
  sig.connect(0, Hello());  // connect with group 0
//]

//[ hello_world_ordered_invoke_code_snippet
  // by default slots are connected at the end of the slot list
  sig.connect(GoodMorning());

  // slots are invoked this order:
  // 1) ungrouped slots connected with boost::signals2::at_front
  // 2) grouped slots according to ordering of their groups
  // 3) ungrouped slots connected with boost::signals2::at_back
  sig();
//]

  return 0;
};
Esempio n. 20
0
int
Server_Task::svc (void)
{
 try
   {
     CORBA::Object_var poa_object =
       this->sorb_->resolve_initial_references("RootPOA");

     PortableServer::POA_var root_poa =
       PortableServer::POA::_narrow (poa_object.in ());

     if (CORBA::is_nil (root_poa.in ()))
       ACE_ERROR_RETURN ((LM_ERROR,
                          " (%P|%t) Panic: nil RootPOA\n"),
                         1);

     PortableServer::POAManager_var poa_manager =
       root_poa->the_POAManager ();

     Hello *hello_impl;
     ACE_NEW_RETURN (hello_impl,
                     Hello (this->sorb_.in (),
                            ACE_Thread::self ()),
                     1);

     PortableServer::ServantBase_var owner_transfer(hello_impl);

     PortableServer::ObjectId_var id =
       root_poa->activate_object (hello_impl);

     CORBA::Object_var object = root_poa->id_to_reference (id.in ());

     Test::Hello_var hello =
       Test::Hello::_narrow (object.in ());

     CORBA::String_var ior =
       this->sorb_->object_to_string (hello.in ());

     // Output the IOR to the <this->output_>
     FILE *output_file= ACE_OS::fopen (this->output_,
                                       "w");
     if (output_file == 0)
       ACE_ERROR_RETURN ((LM_ERROR,
                          "Cannot open output file for writing IOR: %s",
                          this->output_),
                         1);

     ACE_OS::fprintf (output_file, "%s", ior.in ());
     ACE_OS::fclose (output_file);

     poa_manager->activate ();

     // Signal the main thread before we call orb->run ();
     this->me_.signal ();

     this->sorb_->run ();

     ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));

     root_poa->destroy (1, 1);

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

 return 0;
}
Esempio n. 21
0
int main(int argc, char **argv)
{
    Hello();

    return 0;
}
Esempio n. 22
0
int _stdc main(int argc, char *argv[])
{
  char *p;

  NW(__fd2n);

#if defined(__FLAT__) && !defined(UNIX)
  Hello("SQUISH/386", "SquishMail Conference Processor", version, "1990, " THIS_YEAR);
#elif defined(LINUX)
  Hello("SQUISH/LINUX", "SquishMail Conference Processor", version, "1990, " THIS_YEAR);
#elif defined(UNIX)
  Hello("SQUISH/UNIX", "SquishMail Conference Processor", version, "1990, " THIS_YEAR);
#else
  Hello("SQUISH", "SquishMail Conference Processor", version, "1990, " THIS_YEAR);
#endif

#ifdef OS_2 /* Serialize Squish's execution */
  BbsSemSerialize("/sem/squish/default", "BBSSEM");
#endif

#ifdef __WATCOMC__
  setbuf(stdout, NULL);
#endif

#ifdef DMALLOC
  /*dmalloc_on(TRUE);*/
#endif

#ifdef DJ
  dj=fopen("dj.log", "a");
#endif

#ifdef UNIX
  if (!getenv("SQUISH"))
    putenv("SQUISH=" INSTALL_PREFIX "/etc/squish.cfg");
#endif

  if (!fexist(ar.cfgname) && (p=getenv("SQUISH")) != NULL)
    (void)strcpy(ar.cfgname, p);

#if defined(__MSDOS__) && !defined(__FLAT__)
  install_24();
  (void)atexit(uninstall_24);
#endif

  if (argc < 2)
    usage();
    
  Initialize_Variables();

  /* Use the SQUISH environment variable to locate config file, if necessary */

  p=getenv("SQUISH");

  if (p && !fexist(ar.cfgname)) /* as long as there's no squish.cfg in cwd */
    (void)strcpy(ar.cfgname, p);

  ParseArgs(&ar, (byte **)argv);   /* Command-line arguments */
/*  strcpy(ar.cfgname,"Squish.Cfg");*/

  Parse_Config(ar.cfgname);  /* parse squish.cfg and areas.bbs */

/*
  {
    NETADDR bill={1,249,1,0};

    if (DestIsHereA(&bill))
      printf("!!! This copy of Squish is registered to Bill Cassidy !!!\n");
  }
*/

  Parse_Areas(*ar.areasbbs ? ar.areasbbs : config.areasbbs);

  /* If a log-file override was specified on the command line */

  if (*ar.logfile)
  {
    if (config.logfile)
      free(config.logfile);

    config.logfile=sstrdup(ar.logfile);
  }

  InitializeConfig();     /* Initialize configuration */

  if (ar.action==ACTION_GET || ar.action==ACTION_SEND ||
      ar.action==ACTION_UPDATE || ar.action==ACTION_POLL)
  {
    config.flag &= ~FLAG_ADDMODE;
    HandleAttReqPoll(ar.action, ar.toscan);
  }
  else SquishSquashCycle();

#ifdef DJ
  if (dj)
    fclose(dj);
#endif

  CleanupConfig();

  (void)printf("\n" SQNAME ": Done!\n");

  return (erl_max ? ERL_MAXMSGS : erl_echo ? ERL_TOSS_ECHO :
          erl_net ? ERL_TOSS_NET : erl_sent ? ERL_SENT_ECHO :
          ERL_NONE);
}
Esempio n. 23
0
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - ORB_init\n"));
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - Obtain RootPOA\n"));
      CORBA::Object_var poa_object =
        orb->resolve_initial_references("RootPOA");

      PortableServer::POA_var root_poa =
        PortableServer::POA::_narrow (poa_object.in ());

      if (CORBA::is_nil (root_poa.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Panic: nil RootPOA\n"),
                          1);

      PortableServer::POAManager_var poa_manager = root_poa->the_POAManager ();

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - parse args\n"));
      if (parse_args (argc, argv) != 0)
        return 1;

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - init hello\n"));
      Hello *hello_impl = 0;
      ACE_NEW_RETURN (hello_impl,
                      Hello (orb.in ()),
                      1);
      PortableServer::ServantBase_var owner_transfer(hello_impl);

      PortableServer::ObjectId_var id =
        root_poa->activate_object (hello_impl);

      CORBA::Object_var object = root_poa->id_to_reference (id.in ());

      Test::Hello_var hello = Test::Hello::_narrow (object.in ());

      CORBA::String_var ior = orb->object_to_string (hello.in ());

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - Create the forwarding loop\n"));
      CORBA::Object_var iorTableObj =
            orb->resolve_initial_references ("IORTable");

      IORTable::Table_var iorTable
          = IORTable::Table::_narrow (iorTableObj.in ());

      // We are using this test with ObjRefStyle == URL ... or at
      // least we better be. The IOR is therefore a corbaloc
      ACE_CString full_corbaloc (ior.in (), 0, 1);

      // Create a corbaloc for an IOR table binding that points to
      // itself. Acessing this will  make the server reply with LOCATION_FORWARD
      // indefinitely.

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - Corbaloc is\n  \"%C\"\n", full_corbaloc.c_str()));
      // Get the endpoint info only...
      CORBA::ULong first_slash = full_corbaloc.find ("/", 0);
      ACE_CString forward_forever = full_corbaloc.substring (0,
                                                             first_slash);

      // .. add the string we are going to bind against and then bind
      forward_forever += "/hello";
      iorTable->bind("hello", forward_forever.c_str ());

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - Forward forever is\n  \"%C\"\n", forward_forever.c_str()));
      // Output the IORs
      FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
      if (output_file == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot open output file for writing IOR: %s\n",
                           ior_output_file),
                           1);
      ACE_OS::fprintf (output_file, "%s", ior.in ());
      ACE_OS::fclose (output_file);

      output_file = ACE_OS::fopen (ior_output_file2, "w");
      if (output_file == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot open output file for writing IOR: %s\n",
                           ior_output_file2),
                           1);
      ACE_OS::fprintf (output_file, "%s", forward_forever.c_str ());
      ACE_OS::fclose (output_file);

      poa_manager->activate ();

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - orb->run()\n"));
      orb->run ();

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));

      root_poa->destroy (1, 1);

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

  return 0;
}
Esempio n. 24
0
int
Server_Worker::test_main (int argc, ACE_TCHAR *argv[])
{
  try
    {
      // Making sure there are no stale ior files to confuse a client
      ACE_OS::unlink (ior_file_.c_str ());

      CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);

      CORBA::Object_var poa_object =
        orb->resolve_initial_references ("RootPOA");

      PortableServer::POA_var root_poa =
        PortableServer::POA::_narrow (poa_object.in ());

      if (CORBA::is_nil (root_poa.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                          ACE_TEXT ("(%P|%t) Panic: nil RootPOA\n")),
                          1);

      PortableServer::POAManager_var poa_manager =
        root_poa->the_POAManager ();

      if (parse_args (argc, argv) != 0)
        return 1;

      Hello *hello_impl;
      ACE_NEW_RETURN (hello_impl,
                      Hello (orb.in ()),
                      1);

      PortableServer::ServantBase_var owner_transfer (hello_impl);

      PortableServer::ObjectId_var id =
        root_poa->activate_object (hello_impl);

      CORBA::Object_var hello_obj =
        root_poa->id_to_reference (id.in ());

      Test::Hello_var hello =
        Test::Hello::_narrow (hello_obj.in ());

      CORBA::String_var ior =
        orb->object_to_string (hello.in ());

      poa_manager->activate ();

      ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Server activated POA manager\n")));

      // Output the IOR to the <ior_output_file>
      FILE *output_file= ACE_OS::fopen (ior_file_.c_str (), "w");
      if (output_file == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                          ACE_TEXT ("(%P|%t) Cannot open output file %s for writing IOR: %C"),
                          ior_file_.c_str (),
                          ior.in ()),
                          1);
      ACE_OS::fprintf (output_file, "%s", ior.in ());
      ACE_OS::fclose (output_file);

      ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Server entering the event loop\n")));

      orb->run ();

      ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Server exiting the event loop\n")));

      root_poa->destroy (1, 1);

      // During normal test execution the ORB would have been destroyed
      // by a request from the client.

      //  orb->shutdown (0);

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

  return 0;
}
Esempio n. 25
0
int main(int argc, char const *argv[])
{
    Hello();
    return 0;
}
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

      if (parse_args(argc, argv) != 0)
          return 1;

      CORBA::Object_var poa_object =
        orb->resolve_initial_references("RootPOA");

      PortableServer::POA_var root_poa =
        PortableServer::POA::_narrow (poa_object.in ());

      if (CORBA::is_nil (root_poa.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Panic: nil RootPOA\n"),
                          1);

      Hello *hello_impl = 0;
      ACE_NEW_RETURN (hello_impl,
                      Hello (orb.in ()),
                      1);

      PortableServer::ObjectId_var id =
        root_poa->activate_object (hello_impl);

      CORBA::Object_var object = root_poa->id_to_reference (id.in ());

      Test::Hello_var hello = Test::Hello::_narrow (object.in ());

      CORBA::Object_var table_obj = orb->resolve_initial_references("IORTable");
      IORTable::Table_var table = IORTable::Table::_narrow(table_obj.in());
      for (int i = 1; i <= cache_size; ++i)
        {
          CORBA::String_var ior_string = orb->object_to_string (object.in());
          ACE_DEBUG((LM_DEBUG, ACE_TEXT("Registering object %d with IOR string: %C\n"),
            i, ior_string.in ()));
          char identifier[256];
          ACE_OS::sprintf (identifier, "TransportCacheTest%d", i);
          table->bind(identifier, ior_string.in());
        }

      PortableServer::POAManager_var poa_manager = root_poa->the_POAManager ();
      poa_manager->activate ();

      orb->run ();

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));

      root_poa->destroy (1, 1);

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

  return 0;
}
Esempio n. 27
0
void Hello(void)
{
   int array[512];
   printf("Hello, &array=%d\n", &array);
   Hello(); 
}
Esempio n. 28
0
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  int idle_count = 0;
  try
    {
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

      CORBA::Object_var poa_object =
        orb->resolve_initial_references("RootPOA");

      PortableServer::POA_var root_poa =
        PortableServer::POA::_narrow (poa_object.in ());

      if (CORBA::is_nil (root_poa.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Panic: nil RootPOA\n"),
                          1);

      PortableServer::POAManager_var poa_manager = root_poa->the_POAManager ();

      if (parse_args (argc, argv) != 0)
        return 1;

      Hello *hello_impl = 0;
      ACE_NEW_RETURN (hello_impl,
                      Hello (orb.in ()),
                      1);
      PortableServer::ServantBase_var owner_transfer(hello_impl);

      PortableServer::ObjectId_var id =
        root_poa->activate_object (hello_impl);

      CORBA::Object_var object = root_poa->id_to_reference (id.in ());

      Test::Hello_var hello = Test::Hello::_narrow (object.in ());

      CORBA::String_var ior = orb->object_to_string (hello.in ());

      // Output the IOR to the <ior_output_file>
      FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
      if (output_file == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot open output file for writing IOR: %s\n",
                           ior_output_file),
                           1);
      ACE_OS::fprintf (output_file, "%s", ior.in ());
      ACE_OS::fclose (output_file);

      poa_manager->activate ();

      for (;;)
      {
        ACE_Time_Value tv (0, 500);
        while (orb->work_pending (tv))
          {
            ACE_DEBUG ((LM_DEBUG, "Work pending\n"));
            ACE_Time_Value tv2 (0, 500);
            if (orb->work_pending (tv2))
              {
                ACE_Time_Value work_tv (0, 500);
                orb->perform_work (work_tv);
              }
          }
        ++idle_count;
      }

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

  if (idle_count == 0)
    {
      ACE_ERROR_RETURN ((LM_ERROR, "ERROR: Got unexpected idle_count %d\n", idle_count), 1);
    }
  else
    {
      ACE_DEBUG ((LM_DEBUG, "Got %d idle moments\n", idle_count));
    }

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

      CORBA::Object_var poa_object =
        orb->resolve_initial_references("RootPOA");

      PortableServer::POA_var root_poa =
        PortableServer::POA::_narrow (poa_object.in ());

      if (CORBA::is_nil (root_poa.in ()))
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Panic: nil RootPOA\n"),
                          1);

      PortableServer::POAManager_var poa_manager =
        root_poa->the_POAManager ();

      if (parse_args (argc, argv) != 0)
        return 1;

      Hello *hello_impl;
      ACE_NEW_RETURN (hello_impl,
                      Hello (orb.in ()),
                      1);
      PortableServer::ServantBase_var owner_transfer(hello_impl);

      PortableServer::ObjectId_var id =
        root_poa->activate_object (hello_impl);

      CORBA::Object_var object = root_poa->id_to_reference (id.in ());

      Test::Hello_var hello =
        Test::Hello::_narrow (object.in ());

      CORBA::String_var ior =
        orb->object_to_string (hello.in ());

      // Output the IOR to the <ior_output_file>
      FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
      if (output_file == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Cannot open output file for writing IOR: %s",
                           ior_output_file),
                              1);
      ACE_OS::fprintf (output_file, "%s", ior.in ());
      ACE_OS::fclose (output_file);

      poa_manager->activate ();

      orb->run ();

      ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));

      root_poa->destroy (1, 1);

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

  return 0;
}
Esempio n. 30
0
int main()
{
   Function<void(*)()> fu(func1);
   eval(fu);

   Function<bool(*)(int, double&)> f(func);
   double y = 3.1415;
   std::cout << f(42, y) << std::endl;

   Function<void(Hello::*)(int)const> f1(&Hello::sayHello);
   Hello h;
   const Hello* h1 = &h;
   f1(*h1, 42);

   // get rid of this template arguments if possible...
   eval(bind(&Hello::sayHello1, ref(h)));
   double x = 3.1415;
   eval(bind(func, 3, x));
   std::cout << x << std::endl;

   x = 6.666667;
   bind(func, 4, _1)(x);
   std::cout << x << std::endl;

   bind(&Hello::sayHello, ref(h), 23)();
   bind(&Hello::sayHello, ref(h), _1)(33);
   bind(&Hello::sayHello, _1, 24)(h);  // FIXME here no pointer possible
   bind(&Hello::sayHello, _1, _2)(h, 22);

   std::vector<int> iv;
   iv.push_back(2);
   iv.push_back(4);
   iv.push_back(3);
   iv.push_back(1);
   std::for_each(iv.begin(), iv.end(), bind(printx, "%d\n", _1));
   
   double d = 123.123;
   Hello h2(42);   
   
   bind(&Hello::sayHello3, _1, 42, _2)(h2, d);
   std::cout << "d=" << d << std::endl;

   std::vector<Hello> hv;
   hv.push_back(Hello());
   hv.push_back(Hello());
   std::for_each(hv.begin(), hv.end(), bind(&Hello::doIt, _1)); 
   
   Function<bool(*)(double& d)> bf;
   std::cout << !!bf << std::endl;
   bf = bind(func, 4, _1);
   std::cout << !!bf << std::endl;
   d = 7.777;
   bf(d);   
   
   Function<void(*)(Hello&, double&)> bf1(bind(&Hello::sayHello3, _1, 42, _2));
   bf1(h, d);
   
   bind(f4, _2, _3, _4, _1)(1, 2, 3, 4);   
   
   std::vector<Hello*> hv1;
   hv1.push_back(new Hello(42));
   std::for_each(hv1.begin(), hv1.end(), bind(&Hello::sayHello, _1, 23));
   
   bind(&Hello::sayHello, hv1.front(), _1)(23);
   
   // FIXME any smart pointer does not work here!
   std::auto_ptr<Hello> ah(new Hello(11));
   Function<void(Hello::*)(int, double&)> fu1(&Hello::sayHello3);
   fu1(*ah, 42, d);
   
   return 0;
}