|
|
|||
File indexing completed on 2026-09-28 09:19:34
0001 // Copyright (c) 2026 OPEN CASCADE SAS 0002 // 0003 // This file is part of Open CASCADE Technology software library. 0004 // 0005 // This library is free software; you can redistribute it and/or modify it under 0006 // the terms of the GNU Lesser General Public License version 2.1 as published 0007 // by the Free Software Foundation, with special exception defined in the file 0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0009 // distribution for complete text of the license and disclaimer of any warranty. 0010 // 0011 // Alternatively, this file may be used under the terms of Open CASCADE 0012 // commercial license or contractual agreement. 0013 0014 #ifndef _BRepGraph_DeferredScope_HeaderFile 0015 #define _BRepGraph_DeferredScope_HeaderFile 0016 0017 #include <BRepGraph.hxx> 0018 #include <BRepGraph_EditorView.hxx> 0019 0020 //! @brief RAII guard for batch mutation scopes with deferred invalidation. 0021 //! 0022 //! Activates deferred invalidation on construction and flushes it on destruction, 0023 //! followed by CommitMutation validation. Guarantees exception-safe cleanup: 0024 //! when this guard owns deferred mode, it is always closed and boundary checks 0025 //! are executed at scope exit. EndDeferredInvalidation() batch-propagates 0026 //! SubtreeGen upward, then CommitMutation() validates relation consistency and 0027 //! active-entity counts. 0028 //! 0029 //! Re-entrant: if deferred mode is already active (e.g., nested guard), 0030 //! the inner guard is a no-op. Only the outermost guard flushes and commits, 0031 //! so nested scopes do not create separate transaction or validation boundaries. 0032 //! 0033 //! @warning This guard batches invalidation and propagation; it is NOT a 0034 //! transaction and does not serialize mutation bodies. Concurrent `Mut*()` 0035 //! usage still requires external synchronization for the whole guarded scope 0036 //! (for example, a mutex protecting exclusive Builder() access until the guard 0037 //! is destroyed). 0038 //! 0039 //! Usage: 0040 //! @code 0041 //! { 0042 //! BRepGraph_DeferredScope aScope(theGraph); 0043 //! for (int i = 0; i < N; ++i) 0044 //! { 0045 //! // mutations 0046 //! } 0047 //! } // EndDeferredInvalidation + CommitMutation called here 0048 //! @endcode 0049 class BRepGraph_DeferredScope 0050 { 0051 public: 0052 //! Begin deferred invalidation if not already active. 0053 explicit BRepGraph_DeferredScope(BRepGraph& theGraph) 0054 : myGraph(theGraph), 0055 myOwnsScope(!theGraph.Editor().IsDeferredMode()) 0056 { 0057 if (myOwnsScope) 0058 { 0059 myGraph.Editor().BeginDeferredInvalidation(); 0060 } 0061 } 0062 0063 //! End deferred invalidation and validate relations + active counts. 0064 ~BRepGraph_DeferredScope() 0065 { 0066 if (myOwnsScope) 0067 { 0068 myGraph.Editor().EndDeferredInvalidation(); 0069 myGraph.Editor().CommitMutation(); 0070 } 0071 } 0072 0073 BRepGraph_DeferredScope(const BRepGraph_DeferredScope&) = delete; 0074 BRepGraph_DeferredScope& operator=(const BRepGraph_DeferredScope&) = delete; 0075 0076 private: 0077 BRepGraph& myGraph; 0078 bool myOwnsScope; 0079 }; 0080 0081 #endif // _BRepGraph_DeferredScope_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|