ALMA Computing Group

acsexmplClientListComponents.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 * "@(#) $Id: acsexmplClientListComponents.cpp,v 1.8 2007/02/01 05:14:26 cparedes Exp $" 00023 * 00024 * who when what 00025 * -------- -------- ---------------------------------------------- 00026 * david 2002-06-17 fixed client.init(argc,argv) 00027 * gchiozzi 2002-02-13 Cleaned up 00028 * msekoran 17/02/01 created 00029 */ 00030 00049 00054 00089 /* @}*/ 00090 /* @}*/ 00091 00092 #include <maciSimpleClient.h> 00093 00094 ACE_RCSID(acsexmpl, acsexmplListCOBS, "$Id: acsexmplClientListComponents.cpp,v 1.8 2007/02/01 05:14:26 cparedes Exp $") 00095 using namespace maci; 00096 00097 /*---------------------------------------------------------------------------------------*/ 00098 00101 int main(int argc, char *argv[]) 00102 { 00103 ACS_SHORT_LOG((LM_INFO, "Welcome to %s!", argv[0])); 00104 00105 //Creates and initializes the SimpleClient object 00106 SimpleClient client; 00107 if (client.init(argc,argv) == 0) 00108 { 00109 ACE_DEBUG((LM_DEBUG,"Cannot init client")); 00110 return -1; 00111 } 00112 else 00113 { 00114 //Must log into manager before we can really do anything 00115 client.login(); 00116 } 00117 00118 try 00119 { 00120 //Query the manager for a list of all components 00121 //and print infos for all of them 00122 maci::HandleSeq seq; 00123 //Invoke a manager method directly to obtain information on components. Please see the 00124 //doxygen-generated documentation for maci.idl for more detailed info. 00125 maci::ComponentInfoSeq_var devs = client.manager()->get_component_info(client.handle(), 00126 seq, 00127 "*", 00128 "*", 00129 false); 00130 00131 //Print some standard information about all components to standard out. 00132 ACS_SHORT_LOG((LM_INFO, "Listing all components known to manager:")); 00133 for (unsigned int i = static_cast<unsigned int>(0); i < devs->length (); i++) 00134 { 00135 ACS_SHORT_LOG((LM_INFO, "\tComponent: %s (type: %s)", devs[i].name.in(), devs[i].type.in())); 00136 } 00137 00138 //Logout from manager cleanly 00139 if(client.logout() == 0) 00140 { 00141 ACS_SHORT_LOG ((LM_INFO, "Cannot logout")); 00142 return -1; 00143 } 00144 } 00145 catch( CORBA::SystemException &_ex ) // can be thrown by get_component_infos 00146 { 00147 ACSErrTypeCommon::CORBAProblemExImpl corbaProblemEx(__FILE__, __LINE__, 00148 "main"); 00149 corbaProblemEx.setMinor(_ex.minor()); 00150 corbaProblemEx.setCompletionStatus(_ex.completed()); 00151 corbaProblemEx.setInfo(_ex._info().c_str()); 00152 corbaProblemEx.log(); 00153 return -1; 00154 } 00155 catch(...) 00156 { 00157 ACS_SHORT_LOG((LM_ERROR,"Error!")); 00158 return -1; 00159 } 00160 00161 ACS_SHORT_LOG ((LM_INFO, "The end!")); 00162 return 0; 00163 } 00164