ALMA Computing Group

acsexmplClientHelloWorldSP.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: acsexmplClientHelloWorldSP.cpp,v 1.1 2007/03/06 08:47:50 agrimstrup Exp $" 00024 * 00025 * who when what 00026 * -------- -------- ---------------------------------------------- 00027 * david 2002-10-31 created 00028 */ 00029 00053 00058 00096 /* @}*/ 00097 /* @}*/ 00098 00099 #include <iostream> 00100 #include <maciSimpleClient.h> 00101 #include <acsexmplHelloWorldC.h> 00102 #include <ACSErrTypeCommon.h> 00103 #include <acsutilTimeStamp.h> 00104 00105 ACE_RCSID(acsexmpl, acsexmplHelloWorldClient, "$Id: acsexmplClientHelloWorldSP.cpp,v 1.1 2007/03/06 08:47:50 agrimstrup Exp $") 00106 using namespace maci; 00107 00108 /*******************************************************************************/ 00111 int main(int argc, char *argv[]) 00112 { 00113 SimpleClient client; 00114 int ret; 00115 00116 // Creates and initializes the SimpleClient object 00117 00118 std::cout << "Initializing client..." << std::endl; 00119 std::cout.flush(); 00120 if (client.init(argc,argv) == 0) return -1; 00121 00122 //Must log into manager before we can really do anything 00123 client.login(); 00124 00125 try 00126 { 00127 ComponentSmartPtr<acsexmplHelloWorld::HelloWorld> foo; 00128 //Get the specific component we have requested on the command-line 00129 foo = client.getComponentSmartPtr<acsexmplHelloWorld::HelloWorld>(argv[1], 0, true); 00130 00131 //Call the displayMessage() method existing in the interface for HelloWorld 00132 foo->displayMessage(); 00133 00134 try 00135 { 00136 foo->badMethod(); 00137 } 00138 catch(ACSErrTypeCommon::UnknownEx &ex) 00139 { 00140 ACSErrTypeCommon::UnknownExImpl badMethodEx(ex); 00141 badMethodEx.log(); 00142 ACS::Time timeStamp = badMethodEx.getTimeStamp(); 00143 ACE_CString tString = getStringifiedUTC(timeStamp); 00144 ACS_DEBUG_PARAM(argv[0], "Time of the exception: %s\n", tString.c_str()); 00145 } 00146 00147 ret = 0; 00148 } 00149 catch(maciErrType::CannotGetComponentExImpl &_ex) 00150 { 00151 _ex.log(); 00152 ret = -1; 00153 } 00154 00155 client.logout(); 00156 00157 //Sleep for 3 sec to allow everytihng to cleanup and stablize 00158 ACE_OS::sleep(3); 00159 00160 return 0; 00161 } 00164 /*___oOo___*/ 00165 00166 00167