/srv/build/STABLE_8/pkgs/tog-pegasus/BUILD/pegasus/src/Pegasus/Client/ClientOpPerformanceDataHandler.h00001 //%LICENSE//////////////////////////////////////////////////////////////// 00002 // 00003 // Licensed to The Open Group (TOG) under one or more contributor license 00004 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with 00005 // this work for additional information regarding copyright ownership. 00006 // Each contributor licenses this file to you under the OpenPegasus Open 00007 // Source License; you may not use this file except in compliance with the 00008 // License. 00009 // 00010 // Permission is hereby granted, free of charge, to any person obtaining a 00011 // copy of this software and associated documentation files (the "Software"), 00012 // to deal in the Software without restriction, including without limitation 00013 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 00014 // and/or sell copies of the Software, and to permit persons to whom the 00015 // Software is furnished to do so, subject to the following conditions: 00016 // 00017 // The above copyright notice and this permission notice shall be included 00018 // in all copies or substantial portions of the Software. 00019 // 00020 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00021 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00022 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00023 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 00024 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 00025 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 00026 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00027 // 00029 // 00030 //%///////////////////////////////////////////////////////////////////////////// 00031 00032 #ifndef ClientOpPerformanceDataHandler_h 00033 #define ClientOpPerformanceDataHandler_h 00034 00035 #include <Pegasus/Common/CIMOperationType.h> 00036 #include <Pegasus/Client/Linkage.h> 00037 00038 PEGASUS_NAMESPACE_BEGIN 00039 00044 struct PEGASUS_CLIENT_LINKAGE ClientOpPerformanceData 00045 { 00049 CIMOperationType operationType; 00050 00055 Boolean serverTimeKnown; 00056 00062 Uint64 serverTime; 00063 00070 Uint64 roundTripTime; 00071 00074 Uint64 requestSize; 00075 00078 Uint64 responseSize; 00079 }; 00080 00081 00087 class PEGASUS_CLIENT_LINKAGE ClientOpPerformanceDataHandler 00088 { 00089 public: 00090 00091 virtual ~ClientOpPerformanceDataHandler(); 00092 00109 virtual void handleClientOpPerformanceData( 00110 const ClientOpPerformanceData& item) = 0; 00111 }; 00112 00113 00114 /* 00115 00116 The following example shows how a ClientOpPerformanceDataHandler callback may 00117 be used by a client application. 00118 00119 // A ClientOpPerformanceDataHandler implementation that simply prints the 00120 // data from the ClientOpPerformanceData object. 00121 00122 class ClientStatisticsAccumulator : public ClientOpPerformanceDataHandler 00123 { 00124 public: 00125 00126 virtual void handleClientOpPerformanceData( 00127 const ClientOpPerformanceData& item) 00128 { 00129 cout << "ClientStatisticsAccumulator data:" << endl; 00130 cout << " operationType is " << (Uint32)item.operationType << endl; 00131 cout << " serverTime is " << (Uint32)item.serverTime << endl; 00132 cout << " roundTripTime is " << (Uint32)item.roundTripTime << endl; 00133 cout << " requestSize is " << (Uint32)item.requestSize << endl; 00134 cout << " responseSize is " << (Uint32)item.responseSize << endl; 00135 if (item.serverTimeKnown) 00136 { 00137 cout << " serverTimeKnown is true" << endl; 00138 } 00139 else 00140 { 00141 cout << " serverTimeKnown is false" << endl; 00142 } 00143 } 00144 }; 00145 00146 int main(int argc, char** argv) 00147 { 00148 // Establish the namespace from the input parameters 00149 String nameSpace = "root/cimv2"; 00150 00151 //Get hostname 00152 String location = "localhost"; 00153 00154 //Get port number 00155 Uint32 port = 5988; 00156 00157 //Get user name and password 00158 String userN; 00159 String passW; 00160 00161 // Connect to the server 00162 00163 String className = "PG_ComputerSystem"; 00164 CIMClient client; 00165 // Note: The ClientStatisticsAccumulator object should have the same 00166 // scope as the CIMClient object. 00167 ClientStatisticsAccumulator accumulator; 00168 00169 try 00170 { 00171 client.connect(location, port, userN, passW); 00172 } 00173 catch (Exception& e) 00174 { 00175 cerr << argv[0] << "Exception connecting to: " << location << endl; 00176 cerr << e.getMessage() << endl; 00177 exit(1); 00178 } 00179 00181 // Register callback and EnumerateInstances 00183 00184 client.registerClientOpPerformanceDataHandler(accumulator); 00185 00186 try 00187 { 00188 Array<CIMObjectPath> instances; 00189 00190 // Note: Completion of this CIMClient operation will invoke the 00191 // ClientOpPerformanceDataHandler callback. 00192 instances = client.enumerateInstanceNames(nameSpace, className); 00193 } 00194 catch (Exception& e) 00195 { 00196 cerr << "Exception: " << e.getMessage() << endl; 00197 exit(1); 00198 } 00199 00200 return 0; 00201 } 00202 00203 */ 00204 00205 00206 PEGASUS_NAMESPACE_END 00207 00208 #endif /* ClientOpPerformanceDataHandler_h */ 00209 00210