/******************************************************************************* * ALMA - Atacama Large Millimiter Array * (c) European Southern Observatory, 2002 * Copyright by ESO (in the framework of the ALMA collaboration) * and Cosylab 2002, All rights reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * * "@(#) $Id: acsexmplClientHelloWorld.cpp,v 1.7 2007/02/01 05:14:26 cparedes Exp $" * * who when what * -------- -------- ---------------------------------------------- * david 2002-10-31 created */ /** @file acsexmplClientHelloWorld.cpp * @htmlonly *

@endhtmlonly * @param "component name" Use this required parameter to specify which component * should be activated. * @htmlonly

@endhtmlonly * @param "-ORBEndpoint iiop://yyy:xxxx" Use this optional parameter to specify which host/port SimpleClient * should run on. * @htmlonly

@endhtmlonly * @param "-m corbaloc::yyy:xxxx/Manager" Use this optional parameter to specify where * manager is. * @htmlonly

@endhtmlonly */ /** @addtogroup ACSEXMPLTOC */ /*@{ */ /** @defgroup ACSEXMPLTOCCLIENTS Client Examples */ /*@{ */ /** @defgroup ACSEXMPLCLIENTHWDOC Client Hello World * @{ * @htmlonly

Description

This example shows a client that:

What can I gain from this example?



Links

@endhtmlonly * @} */ /* @}*/ /* @}*/ #include #include #include #include using namespace maci; /*******************************************************************************/ /** @cond */ int main(int argc, char *argv[]) { SimpleClient client; acsexmplHelloWorld::HelloWorld_var foo; // Creates and initializes the SimpleClient object if (client.init(argc,argv) == 0) { return -1; } else { //Must log into manager before we can really do anything client.login(); } try { //Get the specific component we have requested on the command-line foo = client.getComponent(argv[1], 0, true); } catch(maciErrType::CannotGetComponentExImpl &_ex) { _ex.log(); return -1; } //Call the displayMessage() method existing in the interface for HelloWorld foo->displayMessage(); try { foo->badMethod(); } catch(ACSErrTypeCommon::UnknownEx &ex) { ACSErrTypeCommon::UnknownExImpl badMethodEx(ex); badMethodEx.log(); ACS::Time timeStamp = badMethodEx.getTimeStamp(); ACE_CString tString = getStringifiedUTC(timeStamp); ACS_DEBUG_PARAM(argv[0], "Time of the exception: %s\n", tString.c_str()); } //We release our component and logout from manager try { client.releaseComponent(argv[1]); } catch(maciErrType::CannotReleaseComponentExImpl &_ex) { _ex.log(); return -1; } client.logout(); //Sleep for 3 sec to allow everytihng to cleanup and stablize ACE_OS::sleep(3); return 0; } /** @endcond */ /*___oOo___*/