caprocstatreq.h

Go to the documentation of this file.
00001 // OSB library ************************************************ -*- C++ -*-
00006 /*
00007   AUTHOR(S): Stephan Broennimann (vb)
00008 
00009   RCS information
00010    $Name: OSB_060808 $
00011    $Revision: 1.6 $
00012 
00013   License
00014    OSB rating and billing library for communication networks
00015    Copyright (C) 2004, 2005, 2006  OSB systems
00016 
00017    This file may be distributed and/or modify under the terms of the
00018    GNU General Public License (GPL) as published by the Free Software
00019    Foundation which is provided in the file LICENSE.GPL included in the
00020    packaging of this file.
00021 
00022    The file is distributed in the hope that it will be useful, but WITHOUT
00023    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00024    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00025    for more details.
00026 
00027    Holders of a OSB Commercial License may use this file under the terms
00028    and conditions of this commercial license.
00029  */
00030 #ifndef _CAPROCSTATREQ_H_
00031 #define _CAPROCSTATREQ_H_
00032 
00033 // ************************************************************************
00034 // included header files
00035 // + standard includes
00036 #include <sstream>
00037 
00038 // + libraries
00039 #include <corba_statusC.h>
00040 
00041 // + local headers
00042 #include "corbalog.h"
00043 #include "corba_utility.h"
00044 #include "caglobal.h"
00045 
00046 // + class declarations
00047 
00048 // ************************************************************************
00049 // namespace extensions
00050 namespace OSB_CORBA {
00051     using corba::cadmin::StatusRequestId;
00052     using corba::common::CfgErrorSeq;
00053 
00055     const int aerRqsNotAvail = 402;
00056 
00057 // ************************************************************************
00058 // free functions
00082     template<typename Id>
00083     bool fwdStatusRequest(
00084         const std::string&    ifc,
00085         const std::string&    module,
00086               Id              contrId,
00087               StatusRequestId srId,
00088               CfgErrorSeq&    errors
00089     );
00090 }                                       // namespace OSB_CORBA
00091 
00092 // ************************************************************************
00093 // inline definitions
00094 namespace OSB_CORBA {
00095 
00096     template<typename Id>
00097     bool fwdStatusRequest(
00098         const std::string&     ifc,
00099         const std::string&     module,
00100               Id               id,
00101               StatusRequestId  srId,
00102               CfgErrorSeq&     errors
00103     )
00104     try {
00105         using namespace corba::cadmin;
00106 
00107         StatusReqResult ret = srqNotAvail;
00108         try {
00109             CaGlobal::RequestServer* rs = caGlobal.requestServer();
00110             ret = rs->procStatusRequest(srId, errors);
00111         }
00112         catch (const CaGlobal::NoRqsAvail& ex) {
00113             // warning logged already
00114             size_t numErr = errors.length();
00115             errors.length(numErr+1);
00116 
00117             OSB_APP::AppError e(aerRqsNotAvail, ex.args());
00118             errors[numErr] = osbToCfgError(e);
00119         }
00120 
00121         // determine the return value and log the result:
00122         // (if RQS is not avail: consider skipped)
00123         std::ostringstream os;
00124         os << id << ": status request " << srId.id;
00125 
00126         bool rc = true;
00127         switch (ret) {
00128           case srqSuccess:   // fall through
00129             os << " applied.";
00130             break;
00131           case srqProcessed:
00132             os << " done by RQS.";
00133             break;
00134           case srqNotAvail:  // fall through
00135           case srqSkipped:
00136             os << " skipped.";
00137             break;
00138           case srqError:
00139             os << " failed.";
00140             rc = false;
00141             break;
00142         };
00143         logMsg(DBG1, ifc, module, os);
00144 
00145         return rc;
00146     }
00147     catch (const OSB_LIB::BaseError& ex) {
00148         size_t numErr = errors.length();
00149         errors.length(numErr+1);
00150         errors[numErr] = osbToCfgError(ex);
00151 
00152         return false;
00153     }
00154 }                                       // namespace OSB_CORBA
00155 #endif                                  // #ifndef _CAPROCSTATREQ_H_

Generated on Sat Sep 2 14:25:51 2006 for OSB Library by  doxygen 1.4.7