miniassimp

view include/miniassimp/ProgressHandler.hpp @ 0:879c81d94345

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 28 Jan 2019 18:19:26 +0200
parents
children
line source
1 /*
2 Open Asset Import Library (assimp)
3 ----------------------------------------------------------------------
5 Copyright (c) 2006-2018, assimp team
8 All rights reserved.
10 Redistribution and use of this software in source and binary forms,
11 with or without modification, are permitted provided that the
12 following conditions are met:
14 * Redistributions of source code must retain the above
15 copyright notice, this list of conditions and the
16 following disclaimer.
18 * Redistributions in binary form must reproduce the above
19 copyright notice, this list of conditions and the
20 following disclaimer in the documentation and/or other
21 materials provided with the distribution.
23 * Neither the name of the assimp team, nor the names of its
24 contributors may be used to endorse or promote products
25 derived from this software without specific prior
26 written permission of the assimp team.
28 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 ----------------------------------------------------------------------
41 */
43 /** @file ProgressHandler.hpp
44 * @brief Abstract base class 'ProgressHandler'.
45 */
46 #pragma once
47 #ifndef AI_PROGRESSHANDLER_H_INC
48 #define AI_PROGRESSHANDLER_H_INC
50 #include "types.h"
52 namespace Assimp {
54 // ------------------------------------------------------------------------------------
55 /** @brief CPP-API: Abstract interface for custom progress report receivers.
56 *
57 * Each #Importer instance maintains its own #ProgressHandler. The default
58 * implementation provided by Assimp doesn't do anything at all. */
59 class ASSIMP_API ProgressHandler
60 #ifndef SWIG
61 : public Intern::AllocateFromAssimpHeap
62 #endif
63 {
64 protected:
65 /// @brief Default constructor
66 ProgressHandler () AI_NO_EXCEPT {
67 // empty
68 }
70 public:
71 /// @brief Virtual destructor.
72 virtual ~ProgressHandler () {
73 }
75 // -------------------------------------------------------------------
76 /** @brief Progress callback.
77 * @param percentage An estimate of the current loading progress,
78 * in percent. Or -1.f if such an estimate is not available.
79 *
80 * There are restriction on what you may do from within your
81 * implementation of this method: no exceptions may be thrown and no
82 * non-const #Importer methods may be called. It is
83 * not generally possible to predict the number of callbacks
84 * fired during a single import.
85 *
86 * @return Return false to abort loading at the next possible
87 * occasion (loaders and Assimp are generally allowed to perform
88 * all needed cleanup tasks prior to returning control to the
89 * caller). If the loading is aborted, #Importer::ReadFile()
90 * returns always NULL.
91 * */
92 virtual bool Update(float percentage = -1.f) = 0;
94 // -------------------------------------------------------------------
95 /** @brief Progress callback for file loading steps
96 * @param numberOfSteps The number of total post-processing
97 * steps
98 * @param currentStep The index of the current post-processing
99 * step that will run, or equal to numberOfSteps if all of
100 * them has finished. This number is always strictly monotone
101 * increasing, although not necessarily linearly.
102 *
103 * @note This is currently only used at the start and the end
104 * of the file parsing.
105 * */
106 virtual void UpdateFileRead(int currentStep /*= 0*/, int numberOfSteps /*= 0*/) {
107 float f = numberOfSteps ? currentStep / (float)numberOfSteps : 1.0f;
108 Update( f * 0.5f );
109 }
111 // -------------------------------------------------------------------
112 /** @brief Progress callback for post-processing steps
113 * @param numberOfSteps The number of total post-processing
114 * steps
115 * @param currentStep The index of the current post-processing
116 * step that will run, or equal to numberOfSteps if all of
117 * them has finished. This number is always strictly monotone
118 * increasing, although not necessarily linearly.
119 * */
120 virtual void UpdatePostProcess(int currentStep /*= 0*/, int numberOfSteps /*= 0*/) {
121 float f = numberOfSteps ? currentStep / (float)numberOfSteps : 1.0f;
122 Update( f * 0.5f + 0.5f );
123 }
126 // -------------------------------------------------------------------
127 /** @brief Progress callback for export steps.
128 * @param numberOfSteps The number of total processing
129 * steps
130 * @param currentStep The index of the current post-processing
131 * step that will run, or equal to numberOfSteps if all of
132 * them has finished. This number is always strictly monotone
133 * increasing, although not necessarily linearly.
134 * */
135 virtual void UpdateFileWrite(int currentStep /*= 0*/, int numberOfSteps /*= 0*/) {
136 float f = numberOfSteps ? currentStep / (float)numberOfSteps : 1.0f;
137 Update(f * 0.5f);
138 }
139 }; // !class ProgressHandler
141 // ------------------------------------------------------------------------------------
143 } // Namespace Assimp
145 #endif // AI_PROGRESSHANDLER_H_INC