SystemException.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    SystemException.h
00006  *
00007  *  $Id: SystemException.h 78860 2007-07-12 23:43:35Z ossama $
00008  *
00009  *  CORBA::SystemException class header.
00010  *
00011  *  @author DOC Group at Vanderbilt U, Wash U, and UCI
00012  *  @author Ossama Othman <ossama@dre.vanderbilt.edu>
00013  */
00014 //=============================================================================
00015 
00016 #ifndef TAO_SYSTEM_EXCEPTION_H
00017 #define TAO_SYSTEM_EXCEPTION_H
00018 
00019 #include /**/ "ace/pre.h"
00020 
00021 // Do not try removing this. If you remove this for subsetting lots of
00022 // things go wrong in TAO.
00023 #include "tao/orbconf.h"
00024 
00025 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00026 # pragma once
00027 #endif /* ACE_LACKS_PRAGMA_ONCE */
00028 
00029 #include "tao/Exception.h"
00030 
00031 #ifndef TAO_Exception_Export
00032 # if (__GNUC__ > 3)
00033 // Exceptions found in DLL A but potentially thrown in DLL B must
00034 // always be exported.
00035 #  define TAO_Exception_Export ACE_Proper_Export_Flag
00036 # else
00037 #  define TAO_Exception_Export TAO_Export
00038 # endif  /* __GNUC__ > 3*/
00039 #endif  /* !TAO_Exception_Export */
00040 
00041 #ifdef THREAD_CANCELLED
00042 # undef THREAD_CANCELLED
00043 #endif /* THREAD_CANCELLED */
00044 
00045 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00046 
00047 class TAO_OutputCDR;
00048 class TAO_InputCDR;
00049 
00050 // This is already done in orbconf.h. But this file is totally
00051 // decoupled from its contents that we have to do this here. Including
00052 // orbconf.h is probably going to be a overhead.
00053 #if defined (minor)
00054 #undef minor
00055 #endif /* minor */
00056 
00057 namespace CORBA
00058 {
00059   class SystemException;
00060 }
00061 
00062 namespace TAO
00063 {
00064   typedef CORBA::SystemException* (*excp_factory)(void);
00065 }
00066 
00067 namespace CORBA
00068 {
00069   /**
00070    * @enum CompletionStatus
00071    *
00072    * @brief Completion status for CORBA system exceptions
00073    *
00074    * Enumerations that denote how an operation was (not) completed
00075    * when a @c CORBA::SystemException is thrown.
00076    */
00077   enum CompletionStatus
00078   {
00079     COMPLETED_YES,     ///< Successful or exceptional completion.
00080     COMPLETED_NO,      ///< Didn't change any state; retry is OK.
00081     COMPLETED_MAYBE    ///< Can't say what happened; retry unsafe.
00082   };
00083 
00084   /**
00085    * @class SystemException
00086    *
00087    * @brief SystemException
00088    *
00089    * System exceptions are those defined in the CORBA specification;
00090    * OMG-IDL defines these.
00091    */
00092   class TAO_Export SystemException : public Exception
00093   {
00094   public:
00095 
00096     /// Copy constructor.
00097     /**
00098      * @note This constructor should be protected, but VC7.1 at
00099      *       warning level 4 complains about the inaccessible copy
00100      *       constructor preventing it from being caught.  However,
00101      *       that probably isn't true for most cases since CORBA
00102      *       exceptions are typically caught by reference, not by
00103      *       copy.
00104      */
00105     SystemException (const SystemException & src);
00106 
00107     /// Destructor.
00108     virtual ~SystemException (void);
00109 
00110     /// Get the minor status.
00111     ULong minor (void) const;
00112 
00113     /// Set the minor status.
00114     void minor (ULong m);
00115 
00116     /// Get the completion status.
00117     CORBA::CompletionStatus completed (void) const;
00118 
00119     /// Set the operation completion status.
00120     void completed (CORBA::CompletionStatus c);
00121 
00122     /// Narrow to a SystemException.
00123     static SystemException *_downcast (CORBA::Exception *exception);
00124 
00125     /// The const version of narrow operation to a SystemException
00126     static const SystemException *_downcast(const CORBA::Exception *exception);
00127 
00128     virtual void _raise (void) const = 0;
00129 
00130     // = TAO-specific extension.
00131 
00132     /// Print the system exception @c ex to output determined by @c f.
00133     /// This function is not CORBA compliant.
00134     void _tao_print_system_exception (FILE *f = stdout) const;
00135 
00136     /// Returns a string containing information about the exception. This
00137     /// function is not CORBA compliant.
00138     virtual ACE_CString _info (void) const;
00139 
00140     virtual void _tao_encode (TAO_OutputCDR &cdr) const;
00141 
00142     virtual void _tao_decode (TAO_InputCDR &cdr);
00143 
00144     /// Helper to create a minor status value.
00145     static CORBA::ULong _tao_minor_code (u_int location, int errno_value);
00146 
00147     /// Helper to translate a platform-specific errno to a TAO errno
00148     /// value.
00149     static CORBA::ULong _tao_errno (int errno_value);
00150 
00151     /// Deep copy
00152     virtual CORBA::Exception *_tao_duplicate (void) const;
00153 
00154   protected:
00155 
00156     /// Default constructor.
00157     SystemException (void);
00158 
00159     /// Assignment operator.
00160     SystemException & operator= (const SystemException &src);
00161 
00162     /// Constructor using a repository id.
00163     SystemException (CORBA::ULong code, CORBA::CompletionStatus completed);
00164 
00165     /// Constructor using a repository id.
00166     SystemException (const char *repository_id,
00167                      const char *local_name,
00168                      CORBA::ULong code,
00169                      CORBA::CompletionStatus completed);
00170 
00171     /// Return the exception description associated with the given OMG
00172     /// minor code.
00173     static const char *_tao_get_omg_exception_description (
00174       const CORBA::SystemException &exc, CORBA::ULong minor_code);
00175 
00176   private:
00177     /// Minor code.
00178     CORBA::ULong minor_;
00179 
00180     /// Completion status.
00181     CORBA::CompletionStatus completed_;
00182   };
00183 
00184   // Declarations for all of the CORBA standard exceptions.
00185   //
00186   // @@ - shouldn't have a default minor code, at least for code that's
00187   // inside the ORB.  All minor codes should be symbolically catalogued.
00188 
00189 #define TAO_SYSTEM_EXCEPTION(name) \
00190     class TAO_Exception_Export name : public SystemException \
00191     { \
00192     public: \
00193       name (void); \
00194       name (CORBA::ULong code, \
00195             CORBA::CompletionStatus completed); \
00196       static name * _downcast (CORBA::Exception* exception); \
00197       static name const * _downcast (CORBA::Exception const * exception); \
00198       virtual void _raise (void) const; \
00199       virtual CORBA::TypeCode_ptr _tao_type (void) const; \
00200       static void _tao_any_destructor (void*); \
00201       virtual CORBA::Exception *_tao_duplicate (void) const; \
00202       static CORBA::SystemException *_tao_create (void); \
00203     }; \
00204 
00205   TAO_SYSTEM_EXCEPTION(UNKNOWN)          // the unknown exception
00206   TAO_SYSTEM_EXCEPTION(BAD_PARAM)        // an invalid parameter was passed
00207   TAO_SYSTEM_EXCEPTION(NO_MEMORY)        // memory allocation failure
00208   TAO_SYSTEM_EXCEPTION(IMP_LIMIT)        // violated implementation limit
00209   TAO_SYSTEM_EXCEPTION(COMM_FAILURE)     // communication failure
00210   TAO_SYSTEM_EXCEPTION(INV_OBJREF)       // invalid object reference
00211   TAO_SYSTEM_EXCEPTION(OBJECT_NOT_EXIST) // no such object
00212   TAO_SYSTEM_EXCEPTION(NO_PERMISSION)    // no permission for operation
00213   TAO_SYSTEM_EXCEPTION(INTERNAL)         // ORB internal error
00214   TAO_SYSTEM_EXCEPTION(MARSHAL)          // error marshaling param/result
00215   TAO_SYSTEM_EXCEPTION(INITIALIZE)       // ORB initialization failure
00216   TAO_SYSTEM_EXCEPTION(NO_IMPLEMENT)     // implementation unavailable
00217   TAO_SYSTEM_EXCEPTION(BAD_TYPECODE)     // bad typecode
00218   TAO_SYSTEM_EXCEPTION(BAD_OPERATION)    // invalid operation
00219   TAO_SYSTEM_EXCEPTION(NO_RESOURCES)     // out of resources for request
00220   TAO_SYSTEM_EXCEPTION(NO_RESPONSE)      // response not yet available
00221   TAO_SYSTEM_EXCEPTION(PERSIST_STORE)    // persistent storage failure
00222   TAO_SYSTEM_EXCEPTION(BAD_INV_ORDER)    // routine invocations out of order
00223   TAO_SYSTEM_EXCEPTION(TRANSIENT)        // transient error, try again later
00224   TAO_SYSTEM_EXCEPTION(FREE_MEM)         // cannot free memory
00225   TAO_SYSTEM_EXCEPTION(INV_IDENT)        // invalid identifier syntax
00226   TAO_SYSTEM_EXCEPTION(INV_FLAG)         // invalid flag was specified
00227   TAO_SYSTEM_EXCEPTION(INTF_REPOS)       // interface repository unavailable
00228   TAO_SYSTEM_EXCEPTION(BAD_CONTEXT)      // error processing context object
00229   TAO_SYSTEM_EXCEPTION(OBJ_ADAPTER)      // object adapter failure
00230   TAO_SYSTEM_EXCEPTION(DATA_CONVERSION)  // data conversion error
00231   TAO_SYSTEM_EXCEPTION(INV_POLICY)       // invalid policies present
00232   TAO_SYSTEM_EXCEPTION(REBIND)           // rebind needed
00233   TAO_SYSTEM_EXCEPTION(TIMEOUT)          // operation timed out
00234   TAO_SYSTEM_EXCEPTION(TRANSACTION_UNAVAILABLE) // no transaction
00235   TAO_SYSTEM_EXCEPTION(TRANSACTION_MODE)        // invalid transaction mode
00236   TAO_SYSTEM_EXCEPTION(TRANSACTION_REQUIRED)    // operation needs transaction
00237   TAO_SYSTEM_EXCEPTION(TRANSACTION_ROLLEDBACK)  // operation was a no-op
00238   TAO_SYSTEM_EXCEPTION(INVALID_TRANSACTION)     // invalid TP context passed
00239   TAO_SYSTEM_EXCEPTION(CODESET_INCOMPATIBLE)    // incompatible code set
00240   TAO_SYSTEM_EXCEPTION(BAD_QOS)          // bad quality of service
00241   TAO_SYSTEM_EXCEPTION(INVALID_ACTIVITY)
00242   TAO_SYSTEM_EXCEPTION(ACTIVITY_COMPLETED)
00243   TAO_SYSTEM_EXCEPTION(ACTIVITY_REQUIRED)
00244   TAO_SYSTEM_EXCEPTION(THREAD_CANCELLED)
00245 
00246 #undef TAO_SYSTEM_EXCEPTION
00247 
00248 } // End CORBA namespace
00249 
00250 TAO_END_VERSIONED_NAMESPACE_DECL
00251 
00252 #if defined (__ACE_INLINE__)
00253 # include "tao/SystemException.inl"
00254 #endif /* __ACE_INLINE__ */
00255 
00256 #include /**/"ace/post.h"
00257 
00258 #endif /* TAO_SYSTEM_EXCEPTION_H */

Generated on Tue Feb 2 17:37:52 2010 for TAO by  doxygen 1.4.7