diff options
Diffstat (limited to 'Src/nu/ReEntry.h')
-rw-r--r-- | Src/nu/ReEntry.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/Src/nu/ReEntry.h b/Src/nu/ReEntry.h new file mode 100644 index 00000000..87035d29 --- /dev/null +++ b/Src/nu/ReEntry.h @@ -0,0 +1,68 @@ +#ifndef NULLSOFT_UTILITY_RENTRYH +#define NULLSOFT_UTILITY_RENTRYH + +#include <string> + + +namespace Nullsoft +{ + namespace Utility + { + + + class ReEntryGuard + { + public: + ReEntryGuard() : entered(false) + {} + + + bool FunctionCall(std::string funcName = "Unknown") + { + + if (entered) + { + char errorMsg[256]; + sprintf(errorMsg, "%s branched to %s", firstFunc.c_str(), funcName.c_str()); + ::MessageBox(NULL, errorMsg, "Class ReEntry error", MB_OK); + return false; + } + else + { + firstFunc = funcName; + entered = true; + return true; + } + + + } + void LeaveFunction() + { + entered = false; + firstFunc = ""; + } + private: + bool entered; + std::string firstFunc; + + }; + class ReEntry + { + public: + ReEntry(ReEntryGuard &_entry, std::string funcName = "Unknown") : entry(&_entry) + { + entry->FunctionCall(funcName); + } + + ~ReEntry() + { + entry->LeaveFunction(); + } + + private: + ReEntryGuard *entry; + + }; + } +} +#endif |