File: CORBA_Exception.h

package info (click to toggle)
omniorb-dfsg 4.3.3%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 13,172 kB
  • sloc: cpp: 115,843; python: 24,962; ansic: 13,414; sh: 2,665; makefile: 40
file content (310 lines) | stat: -rw-r--r-- 10,375 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
// -*- Mode: C++; -*-
//                            Package   : omniORB
// CORBA_Exception.h          Created on: 2001/08/17
//                            Author    : Duncan Grisby (dpg1)
//
//    Copyright (C) 2013 Apasphere Ltd
//    Copyright (C) 2001 AT&T Laboratories Cambridge
//
//    This file is part of the omniORB library
//
//    The omniORB library is free software; you can redistribute it and/or
//    modify it under the terms of the GNU Lesser General Public
//    License as published by the Free Software Foundation; either
//    version 2.1 of the License, or (at your option) any later version.
//
//    This library is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//    Lesser General Public License for more details.
//
//    You should have received a copy of the GNU Lesser General Public
//    License along with this library. If not, see http://www.gnu.org/licenses/
//
//
// Description:
//    CORBA::Exception, SystemException, UserException
//

#ifndef INSIDE_OMNIORB_CORBA_MODULE
#  error "Must only be #included by CORBA.h"
#endif

//////////////////////////////////////////////////////////////////////
////////////////////////////// Exception /////////////////////////////
//////////////////////////////////////////////////////////////////////

class Exception {
public:
  virtual ~Exception();

  virtual void _raise() const = 0;
  // 'throw' a copy of self. Must be overriden by all descendants.

  static inline Exception* _downcast(Exception* e) { return e; }
  // An equivalent operation must be provided by each descendant,
  // returning a pointer to the descendant's type.

  static inline const Exception* _downcast(const Exception* e) { return e; }
  // An equivalent operation must be provided by each descendant,
  // returning a pointer to the descendant's type.

  static inline Exception* _narrow(Exception* e) { return e; }
  // An equivalent operation must be provided by each descendant,
  // returning a pointer to the descendant's type.
  // NOTE: deprecated function from CORBA 2.2. Same as _downcast.

  static Exception* _duplicate(const Exception* e);

  virtual const char* _name() const;
  virtual const char* _rep_id() const;
  // Return the plain name and repository id

  // omniORB internal.
  virtual const char* _NP_repoId(int* size) const = 0;
  virtual void _NP_marshal(cdrStream&) const = 0;

  static inline _CORBA_Boolean PR_is_valid(Exception* p ) {
    return ((p) ? (p->pd_magic == PR_magic) : 1);
  }
  static _core_attr const _CORBA_ULong PR_magic;

  typedef void (*insertExceptionToAny)    (Any&, const Exception&);
  typedef void (*insertExceptionToAnyNCP) (Any&, const Exception*);

  inline insertExceptionToAny insertToAnyFn() const {
    return pd_insertToAnyFn;
  }
  inline insertExceptionToAnyNCP insertToAnyFnNCP() const {
    return pd_insertToAnyFnNCP;
  }

protected:
  inline Exception() :
    pd_insertToAnyFn(0),
    pd_insertToAnyFnNCP(0),
    pd_magic(PR_magic)
  {}
  inline Exception& operator = (const Exception& ex) {
    pd_magic = ex.pd_magic;
    pd_insertToAnyFn = ex.pd_insertToAnyFn;
    pd_insertToAnyFnNCP = ex.pd_insertToAnyFnNCP;
    return *this;
  }
  static Exception* _NP_is_a(const Exception* e, const char* typeId);

  insertExceptionToAny     pd_insertToAnyFn;
  insertExceptionToAnyNCP  pd_insertToAnyFnNCP;

#ifdef _MSC_VER      // Copy ctor has to be public for catch on this
  // base class to work when a derived class is thrown.
public:
#endif
  inline Exception(const Exception& ex) :
    pd_insertToAnyFn(ex.pd_insertToAnyFn),
    pd_insertToAnyFnNCP(ex.pd_insertToAnyFnNCP),
    pd_magic(ex.pd_magic)
  {}

private:
  virtual Exception* _NP_duplicate() const = 0;
  // Must be overriden by all descendants to return a new copy of
  // themselves.

  virtual const char* _NP_typeId() const = 0;
  // Returns a type identifier in the form of a string.  The format is
  // internal to omniORB. This is used to support the _downcast()
  // operation.  Must be overriden by all descendants.

  ULong pd_magic;
};


//////////////////////////////////////////////////////////////////////
/////////////////////////// SystemException //////////////////////////
//////////////////////////////////////////////////////////////////////

enum CompletionStatus { COMPLETED_YES, COMPLETED_NO, COMPLETED_MAYBE };
enum exception_type { NO_EXCEPTION, USER_EXCEPTION, SYSTEM_EXCEPTION };

_CORBA_MODULE_VARINT const ULong
OMGVMCID _init_in_decl_(  = 1330446336 );


class SystemException : public Exception {
public:
  virtual ~SystemException();

#ifdef minor
  // Digital Unix 3.2, and may be others as well, defines minor() as
  // a macro in its sys/types.h. Get rid of it!
#undef minor
#endif

  inline ULong minor() const { return pd_minor; }
  inline void minor(ULong m) { pd_minor = m;    }

  inline CompletionStatus completed() const { return pd_status; }
  inline void completed(CompletionStatus s) { pd_status = s;    }

  static SystemException* _downcast(Exception*);
  static const SystemException* _downcast(const Exception*);
  static inline SystemException* _narrow(Exception* e) {
    return _downcast(e);
  }

  inline SystemException() {
    pd_minor = 0;
    pd_status = COMPLETED_NO;
  }
  inline SystemException(const SystemException& e) : Exception(e) {
    pd_minor = e.pd_minor;
    pd_status = e.pd_status;
  }
  inline SystemException(ULong minor_, CompletionStatus status) {
    pd_minor = minor_;
    pd_status = status;
  }
  inline SystemException& operator=(const SystemException& e) {
    Exception::operator=(e);
    pd_minor = e.pd_minor;
    pd_status = e.pd_status;
    return *this;
  }

  virtual const char* NP_minorString() const = 0;
  // omniORB proprietary function to get a meaningful name for the
  // minor code. The string must NOT be freed.

protected:
  ULong             pd_minor;
  CompletionStatus  pd_status;

private:
  virtual void _NP_marshal(cdrStream&) const;
};

#define OMNIORB_DECLARE_SYS_EXCEPTION(name) \
  class name : public SystemException { \
  public: \
    inline name(ULong minor_ = 0, CompletionStatus completed_ = COMPLETED_NO) \
      : SystemException (minor_, completed_) { \
          pd_insertToAnyFn    = insertToAnyFn; \
          pd_insertToAnyFnNCP = insertToAnyFnNCP; \
    } \
    inline name(const name& ex) : SystemException(ex) {} \
    inline name& operator=(const name& ex) { \
      SystemException::operator=(ex); \
      return *this; \
    } \
    virtual ~name(); \
    virtual void _raise() const; \
    static name* _downcast(Exception*); \
    static const name* _downcast(const Exception*); \
    static inline name* _narrow(Exception* e) { return _downcast(e); } \
    virtual const char* _NP_repoId(int* size) const; \
    static _core_attr Exception::insertExceptionToAny    insertToAnyFn; \
    static _core_attr Exception::insertExceptionToAnyNCP insertToAnyFnNCP; \
    virtual const char* NP_minorString() const; \
  private: \
    virtual Exception* _NP_duplicate() const; \
    virtual const char* _NP_typeId() const; \
  };

OMNIORB_FOR_EACH_SYS_EXCEPTION(OMNIORB_DECLARE_SYS_EXCEPTION)

#undef OMNIORB_DECLARE_SYS_EXCEPTION


  //////////////////////////////////////////////////////////////////////
  //////////////////////////// UserException ///////////////////////////
  //////////////////////////////////////////////////////////////////////

  class UserException : public Exception {
  public:
    virtual ~UserException();
    static UserException* _downcast(Exception* e);
    static const UserException* _downcast(const Exception* e);
    static inline UserException* _narrow(Exception* e) { return _downcast(e); }

  protected:
    inline UserException() {}

#ifdef _MSC_VER      // Copy ctor has to be public for catch on this
    // base class to work when a derived class is thrown.
  public:
#endif
    inline UserException(const UserException& ex) : Exception(ex) {}

  public: // Don't know why this needs to be public ...
    UserException& operator=(const UserException& ex) {
      Exception::operator=(ex);
      return *this;
    }
  };


//////////////////////////////////////////////////////////////////////
////////////////////////// WrongTransaction //////////////////////////
//////////////////////////////////////////////////////////////////////

OMNIORB_DECLARE_USER_EXCEPTION_IN_CORBA(WrongTransaction, _dyn_attr)


//////////////////////////////////////////////////////////////////////
////////////////////////// PolicyError      //////////////////////////
//////////////////////////////////////////////////////////////////////
typedef _CORBA_Short PolicyErrorCode;

_CORBA_MODULE_VARINT
const PolicyErrorCode BAD_POLICY               _init_in_decl_( = 0 );

_CORBA_MODULE_VARINT
const PolicyErrorCode UNSUPPORTED_POLICY       _init_in_decl_( = 1 );

_CORBA_MODULE_VARINT
const PolicyErrorCode BAD_POLICY_TYPE          _init_in_decl_( = 2 );

_CORBA_MODULE_VARINT
const PolicyErrorCode BAD_POLICY_VALUE         _init_in_decl_( = 3 );

_CORBA_MODULE_VARINT
const PolicyErrorCode UNSUPPORTED_POLICY_VALUE _init_in_decl_( = 4 );

_CORBA_MODULE_VAR _dyn_attr const CORBA::TypeCode_ptr _tc_PolicyErrorCode; 

class PolicyError : public CORBA::UserException {
public:
  PolicyErrorCode reason;

  inline PolicyError() {
    pd_insertToAnyFn    = insertToAnyFn;
    pd_insertToAnyFnNCP = insertToAnyFnNCP;
  }
  PolicyError(const PolicyError&);
  PolicyError(PolicyErrorCode);
  PolicyError& operator=(const PolicyError&);
  virtual ~PolicyError();
  virtual void _raise() const;
  static PolicyError* _downcast(CORBA::Exception*);
  static const PolicyError* _downcast(const CORBA::Exception*);
  static inline PolicyError* _narrow(CORBA::Exception* e) { 
    return _downcast(e);
  }

  void operator>>=(cdrStream&) const;
  void operator<<=(cdrStream&);

  static _core_attr insertExceptionToAny    insertToAnyFn;
  static _core_attr insertExceptionToAnyNCP insertToAnyFnNCP;

  static _core_attr const char* _PD_repoId;

private:
  virtual CORBA::Exception* _NP_duplicate() const;
  virtual const char* _NP_typeId() const;
  virtual const char* _NP_repoId(int*) const;
  virtual void _NP_marshal(cdrStream&) const;
};

_CORBA_MODULE_VAR _dyn_attr const CORBA::TypeCode_ptr _tc_PolicyError;