diff options
Diffstat (limited to 'Source/cmListFileCache.h')
-rw-r--r-- | Source/cmListFileCache.h | 56 |
1 files changed, 46 insertions, 10 deletions
diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h index d3cab22..9fa8585 100644 --- a/Source/cmListFileCache.h +++ b/Source/cmListFileCache.h @@ -87,17 +87,53 @@ struct cmListFileFunction: public cmCommandContext std::vector<cmListFileArgument> Arguments; }; -class cmListFileBacktrace: private std::vector<cmListFileContext> +// Represent a backtrace (call stack). Provide value semantics +// but use efficient reference-counting underneath to avoid copies. +class cmListFileBacktrace { - public: - cmListFileBacktrace(cmState::Snapshot snapshot = cmState::Snapshot(), - cmCommandContext const& cc = cmCommandContext()); - ~cmListFileBacktrace(); - - void PrintTitle(std::ostream& out) const; - void PrintCallStack(std::ostream& out) const; - private: - cmState::Snapshot Snapshot; +public: + // Default-constructed backtrace may not be used until after + // set via assignment from a backtrace constructed with a + // valid snapshot. + cmListFileBacktrace(); + + // Construct an empty backtrace whose bottom sits in the directory + // indicated by the given valid snapshot. + cmListFileBacktrace(cmState::Snapshot snapshot); + + // Backtraces may be copied and assigned as values. + cmListFileBacktrace(cmListFileBacktrace const& r); + cmListFileBacktrace& operator=(cmListFileBacktrace const& r); + ~cmListFileBacktrace(); + + // Get a backtrace with the given file scope added to the top. + // May not be called until after construction with a valid snapshot. + cmListFileBacktrace Push(std::string const& file) const; + + // Get a backtrace with the given call context added to the top. + // May not be called until after construction with a valid snapshot. + cmListFileBacktrace Push(cmListFileContext const& lfc) const; + + // Get a backtrace with the top level removed. + // May not be called until after a matching Push. + cmListFileBacktrace Pop() const; + + // Get the context at the top of the backtrace. + // Returns an empty context if the backtrace is empty. + cmListFileContext const& Top() const; + + // Print the top of the backtrace. + void PrintTitle(std::ostream& out) const; + + // Print the call stack below the top of the backtrace. + void PrintCallStack(std::ostream& out) const; +private: + struct Entry; + cmState::Snapshot Bottom; + Entry* Cur; + cmListFileBacktrace(cmState::Snapshot bottom, Entry* up, + cmListFileContext const& lfc); + cmListFileBacktrace(cmState::Snapshot bottom, Entry* cur); }; struct cmListFile |