diff options
Diffstat (limited to 'vendor/bandit/bandit/run_policies/run_policy.h')
-rw-r--r-- | vendor/bandit/bandit/run_policies/run_policy.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/vendor/bandit/bandit/run_policies/run_policy.h b/vendor/bandit/bandit/run_policies/run_policy.h new file mode 100644 index 00000000..4a6e8e1d --- /dev/null +++ b/vendor/bandit/bandit/run_policies/run_policy.h @@ -0,0 +1,44 @@ +#ifndef BANDIT_RUN_POLICY_H +#define BANDIT_RUN_POLICY_H + +namespace bandit { namespace detail { + + struct run_policy + { + run_policy() : encountered_failure_(false) {} + run_policy(const run_policy& other) = default; + run_policy(run_policy&&) = default; + virtual ~run_policy() {} + + virtual bool should_run(const char* it_name, const contextstack_t& contexts) const = 0; + + virtual void encountered_failure() + { + encountered_failure_ = true; + } + + virtual bool has_encountered_failure() const + { + return encountered_failure_; + } + + private: + bool encountered_failure_; + }; + typedef std::unique_ptr<run_policy> run_policy_ptr; + + inline run_policy& registered_run_policy(run_policy* policy = NULL) + { + static struct run_policy* policy_; + + if(policy) + { + policy_ = policy; + } + + return *policy_; + } + +}} + +#endif |