Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 09:30:09

0001 /*
0002 Open Asset Import Library (assimp)
0003 ----------------------------------------------------------------------
0004 
0005 Copyright (c) 2006-2024, assimp team
0006 
0007 
0008 All rights reserved.
0009 
0010 Redistribution and use of this software in source and binary forms,
0011 with or without modification, are permitted provided that the
0012 following conditions are met:
0013 
0014 * Redistributions of source code must retain the above
0015   copyright notice, this list of conditions and the
0016   following disclaimer.
0017 
0018 * Redistributions in binary form must reproduce the above
0019   copyright notice, this list of conditions and the
0020   following disclaimer in the documentation and/or other
0021   materials provided with the distribution.
0022 
0023 * Neither the name of the assimp team, nor the names of its
0024   contributors may be used to endorse or promote products
0025   derived from this software without specific prior
0026   written permission of the assimp team.
0027 
0028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0029 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0030 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0031 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0032 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0033 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0034 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0035 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0036 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0037 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0038 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0039 
0040 ----------------------------------------------------------------------
0041 */
0042 
0043 /** @file ProgressHandler.hpp
0044  *  @brief Abstract base class 'ProgressHandler'.
0045  */
0046 #pragma once
0047 #ifndef AI_PROGRESSHANDLER_H_INC
0048 #define AI_PROGRESSHANDLER_H_INC
0049 
0050 #ifdef __GNUC__
0051 #   pragma GCC system_header
0052 #endif
0053 
0054 #include <assimp/types.h>
0055 
0056 namespace Assimp {
0057 
0058 // ------------------------------------------------------------------------------------
0059 /** @brief CPP-API: Abstract interface for custom progress report receivers.
0060  *
0061  *  Each #Importer instance maintains its own #ProgressHandler. The default
0062  *  implementation provided by Assimp doesn't do anything at all. */
0063 class ASSIMP_API ProgressHandler
0064 #ifndef SWIG
0065     : public Intern::AllocateFromAssimpHeap
0066 #endif
0067 {
0068 protected:
0069     /// @brief  Default constructor
0070     ProgressHandler () AI_NO_EXCEPT = default;
0071 
0072 public:
0073     /// @brief  Virtual destructor.
0074     virtual ~ProgressHandler () = default;
0075 
0076     // -------------------------------------------------------------------
0077     /** @brief Progress callback.
0078      *  @param percentage An estimate of the current loading progress,
0079      *    in percent. Or -1.f if such an estimate is not available.
0080      *
0081      *  There are restriction on what you may do from within your
0082      *  implementation of this method: no exceptions may be thrown and no
0083      *  non-const #Importer methods may be called. It is
0084      *  not generally possible to predict the number of callbacks
0085      *  fired during a single import.
0086      *
0087      *  @return Return false to abort loading at the next possible
0088      *   occasion (loaders and Assimp are generally allowed to perform
0089      *   all needed cleanup tasks prior to returning control to the
0090      *   caller). If the loading is aborted, #Importer::ReadFile()
0091      *   returns always nullptr.
0092      *   */
0093     virtual bool Update(float percentage = -1.f) = 0;
0094 
0095     // -------------------------------------------------------------------
0096     /** @brief Progress callback for file loading steps
0097      *  @param numberOfSteps The number of total post-processing
0098      *   steps
0099      *  @param currentStep The index of the current post-processing
0100      *   step that will run, or equal to numberOfSteps if all of
0101      *   them has finished. This number is always strictly monotone
0102      *   increasing, although not necessarily linearly.
0103      *
0104      *  @note This is currently only used at the start and the end
0105      *   of the file parsing.
0106      *   */
0107     virtual void UpdateFileRead(int currentStep /*= 0*/, int numberOfSteps /*= 0*/) {
0108         float f = numberOfSteps ? currentStep / (float)numberOfSteps : 1.0f;
0109         Update( f * 0.5f );
0110     }
0111 
0112     // -------------------------------------------------------------------
0113     /** @brief Progress callback for post-processing steps
0114      *  @param numberOfSteps The number of total post-processing
0115      *   steps
0116      *  @param currentStep The index of the current post-processing
0117      *   step that will run, or equal to numberOfSteps if all of
0118      *   them has finished. This number is always strictly monotone
0119      *   increasing, although not necessarily linearly.
0120      *   */
0121     virtual void UpdatePostProcess(int currentStep /*= 0*/, int numberOfSteps /*= 0*/) {
0122         float f = numberOfSteps ? currentStep / (float)numberOfSteps : 1.0f;
0123         Update( f * 0.5f + 0.5f );
0124     }
0125 
0126 
0127     // -------------------------------------------------------------------
0128     /** @brief Progress callback for export steps.
0129      *  @param numberOfSteps The number of total processing
0130      *   steps
0131      *  @param currentStep The index of the current post-processing
0132      *   step that will run, or equal to numberOfSteps if all of
0133      *   them has finished. This number is always strictly monotone
0134      *   increasing, although not necessarily linearly.
0135      *   */
0136     virtual void UpdateFileWrite(int currentStep /*= 0*/, int numberOfSteps /*= 0*/) {
0137         float f = numberOfSteps ? currentStep / (float)numberOfSteps : 1.0f;
0138         Update(f * 0.5f);
0139     }
0140 }; // !class ProgressHandler
0141 
0142 // ------------------------------------------------------------------------------------
0143 
0144 } // Namespace Assimp
0145 
0146 #endif // AI_PROGRESSHANDLER_H_INC