X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/f5ea2a9375e9fb6fc8dc0720395e761ddd3c11c0..e9ae1f101b5418c0ba2e6c9d86b23c12f0140982:/include/stg/resetable.h?ds=sidebyside diff --git a/include/stg/resetable.h b/include/stg/resetable.h deleted file mode 100644 index a451b357..00000000 --- a/include/stg/resetable.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2001 by Peter Simons . - * All rights reserved. - */ - -#ifndef RESETABLE_VARIABLE_H -#define RESETABLE_VARIABLE_H - -// This is a wrapper class about variables where you want to keep -// track of whether it has been assigened yet or not. - -template -class RESETABLE -{ -public: - typedef T value_type; - - RESETABLE() : value(), is_set(false) {} - RESETABLE(const T & v) : value(v), is_set(true) {} - - RESETABLE(const RESETABLE & rvalue) - : value(rvalue.value), - is_set(rvalue.is_set) - {} - - RESETABLE & operator=(const RESETABLE & rhs) - { - value = rhs.value; - is_set = rhs.is_set; - return *this; - } - - RESETABLE & operator=(const T & rhs) - { - value = rhs; - is_set = true; - return *this; - } - - const T & const_data() const throw() { return value; } - T & data() throw() { return value; } - const T & data() const throw() { return value; } - bool empty() const throw() { return !is_set; } - void reset() throw() { is_set = false; } - void splice(const RESETABLE & rhs) - { - if (rhs.is_set) - { - value = rhs.value; - is_set = true; - } - } - void maybeSet(value_type& dest) const - { - if (is_set) - dest = value; - } - -private: - value_type value; - bool is_set; -}; - -#endif // RESETABLE_VARIABLE_H