Teamcenter C++ API Reference
2312
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
fclasses
error_map.hxx
Go to the documentation of this file.
1
#ifndef ERROR_MAP_HXX
2
#define ERROR_MAP_HXX
3
4
// @<COPYRIGHT_START>@
5
// ===============================================
6
// Copyright 2006 UGS Corp. All Rights Reserved.
7
// ===============================================
8
// @<COPYRIGHT_END>@
9
40
#include <
base_utils/TcBaseTypes.hxx
>
41
#include <error.h>
42
43
#include <
base_utils/SharedPtr.hxx
>
44
#include <
base_utils/ErrorStoreBase.hxx
>
45
#include <tc/tc_startup.h>
46
47
#include <fclasses/libfclasses_exports.h>
48
49
class
IFail
;
50
class
ResultStatus
;
51
class
status_t
;
52
53
// \ref doxygen_namespace_bug
54
namespace
Teamcenter
55
{
56
class
Error;
57
class
ExceptionPolicy;
58
59
// Implementation details.
60
namespace
Private
61
{
65
FCLASSES_API
Error
takeErrorStack
(
int
ifail );
69
FCLASSES_API
Error
takeErrorStack
(
IFail
const
& ifail );
73
FCLASSES_API
Error
takeErrorStack
(
status_t
const
& status );
74
78
FCLASSES_API
Error
readErrorStack
(
int
ifail );
79
83
FCLASSES_API
Error
pushErrorStack
(
int
ifail,
const
char
*s1=0,
const
char
*s2=0,
const
char
*s3=0,
const
char
*s4=0,
const
char
*s5=0,
const
char
*s6=0,
const
char
*s7=0 );
84
}
85
108
class
FCLASSES_API
Error
109
{
110
public
:
112
inline
Error
();
113
inline
~
Error
();
114
// Default copy and assign.
115
// Error( Error const& );
116
// Error& operator=( Error const& );
117
119
inline
bool
isOk()
const
;
121
inline
bool
isError()
const
;
122
124
inline
int
ifail()
const
;
125
inline
std::string errorMessage()
const
;
127
operator
ResultStatus
()
const
;
128
129
private
:
130
friend
Error
Teamcenter::Private::takeErrorStack
(
int
ifail );
131
friend
Error
Teamcenter::Private::takeErrorStack
(
IFail
const
& ifail );
132
friend
Error
Teamcenter::Private::takeErrorStack
(
status_t
const
& status );
133
134
friend
Error
Teamcenter::Private::readErrorStack
(
int
ifail );
135
friend
Error
Teamcenter::Private::pushErrorStack
(
int
ifail,
const
char
*s1,
const
char
*s2,
const
char
*s3,
const
char
*s4,
const
char
*s5,
const
char
*s6,
const
char
*s7 );
136
138
inline
explicit
Error
(
int
ifail );
139
141
int
m_ifail
;
142
std::string
m_errorMessage
;
143
};
144
165
class
FCLASSES_API
ErrorMap
166
{
167
public
:
169
inline
ErrorMap
();
170
171
// Copy and assign.
172
inline
ErrorMap
(
ErrorMap
const
& );
173
inline
ErrorMap
& operator=(
ErrorMap
const
& );
174
177
ErrorMap
& add(
size_t
id
,
Error
const
& error );
180
inline
ErrorMap
& add(
size_t
id
,
int
ifail );
183
inline
ErrorMap
& add(
size_t
id
,
IFail
const
& ifail );
186
inline
ErrorMap
& add(
size_t
id
,
status_t
const
& status );
189
ErrorMap
& operator+=(
ErrorMap
const
& right );
190
192
typedef
size_t
key_type
;
193
typedef
Error
mapped_type
;
194
typedef
StdSmMap< size_t, Error >::Map::value_type
value_type
;
195
197
typedef
StdSmMap< size_t, Error >::Map::iterator
iterator
;
198
typedef
StdSmMap< size_t, Error >::Map::const_iterator
const_iterator
;
199
201
inline
size_t
size()
const
;
203
inline
bool
empty()
const
;
204
206
iterator
find(
size_t
id
);
207
const_iterator
find(
size_t
id
)
const
;
208
210
inline
iterator
begin();
211
inline
iterator
end();
212
inline
const_iterator
begin()
const
;
213
inline
const_iterator
end()
const
;
214
215
private
:
216
typedef
StdSmMap< size_t, Error >::Map
StdErrorMap
;
217
219
inline
StdErrorMap
& ensureMap();
220
225
shared_ptr< StdErrorMap >
m_map
;
226
231
StdErrorMap
m_emptyMap
;
232
};
233
238
class
FCLASSES_API
ExceptionPolicy
239
{
240
public
:
244
ExceptionPolicy
();
252
explicit
ExceptionPolicy
(
bool
throwOnError );
254
~
ExceptionPolicy
();
255
258
static
bool
throwOnError();
259
260
private
:
261
// Prohibit copy and assign.
262
ExceptionPolicy
(
ExceptionPolicy
const
& );
263
ExceptionPolicy
& operator=(
ExceptionPolicy
const
& );
264
266
bool
m_setThrowOnError
;
267
269
static
bool
s_throwOnError
;
270
static
bool
s_overrideThrowOnError
;
271
friend
class
IgnoreExceptionPolicy
;
272
};
273
274
class
FCLASSES_API
IgnoreExceptionPolicy
275
{
276
public
:
277
IgnoreExceptionPolicy
();
278
~
IgnoreExceptionPolicy
();
279
};
280
282
283
inline
Error::Error
()
284
: m_ifail( ITK_ok ), m_errorMessage()
285
{
286
}
287
288
inline
Error::~Error
()
289
{
290
// Required to prevent warnings in std::vector-on-sm template compilation
291
// with msvc7.1 compiler.
292
}
293
294
inline
Error::Error
(
int
ifail )
295
: m_ifail( ifail ), m_errorMessage()
296
{
297
if
( ifail != ITK_ok )
298
{
299
m_errorMessage
=
Teamcenter::ErrorStoreBase::getInstance
().
ask_last_message
( ifail );
// ifail must already been in ERROR_store
300
}
301
}
302
303
inline
bool
Error::isOk
()
const
304
{
305
return
m_ifail
== ITK_ok;
306
}
307
308
inline
bool
Error::isError
()
const
309
{
310
return
m_ifail
!= ITK_ok;
311
}
312
313
inline
int
Error::ifail
()
const
314
{
315
return
m_ifail
;
316
}
317
318
inline
std::string
Error::errorMessage
()
const
319
{
320
return
m_errorMessage
;
321
}
322
323
inline
ErrorMap::ErrorMap
()
324
: m_map(),
325
m_emptyMap()
326
{
327
}
328
329
inline
ErrorMap::ErrorMap
(
ErrorMap
const
& errorMap )
330
: m_map( errorMap.m_map ),
331
m_emptyMap()
332
{
333
}
334
335
inline
ErrorMap
&
ErrorMap::operator=
(
ErrorMap
const
& errorMap )
336
{
337
// Deliberately not checking for self-assignment.
338
// Exception-safe classes rarely need to whatever QAZ says.
339
m_map
= errorMap.
m_map
;
340
// No need to copy m_emptyMap. They are both empty!
341
return
*
this
;
342
}
343
344
inline
ErrorMap
&
ErrorMap::add
(
size_t
id
,
int
ifail )
345
{
346
return
add
(
id
,
Teamcenter::Private::takeErrorStack
( ifail ) );
347
}
348
349
inline
ErrorMap
&
ErrorMap::add
(
size_t
id
,
IFail
const
& ifail )
350
{
351
return
add
(
id
,
Teamcenter::Private::takeErrorStack
( ifail ) );
352
}
353
354
inline
ErrorMap
&
ErrorMap::add
(
size_t
id
,
status_t
const
& status )
355
{
356
return
add
(
id
,
Teamcenter::Private::takeErrorStack
( status ) );
357
}
358
359
inline
size_t
ErrorMap::size
()
const
360
{
361
if
(
m_map
)
362
return
m_map
->size();
363
else
364
return
0;
365
}
366
inline
bool
ErrorMap::empty
()
const
367
{
368
if
(
m_map
)
369
return
m_map
->empty();
370
else
371
return
true
;
372
}
373
374
inline
ErrorMap::iterator
ErrorMap::begin
()
375
{
376
if
(
m_map
)
377
return
m_map
->begin();
378
else
379
return
m_emptyMap
.begin();
380
}
381
382
inline
ErrorMap::iterator
ErrorMap::end
()
383
{
384
if
(
m_map
)
385
return
m_map
->end();
386
else
387
return
m_emptyMap
.end();
388
}
389
390
inline
ErrorMap::const_iterator
ErrorMap::begin
()
const
391
{
392
if
(
m_map
)
393
return
m_map
->begin();
394
else
395
return
m_emptyMap
.begin();
396
}
397
398
inline
ErrorMap::const_iterator
ErrorMap::end
()
const
399
{
400
if
(
m_map
)
401
return
m_map
->end();
402
else
403
return
m_emptyMap
.end();
404
}
405
}
// namespace Teamcenter
406
#include <fclasses/libfclasses_undef.h>
407
#endif