Public Member Functions | Private Member Functions | Private Attributes

TAO::Utils::Server_Main< SERVANT > Class Template Reference

#include <Server_Main.h>

List of all members.

Public Member Functions

 Server_Main (const char *name)
 ~Server_Main ()
int run (int argc, ACE_TCHAR *argv[])

Private Member Functions

 Server_Main (const Server_Main &)
Server_Mainoperator= (const Server_Main &)

Private Attributes

const char * name_

Detailed Description

template<typename SERVANT>
class TAO::Utils::Server_Main< SERVANT >

Definition at line 70 of file Server_Main.h.


Constructor & Destructor Documentation

template<typename SERVANT >
TAO::Utils::Server_Main< SERVANT >::Server_Main ( const char *  name  ) 

Definition at line 30 of file Server_Main.cpp.

  : name_(name)
{
}

template<typename SERVANT >
TAO::Utils::Server_Main< SERVANT >::~Server_Main (  ) 

Definition at line 36 of file Server_Main.cpp.

{
}

template<typename SERVANT >
TAO::Utils::Server_Main< SERVANT >::Server_Main ( const Server_Main< SERVANT > &   )  [private]

Member Function Documentation

template<typename SERVANT >
Server_Main& TAO::Utils::Server_Main< SERVANT >::operator= ( const Server_Main< SERVANT > &   )  [private]
template<typename SERVANT >
int TAO::Utils::Server_Main< SERVANT >::run ( int  argc,
ACE_TCHAR argv[] 
)

Definition at line 42 of file Server_Main.cpp.

{
  int result = 0;
  // hide unicode if necessary.
  ACE_Argv_Type_Converter command_line (argc, argv);

  ACE_TCHAR ** asciiArgv = command_line.get_TCHAR_argv ();

  try
  {
    // Initialize the orb

    CORBA::ORB_var orb =
      CORBA::ORB_init (argc, asciiArgv, name_);

    if (! ::CORBA::is_nil(orb.in ()))
    {
      // create an instance of the servant object and give it a
      // chance at the arguments.
      SERVANT servant;
      result = servant.parse_args (argc, asciiArgv);
      if (result == 0)
      {
        //////////////////////////////////
        // let the servant register itself
        result = servant.init (orb.in ());

        if (result == 0)
        {
          ACE_ERROR ((LM_INFO,
            "%T %s (%P|%t) Ready %s\n", name_, servant.identity ()
            ));

          //////////////////////////////////
          // Run the event loop for the ORB.
          // Initial run to initialize the orb
          ACE_Time_Value tv (1,0);
          orb->run (tv);

          // now run event loop
          int quit = 0;
          while (result == 0 && ! quit )
          {
            ACE_Time_Value work_tv (1,0);
            orb->perform_work(work_tv);
            quit = servant.idle (result);
          }
          servant.fini ();

          orb->shutdown (1);

          ACE_ERROR ((LM_INFO,
                      "%T %s (%P|%t) Terminated normally. %s\n",
                      name_,
                      servant.identity ()
            ));
        }
        else
        {
          ACE_ERROR ((LM_ERROR,
            "%T %s (%P|%t) Registration failed: %m\n", name_
            ));
          result = -1;
        }
      }
      else
      {
        ACE_ERROR ((LM_ERROR,
          "%T %s (%P|%t) ORB manager init failed\n", name_
        ));
        result = -1;
      }
    }
  }
  catch (const ::CORBA::Exception& ex)
  {
    ex._tao_print_exception (name_);
    result = -1;
  }
  return result;
}


Member Data Documentation

template<typename SERVANT >
const char* TAO::Utils::Server_Main< SERVANT >::name_ [private]

Definition at line 83 of file Server_Main.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines