Planeshift

DetourStatus.h

Go to the documentation of this file.
00001 //
00002 // Copyright (c) 2009-2010 Mikko Mononen [email protected]
00003 //
00004 // This software is provided 'as-is', without any express or implied
00005 // warranty.  In no event will the authors be held liable for any damages
00006 // arising from the use of this software.
00007 // Permission is granted to anyone to use this software for any purpose,
00008 // including commercial applications, and to alter it and redistribute it
00009 // freely, subject to the following restrictions:
00010 // 1. The origin of this software must not be misrepresented; you must not
00011 //    claim that you wrote the original software. If you use this software
00012 //    in a product, an acknowledgment in the product documentation would be
00013 //    appreciated but is not required.
00014 // 2. Altered source versions must be plainly marked as such, and must not be
00015 //    misrepresented as being the original software.
00016 // 3. This notice may not be removed or altered from any source distribution.
00017 //
00018 
00019 #ifndef DETOURSTATUS_H
00020 #define DETOURSTATUS_H
00021 
00022 typedef unsigned int dtStatus;
00023 
00024 // High level status.
00025 static const unsigned int DT_FAILURE = 1u << 31;                        // Operation failed.
00026 static const unsigned int DT_SUCCESS = 1u << 30;                        // Operation succeed.
00027 static const unsigned int DT_IN_PROGRESS = 1u << 29;            // Operation still in progress.
00028 
00029 // Detail information for status.
00030 static const unsigned int DT_STATUS_DETAIL_MASK = 0x0ffffff;
00031 static const unsigned int DT_WRONG_MAGIC = 1 << 0;              // Input data is not recognized.
00032 static const unsigned int DT_WRONG_VERSION = 1 << 1;    // Input data is in wrong version.
00033 static const unsigned int DT_OUT_OF_MEMORY = 1 << 2;    // Operation ran out of memory.
00034 static const unsigned int DT_INVALID_PARAM = 1 << 3;    // An input parameter was invalid.
00035 static const unsigned int DT_BUFFER_TOO_SMALL = 1 << 4; // Result buffer for the query was too small to store all results.
00036 static const unsigned int DT_OUT_OF_NODES = 1 << 5;             // Query ran out of nodes during search.
00037 static const unsigned int DT_PARTIAL_RESULT = 1 << 6;   // Query did not reach the end location, returning best guess. 
00038 
00039 
00040 // Returns true of status is success.
00041 inline bool dtStatusSucceed(dtStatus status)
00042 {
00043         return (status & DT_SUCCESS) != 0;
00044 }
00045 
00046 // Returns true of status is failure.
00047 inline bool dtStatusFailed(dtStatus status)
00048 {
00049         return (status & DT_FAILURE) != 0;
00050 }
00051 
00052 // Returns true of status is in progress.
00053 inline bool dtStatusInProgress(dtStatus status)
00054 {
00055         return (status & DT_IN_PROGRESS) != 0;
00056 }
00057 
00058 // Returns true if specific detail is set.
00059 inline bool dtStatusDetail(dtStatus status, unsigned int detail)
00060 {
00061         return (status & detail) != 0;
00062 }
00063 
00064 #endif // DETOURSTATUS_H