2013-10-14 00:05:57 +00:00
|
|
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
|
|
|
//*************************************************************************
|
|
|
|
//
|
2017-01-15 17:09:59 +00:00
|
|
|
// Copyright 2013-2017 by Wilson Snyder. This program is free software; you can
|
2013-10-14 00:05:57 +00:00
|
|
|
// redistribute it and/or modify it under the terms of either the GNU
|
2020-03-21 15:24:24 +00:00
|
|
|
// Lesser General Public License Version 3 or the Perl Artistic License
|
2013-10-14 00:05:57 +00:00
|
|
|
// Version 2.0.
|
2020-03-21 15:24:24 +00:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
2013-10-14 00:05:57 +00:00
|
|
|
//
|
|
|
|
//*************************************************************************
|
|
|
|
|
|
|
|
#include "vpi_user.h"
|
|
|
|
|
|
|
|
//======================================================================
|
|
|
|
|
|
|
|
class TestVpiHandle {
|
|
|
|
/// For testing, etc, wrap vpiHandle in an auto-releasing class
|
|
|
|
vpiHandle m_handle;
|
2019-11-10 01:35:12 +00:00
|
|
|
bool m_free;
|
|
|
|
|
2013-10-14 00:05:57 +00:00
|
|
|
public:
|
2019-11-10 01:35:12 +00:00
|
|
|
TestVpiHandle()
|
2020-08-24 22:49:36 +00:00
|
|
|
: m_handle(NULL)
|
2019-11-10 01:35:12 +00:00
|
|
|
, m_free(true) {}
|
|
|
|
TestVpiHandle(vpiHandle h)
|
|
|
|
: m_handle(h)
|
|
|
|
, m_free(true) {}
|
|
|
|
~TestVpiHandle() {
|
|
|
|
if (m_handle && m_free) {
|
2020-08-24 22:49:36 +00:00
|
|
|
{ vpi_free_object(m_handle); m_handle = NULL; }
|
2019-11-10 01:35:12 +00:00
|
|
|
}
|
|
|
|
}
|
2018-08-25 13:52:45 +00:00
|
|
|
operator vpiHandle() const { return m_handle; }
|
2019-11-10 01:35:12 +00:00
|
|
|
inline TestVpiHandle& operator=(vpiHandle h) {
|
|
|
|
m_handle = h;
|
|
|
|
return *this;
|
|
|
|
}
|
2013-10-14 00:05:57 +00:00
|
|
|
TestVpiHandle& nofree() {
|
2018-10-27 14:03:28 +00:00
|
|
|
m_free = false;
|
2013-10-14 00:05:57 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
};
|