HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NullInterrupter.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2012-2018 DreamWorks Animation LLC
4 //
5 // All rights reserved. This software is distributed under the
6 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
7 //
8 // Redistributions of source code must retain the above copyright
9 // and license notice and the following restrictions and disclaimer.
10 //
11 // * Neither the name of DreamWorks Animation nor the names of
12 // its contributors may be used to endorse or promote products derived
13 // from this software without specific prior written permission.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
20 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 // IN NO EVENT SHALL THE COPYRIGHT HOLDERS' AND CONTRIBUTORS' AGGREGATE
27 // LIABILITY FOR ALL CLAIMS REGARDLESS OF THEIR BASIS EXCEED US$250.00.
28 //
29 ///////////////////////////////////////////////////////////////////////////
30 //
31 /// @file NullInterrupter.h
32 
33 #ifndef OPENVDB_UTIL_NULL_INTERRUPTER_HAS_BEEN_INCLUDED
34 #define OPENVDB_UTIL_NULL_INTERRUPTER_HAS_BEEN_INCLUDED
35 
36 #include <openvdb/version.h>
37 
38 namespace openvdb {
40 namespace OPENVDB_VERSION_NAME {
41 namespace util {
42 
43 /// @brief Dummy NOOP interrupter class defining interface
44 ///
45 /// This shows the required interface for the @c InterrupterType template argument
46 /// using by several threaded applications (e.g. tools/PointAdvect.h). The host
47 /// application calls start() at the beginning of an interruptible operation, end()
48 /// at the end of the operation, and wasInterrupted() periodically during the operation.
49 /// If any call to wasInterrupted() returns @c true, the operation will be aborted.
50 /// @note This Dummy interrupter will NEVER interrupt since wasInterrupted() always
51 /// returns false!
53 {
54  /// Default constructor
56  /// Signal the start of an interruptible operation.
57  /// @param name an optional descriptive name for the operation
58  void start(const char* name = NULL) { (void)name; }
59  /// Signal the end of an interruptible operation.
60  void end() {}
61  /// Check if an interruptible operation should be aborted.
62  /// @param percent an optional (when >= 0) percentage indicating
63  /// the fraction of the operation that has been completed
64  /// @note this method is assumed to be thread-safe. The current
65  /// implementation is clearly a NOOP and should compile out during
66  /// optimization!
67  inline bool wasInterrupted(int percent = -1) { (void)percent; return false; }
68 };
69 
70 /// This method allows NullInterrupter::wasInterrupted to be compiled
71 /// out when client code only has a pointer (vs reference) to the interrupter.
72 ///
73 /// @note This is a free-standing function since C++ doesn't allow for
74 /// partial template specialization (in client code of the interrupter).
75 template <typename T>
76 inline bool wasInterrupted(T* i, int percent = -1) { return i && i->wasInterrupted(percent); }
77 
78 /// Specialization for NullInterrupter
79 template<>
80 inline bool wasInterrupted<util::NullInterrupter>(util::NullInterrupter*, int) { return false; }
81 
82 } // namespace util
83 } // namespace OPENVDB_VERSION_NAME
84 } // namespace openvdb
85 
86 #endif // OPENVDB_UTIL_NULL_INTERRUPTER_HAS_BEEN_INCLUDED
87 
88 // Copyright (c) 2012-2018 DreamWorks Animation LLC
89 // All rights reserved. This software is distributed under the
90 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:189
Dummy NOOP interrupter class defining interface.
png_uint_32 i
Definition: png.h:2877
void end()
Signal the end of an interruptible operation.
GLuint const GLchar * name
Definition: glcorearb.h:785
typedef int
Definition: png.h:1175
bool wasInterrupted(T *i, int percent=-1)
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:135