Planeshift
DetourStatus.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2009-2010 Mikko Mononen memon@inside.org
3 //
4 // This software is provided 'as-is', without any express or implied
5 // warranty. In no event will the authors be held liable for any damages
6 // arising from the use of this software.
7 // Permission is granted to anyone to use this software for any purpose,
8 // including commercial applications, and to alter it and redistribute it
9 // freely, subject to the following restrictions:
10 // 1. The origin of this software must not be misrepresented; you must not
11 // claim that you wrote the original software. If you use this software
12 // in a product, an acknowledgment in the product documentation would be
13 // appreciated but is not required.
14 // 2. Altered source versions must be plainly marked as such, and must not be
15 // misrepresented as being the original software.
16 // 3. This notice may not be removed or altered from any source distribution.
17 //
18 
19 #ifndef DETOURSTATUS_H
20 #define DETOURSTATUS_H
21 
22 typedef unsigned int dtStatus;
23 
24 // High level status.
25 static const unsigned int DT_FAILURE = 1u << 31; // Operation failed.
26 static const unsigned int DT_SUCCESS = 1u << 30; // Operation succeed.
27 static const unsigned int DT_IN_PROGRESS = 1u << 29; // Operation still in progress.
28 
29 // Detail information for status.
30 static const unsigned int DT_STATUS_DETAIL_MASK = 0x0ffffff;
31 static const unsigned int DT_WRONG_MAGIC = 1 << 0; // Input data is not recognized.
32 static const unsigned int DT_WRONG_VERSION = 1 << 1; // Input data is in wrong version.
33 static const unsigned int DT_OUT_OF_MEMORY = 1 << 2; // Operation ran out of memory.
34 static const unsigned int DT_INVALID_PARAM = 1 << 3; // An input parameter was invalid.
35 static const unsigned int DT_BUFFER_TOO_SMALL = 1 << 4; // Result buffer for the query was too small to store all results.
36 static const unsigned int DT_OUT_OF_NODES = 1 << 5; // Query ran out of nodes during search.
37 static const unsigned int DT_PARTIAL_RESULT = 1 << 6; // Query did not reach the end location, returning best guess.
38 
39 
40 // Returns true of status is success.
41 inline bool dtStatusSucceed(dtStatus status)
42 {
43  return (status & DT_SUCCESS) != 0;
44 }
45 
46 // Returns true of status is failure.
47 inline bool dtStatusFailed(dtStatus status)
48 {
49  return (status & DT_FAILURE) != 0;
50 }
51 
52 // Returns true of status is in progress.
53 inline bool dtStatusInProgress(dtStatus status)
54 {
55  return (status & DT_IN_PROGRESS) != 0;
56 }
57 
58 // Returns true if specific detail is set.
59 inline bool dtStatusDetail(dtStatus status, unsigned int detail)
60 {
61  return (status & detail) != 0;
62 }
63 
64 #endif // DETOURSTATUS_H
static const unsigned int DT_WRONG_VERSION
Definition: DetourStatus.h:32
static const unsigned int DT_STATUS_DETAIL_MASK
Definition: DetourStatus.h:30
static const unsigned int DT_SUCCESS
Definition: DetourStatus.h:26
static const unsigned int DT_BUFFER_TOO_SMALL
Definition: DetourStatus.h:35
unsigned int dtStatus
Definition: DetourStatus.h:22
static const unsigned int DT_WRONG_MAGIC
Definition: DetourStatus.h:31
static const unsigned int DT_OUT_OF_NODES
Definition: DetourStatus.h:36
static const unsigned int DT_PARTIAL_RESULT
Definition: DetourStatus.h:37
bool dtStatusSucceed(dtStatus status)
Definition: DetourStatus.h:41
bool dtStatusFailed(dtStatus status)
Definition: DetourStatus.h:47
static const unsigned int DT_INVALID_PARAM
Definition: DetourStatus.h:34
bool dtStatusInProgress(dtStatus status)
Definition: DetourStatus.h:53
static const unsigned int DT_IN_PROGRESS
Definition: DetourStatus.h:27
bool dtStatusDetail(dtStatus status, unsigned int detail)
Definition: DetourStatus.h:59
static const unsigned int DT_OUT_OF_MEMORY
Definition: DetourStatus.h:33
static const unsigned int DT_FAILURE
Definition: DetourStatus.h:25