diff options
author | Morgan Deters <mdeters@gmail.com> | 2009-11-17 17:09:13 +0000 |
---|---|---|
committer | Morgan Deters <mdeters@gmail.com> | 2009-11-17 17:09:13 +0000 |
commit | 105503064be6a198dd864d1e95d6d79e1af51d25 (patch) | |
tree | 040d1dfc2d696c2efef84cf2cb044072d97a337a /src/util/unique_id.h | |
parent | 61330b862f7b5565f70e3c1f4d26a8c51a0f534a (diff) |
from meeting
Diffstat (limited to 'src/util/unique_id.h')
-rw-r--r-- | src/util/unique_id.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/util/unique_id.h b/src/util/unique_id.h new file mode 100644 index 000000000..1a6f3427a --- /dev/null +++ b/src/util/unique_id.h @@ -0,0 +1,35 @@ +/********************* -*- C++ -*- */ +/** unique_id.h + ** This file is part of the CVC4 prototype. + ** Copyright (c) 2009 The Analysis of Computer Systems Group (ACSys) + ** Courant Institute of Mathematical Sciences + ** New York University + ** See the file COPYING in the top-level source directory for licensing + ** information. + ** + **/ + +#ifndef __CVC4_UNIQUE_ID_H +#define __CVC4_UNIQUE_ID_H + +namespace CVC4 { + +// NOTE that UniqueID is intended for startup registration; it +// shouldn't be used in multi-threaded contexts. + +template <class T> +class UniqueID { + static unsigned s_topID; + const unsigned d_thisID; + +public: + UniqueID() : d_thisID( s_topID++ ) { } + operator unsigned() const { return d_thisID; } +}; + +template <class T> +unsigned UniqueID<T>::s_topID = 0; + +} /* CVC4 namespace */ + +#endif /* __CVC4_UNIQUE_ID_H */ |