ALMA Computing Group

acsexmplClientHelloWorld.cpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002 *    ALMA - Atacama Large Millimiter Array
00003 *    (c) European Southern Observatory, 2002
00004 *    Copyright by ESO (in the framework of the ALMA collaboration)
00005 *    and Cosylab 2002, All rights reserved
00006 *
00007 *    This library is free software; you can redistribute it and/or
00008 *    modify it under the terms of the GNU Lesser General Public
00009 *    License as published by the Free Software Foundation; either
00010 *    version 2.1 of the License, or (at your option) any later version.
00011 *
00012 *    This library is distributed in the hope that it will be useful,
00013 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 *    Lesser General Public License for more details.
00016 *
00017 *    You should have received a copy of the GNU Lesser General Public
00018 *    License along with this library; if not, write to the Free Software
00019 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00020 *
00021 *
00022 *
00023 * "@(#) $Id: acsexmplClientHelloWorld.cpp,v 1.7 2007/02/01 05:14:26 cparedes Exp $"
00024 *
00025 * who       when      what
00026 * --------  --------  ----------------------------------------------
00027 * david 2002-10-31 created
00028 */
00029 
00053 
00058 
00094 /* @}*/
00095 /* @}*/
00096 
00097 #include <maciSimpleClient.h>
00098 #include <acsexmplHelloWorldC.h>
00099 #include <ACSErrTypeCommon.h>
00100 #include <acsutilTimeStamp.h>
00101 
00102 ACE_RCSID(acsexmpl, acsexmplHelloWorldClient, "$Id: acsexmplClientHelloWorld.cpp,v 1.7 2007/02/01 05:14:26 cparedes Exp $")
00103 using namespace maci;
00104 
00105 /*******************************************************************************/
00108 int main(int argc, char *argv[])
00109 {
00110     SimpleClient client;
00111     acsexmplHelloWorld::HelloWorld_var foo;
00112 
00113 // Creates and initializes the SimpleClient object
00114 
00115     if (client.init(argc,argv) == 0)
00116         {
00117         return -1;
00118         }
00119     else
00120         {
00121         //Must log into manager before we can really do anything
00122         client.login();
00123         }
00124    
00125     try
00126         {
00127         //Get the specific component we have requested on the command-line
00128         foo = client.getComponent<acsexmplHelloWorld::HelloWorld>(argv[1], 0, true);
00129         }
00130     catch(maciErrType::CannotGetComponentExImpl &_ex)
00131         {
00132         _ex.log();
00133         return -1;
00134         }
00135     
00136     
00137     //Call the displayMessage() method existing in the interface for HelloWorld
00138     foo->displayMessage();
00139     
00140     try
00141         {
00142         foo->badMethod();
00143         }
00144     catch(ACSErrTypeCommon::UnknownEx &ex)
00145         {
00146         ACSErrTypeCommon::UnknownExImpl badMethodEx(ex);
00147         badMethodEx.log();
00148         ACS::Time timeStamp = badMethodEx.getTimeStamp();
00149         ACE_CString tString = getStringifiedUTC(timeStamp);
00150         ACS_DEBUG_PARAM(argv[0], "Time of the exception: %s\n", tString.c_str());
00151         }
00152 
00153     //We release our component and logout from manager
00154     try
00155         {
00156         client.releaseComponent(argv[1]);
00157         }
00158     catch(maciErrType::CannotReleaseComponentExImpl &_ex)
00159         {
00160         _ex.log();
00161         return -1;
00162         }
00163     
00164     client.logout();
00165     
00166     //Sleep for 3 sec to allow everytihng to cleanup and stablize
00167     ACE_OS::sleep(3);
00168     return 0;
00169 }
00172 /*___oOo___*/
00173 
00174 
00175