mirror of
https://github.com/holub/mame
synced 2025-04-23 00:39:36 +03:00
netlist: More cpp core guidelines alignment. (nw)
This commit is contained in:
parent
b628a80dee
commit
a905dffd08
@ -14,14 +14,14 @@ VSBUILD = $(SRC)/buildVS
|
||||
DOC = $(SRC)/documentation
|
||||
TIDY_DB = ../compile_commands.json
|
||||
|
||||
TIDY_FLAGSX = -checks=*,-google*,-hicpp*,-readability*,-fuchsia*,-cert-*,
|
||||
TIDY_FLAGSX = -checks=*,-google*,-hicpp*,-readability*,-fuchsia*,-cert-*,-android-*,
|
||||
TIDY_FLAGSX += -llvm-header-guard,-cppcoreguidelines-pro-type-reinterpret-cast,
|
||||
TIDY_FLAGSX += -cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-owning-memory,
|
||||
TIDY_FLAGSX += -modernize-use-default-member-init,-cppcoreguidelines-pro-bounds-constant-array-index,
|
||||
TIDY_FLAGSX += -modernize-pass-by-value,-cppcoreguidelines-pro-type-static-cast-downcast,
|
||||
//TIDY_FLAGSX += -cppcoreguidelines-special-member-functions,
|
||||
TIDY_FLAGSX += -cppcoreguidelines-pro-bounds-array-to-pointer-decay,
|
||||
TIDY_FLAGSX += -performance-unnecessary-value-param,-android-*,-cppcoreguidelines-avoid-magic-numbers,
|
||||
#TIDY_FLAGSX += -cppcoreguidelines-special-member-functions,
|
||||
#TIDY_FLAGSX += -cppcoreguidelines-pro-bounds-array-to-pointer-decay,
|
||||
TIDY_FLAGSX += -performance-unnecessary-value-param,-cppcoreguidelines-avoid-magic-numbers,
|
||||
TIDY_FLAGSX += -cppcoreguidelines-macro-usage,
|
||||
TIDY_FLAGSX += -cppcoreguidelines-non-private-member-variables-in-classes,-misc-non-private-member-variables-in-classes,
|
||||
#TIDY_FLAGSX += -cppcoreguidelines-avoid-c-arrays,-modernize-avoid-c-arrays,
|
||||
@ -33,6 +33,7 @@ space :=
|
||||
space +=
|
||||
TIDY_FLAGS = $(subst $(space),,$(TIDY_FLAGSX))
|
||||
|
||||
#TIDY_FLAGS = -checks=llvm-include-order,llvm-namespace-comment,modernize-use-override,modernize-use-using -fix
|
||||
#TIDY_FLAGS = -checks=llvm-include-order -fix
|
||||
#TIDY_FLAGS = -checks=llvm-namespace-comment -fix
|
||||
#TIDY_FLAGS = -checks=modernize-use-override -fix
|
||||
@ -235,7 +236,7 @@ native:
|
||||
$(MAKE) CEXTRAFLAGS="-march=native -Wall -Wpedantic -Wsign-compare -Wextra -Wno-unused-parameter"
|
||||
|
||||
clang:
|
||||
$(MAKE) CC=clang++-9 LD=clang++-9 CEXTRAFLAGS="-march=native -Wno-unused-parameter -Weverything -Werror -Wno-unreachable-code -Wno-padded -Wno-weak-vtables -Wno-missing-variable-declarations -Wconversion -Wno-c++98-compat -Wno-float-equal -Wno-global-constructors -Wno-c++98-compat-pedantic -Wno-format-nonliteral -Wweak-template-vtables -Wno-exit-time-destructors"
|
||||
$(MAKE) CC=clang++-9 LD=clang++-9 CEXTRAFLAGS="-march=native -Wno-unused-parameter -Weverything -Werror -Wno-non-virtual-dtor -Wno-unreachable-code -Wno-padded -Wno-weak-vtables -Wno-missing-variable-declarations -Wconversion -Wno-c++98-compat -Wno-float-equal -Wno-global-constructors -Wno-c++98-compat-pedantic -Wno-format-nonliteral -Wweak-template-vtables -Wno-exit-time-destructors"
|
||||
|
||||
clang-5:
|
||||
$(MAKE) CC=clang++-5.0 LD=clang++-5.0 CEXTRAFLAGS="-march=native -Weverything -Werror -Wno-inconsistent-missing-destructor-override -Wno-unreachable-code -Wno-padded -Wno-weak-vtables -Wno-missing-variable-declarations -Wconversion -Wno-c++98-compat -Wno-float-equal -Wno-global-constructors -Wno-c++98-compat-pedantic -Wno-format-nonliteral -Wno-weak-template-vtables -Wno-exit-time-destructors"
|
||||
|
@ -5,6 +5,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "nlid_truthtable.h"
|
||||
#include "nld_7448.h"
|
||||
|
||||
@ -135,7 +137,7 @@ namespace netlist
|
||||
|
||||
#define BITS7(b6,b5,b4,b3,b2,b1,b0) ((b6)<<6) | ((b5)<<5) | ((b4)<<4) | ((b3)<<3) | ((b2)<<2) | ((b1)<<1) | ((b0)<<0)
|
||||
|
||||
static constexpr uint8_t tab7448[16] =
|
||||
static constexpr std::array<uint8_t, 16> tab7448 =
|
||||
{
|
||||
BITS7( 1, 1, 1, 1, 1, 1, 0 ), /* 00 - not blanked ! */
|
||||
BITS7( 0, 1, 1, 0, 0, 0, 0 ), /* 01 */
|
||||
|
@ -68,10 +68,10 @@ namespace netlist
|
||||
m_B.activate();
|
||||
m_C.activate();
|
||||
m_D.activate();
|
||||
unsigned t1 = m_A() & m_B();
|
||||
unsigned t2 = m_C() & m_D();
|
||||
auto t1 = m_A() & m_B();
|
||||
auto t2 = m_C() & m_D();
|
||||
|
||||
const netlist_time times[2] = { NLTIME_FROM_NS(22), NLTIME_FROM_NS(15) };
|
||||
const netlist_time times[2] = { NLTIME_FROM_NS(15), NLTIME_FROM_NS(22) };
|
||||
|
||||
uint_fast8_t res = 0;
|
||||
if (t1 ^ 1)
|
||||
@ -85,14 +85,16 @@ namespace netlist
|
||||
m_A.inactivate();
|
||||
m_B.inactivate();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (t2 ^ 1)
|
||||
{
|
||||
m_C.inactivate();
|
||||
m_D.inactivate();
|
||||
}
|
||||
}
|
||||
m_Q.push(res, times[1 - res]);// ? 22000 : 15000);
|
||||
m_Q.push(res, times[res]);// ? 22000 : 15000);
|
||||
}
|
||||
|
||||
NETLIB_DEVICE_IMPL(7450, "TTL_7450_ANDORINVERT", "+A,+B,+C,+D")
|
||||
|
@ -120,7 +120,7 @@ namespace netlist
|
||||
m_last_B = new_B;
|
||||
}
|
||||
|
||||
NETLIB_FUNC_VOID(7490, update_outputs, (void))
|
||||
NETLIB_FUNC_VOID(7490, update_outputs, ())
|
||||
{
|
||||
for (std::size_t i=0; i<4; i++)
|
||||
m_Q[i].push((m_cnt >> i) & 1, delay[i]);
|
||||
|
@ -116,7 +116,7 @@ namespace netlist
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
NETLIB_FUNC_VOID(Am2847_shifter, shift, (void))
|
||||
NETLIB_FUNC_VOID(Am2847_shifter, shift, ())
|
||||
{
|
||||
uint32_t out = m_buffer[0] & 1;
|
||||
uint32_t in = (m_RC() ? out : m_IN());
|
||||
|
@ -29,8 +29,6 @@ namespace netlist
|
||||
nld_base_proxy(netlist_state_t &anetlist, const pstring &name,
|
||||
logic_t *inout_proxied, detail::core_terminal_t *proxy_inout);
|
||||
|
||||
~nld_base_proxy() override = default;
|
||||
|
||||
logic_t &term_proxied() const { return *m_term_proxied; }
|
||||
detail::core_terminal_t &proxy_term() const { return *m_proxy_term; }
|
||||
|
||||
@ -49,8 +47,6 @@ namespace netlist
|
||||
{
|
||||
public:
|
||||
|
||||
~nld_base_a_to_d_proxy() override = default;
|
||||
|
||||
virtual logic_output_t &out() { return m_Q; }
|
||||
|
||||
protected:
|
||||
@ -69,8 +65,6 @@ namespace netlist
|
||||
public:
|
||||
nld_a_to_d_proxy(netlist_state_t &anetlist, const pstring &name, logic_input_t *in_proxied);
|
||||
|
||||
~nld_a_to_d_proxy() override = default;
|
||||
|
||||
analog_input_t m_I;
|
||||
|
||||
protected:
|
||||
@ -88,7 +82,6 @@ namespace netlist
|
||||
NETLIB_OBJECT_DERIVED(base_d_to_a_proxy, base_proxy)
|
||||
{
|
||||
public:
|
||||
~nld_base_d_to_a_proxy() override = default;
|
||||
|
||||
virtual logic_input_t &in() { return m_I; }
|
||||
|
||||
@ -105,7 +98,6 @@ namespace netlist
|
||||
{
|
||||
public:
|
||||
nld_d_to_a_proxy(netlist_state_t &anetlist, const pstring &name, logic_output_t *out_proxied);
|
||||
~nld_d_to_a_proxy() override = default;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -28,7 +28,7 @@ namespace netlist
|
||||
{
|
||||
NETLIB_CONSTRUCTOR(netlistparams)
|
||||
, m_use_deactivate(*this, "USE_DEACTIVATE", false)
|
||||
, m_startup_strategy(*this, "STARTUP_STRATEGY", 1)
|
||||
, m_startup_strategy(*this, "STARTUP_STRATEGY", 0)
|
||||
{
|
||||
}
|
||||
NETLIB_UPDATEI() { }
|
||||
|
@ -219,8 +219,6 @@ namespace devices
|
||||
netlist_base_factory_truthtable_t(const pstring &name, const pstring &classname,
|
||||
const pstring &def_param, const pstring &sourcefile);
|
||||
|
||||
~netlist_base_factory_truthtable_t() override = default;
|
||||
|
||||
std::vector<pstring> m_desc;
|
||||
const logic_family_desc_t *m_family;
|
||||
};
|
||||
|
@ -27,6 +27,7 @@ namespace netlist
|
||||
*/
|
||||
using netlist_sig_t = std::uint32_t;
|
||||
|
||||
/* FIXME: belongs into nl_base.h to nlstate */
|
||||
/**
|
||||
* @brief Interface definition for netlist callbacks into calling code
|
||||
*
|
||||
@ -38,10 +39,17 @@ namespace netlist
|
||||
class callbacks_t
|
||||
{
|
||||
public:
|
||||
|
||||
callbacks_t() = default;
|
||||
/* what is done before this is passed as a unique_ptr to netlist
|
||||
* we should not limit.
|
||||
*/
|
||||
virtual ~callbacks_t() = default;
|
||||
COPYASSIGNMOVE(callbacks_t, default)
|
||||
|
||||
/* logging callback */
|
||||
virtual void vlog(const plib::plog_level &l, const pstring &ls) const = 0;
|
||||
|
||||
};
|
||||
|
||||
using log_type = plib::plog_base<callbacks_t, NL_DEBUG>;
|
||||
|
@ -141,17 +141,13 @@ const logic_family_desc_t *family_CD4XXX()
|
||||
detail::queue_t::queue_t(netlist_state_t &nl)
|
||||
: timed_queue<pqentry_t<net_t *, netlist_time>, false, NL_KEEP_STATISTICS>(512)
|
||||
, netlist_ref(nl)
|
||||
, plib::state_manager_t::callback_t()
|
||||
// , plib::state_manager_t::callback_t()
|
||||
, m_qsize(0)
|
||||
, m_times(512)
|
||||
, m_net_ids(512)
|
||||
{
|
||||
}
|
||||
|
||||
detail::queue_t::~queue_t()
|
||||
{
|
||||
}
|
||||
|
||||
void detail::queue_t::register_state(plib::state_manager_t &manager, const pstring &module)
|
||||
{
|
||||
//state().log().debug("register_state\n");
|
||||
|
@ -227,8 +227,6 @@ namespace netlist
|
||||
explicit nl_exception(const pstring &text //!< text to be passed
|
||||
)
|
||||
: plib::pexception(text) { }
|
||||
/*! Copy constructor. */
|
||||
nl_exception(const nl_exception &e) = default;
|
||||
};
|
||||
|
||||
/*! Logic families descriptors are used to create proxy devices.
|
||||
@ -239,7 +237,10 @@ namespace netlist
|
||||
{
|
||||
public:
|
||||
logic_family_desc_t();
|
||||
virtual ~logic_family_desc_t() = default;
|
||||
|
||||
COPYASSIGNMOVE(logic_family_desc_t, delete)
|
||||
|
||||
virtual ~logic_family_desc_t() noexcept = default;
|
||||
|
||||
virtual plib::owned_ptr<devices::nld_base_d_to_a_proxy> create_d_a_proxy(netlist_state_t &anetlist, const pstring &name,
|
||||
logic_output_t *proxied) const = 0;
|
||||
@ -279,12 +280,14 @@ namespace netlist
|
||||
public:
|
||||
|
||||
logic_family_t() : m_logic_family(nullptr) {}
|
||||
COPYASSIGNMOVE(logic_family_t, delete)
|
||||
|
||||
|
||||
const logic_family_desc_t *logic_family() const { return m_logic_family; }
|
||||
void set_logic_family(const logic_family_desc_t *fam) { m_logic_family = fam; }
|
||||
|
||||
protected:
|
||||
~logic_family_t() = default; // prohibit polymorphic destruction
|
||||
~logic_family_t() noexcept = default; // prohibit polymorphic destruction
|
||||
const logic_family_desc_t *m_logic_family;
|
||||
};
|
||||
|
||||
@ -314,6 +317,9 @@ namespace netlist
|
||||
const pstring &name, //!< identifier/name for this state variable
|
||||
const T &value //!< Initial value after construction
|
||||
);
|
||||
|
||||
//! Destructor.
|
||||
~state_var() noexcept = default;
|
||||
//! Copy Constructor.
|
||||
constexpr state_var(const state_var &rhs) = default;
|
||||
//! Move Constructor.
|
||||
@ -353,9 +359,13 @@ namespace netlist
|
||||
);
|
||||
//! Copy Constructor.
|
||||
state_array(const state_array &rhs) NL_NOEXCEPT = default;
|
||||
//! Destructor.
|
||||
~state_array() noexcept = default;
|
||||
//! Move Constructor.
|
||||
state_array(state_array &&rhs) NL_NOEXCEPT = default;
|
||||
state_array &operator=(const state_array &rhs) NL_NOEXCEPT = default;
|
||||
state_array &operator=(state_array &&rhs) NL_NOEXCEPT = default;
|
||||
|
||||
state_array &operator=(const T &rhs) NL_NOEXCEPT { m_value = rhs; return *this; }
|
||||
T & operator[](const std::size_t i) NL_NOEXCEPT { return m_value[i]; }
|
||||
constexpr const T & operator[](const std::size_t i) const NL_NOEXCEPT { return m_value[i]; }
|
||||
@ -390,7 +400,7 @@ namespace netlist
|
||||
* memory allocation to enhance locality. Please refer to \ref USE_MEMPOOL as
|
||||
* well.
|
||||
*/
|
||||
class detail::object_t : public plib::nocopyassignmove
|
||||
class detail::object_t
|
||||
{
|
||||
public:
|
||||
|
||||
@ -400,6 +410,7 @@ namespace netlist
|
||||
*/
|
||||
explicit object_t(const pstring &aname /*!< string containing name of the object */);
|
||||
|
||||
COPYASSIGNMOVE(object_t, delete)
|
||||
/*! return name of the object
|
||||
*
|
||||
* \returns name of the object.
|
||||
@ -411,7 +422,7 @@ namespace netlist
|
||||
void * operator new (size_t size);
|
||||
void operator delete (void * mem);
|
||||
protected:
|
||||
~object_t() = default; // only childs should be destructible
|
||||
~object_t() noexcept = default; // only childs should be destructible
|
||||
|
||||
private:
|
||||
//pstring m_name;
|
||||
@ -426,6 +437,8 @@ namespace netlist
|
||||
{
|
||||
explicit netlist_ref(netlist_state_t &nl);
|
||||
|
||||
COPYASSIGNMOVE(netlist_ref, delete)
|
||||
|
||||
netlist_state_t & state() noexcept;
|
||||
const netlist_state_t & state() const noexcept;
|
||||
|
||||
@ -512,7 +525,9 @@ namespace netlist
|
||||
|
||||
core_terminal_t(core_device_t &dev, const pstring &aname,
|
||||
const state_e state, nldelegate delegate = nldelegate());
|
||||
virtual ~core_terminal_t() = default;
|
||||
virtual ~core_terminal_t() noexcept = default;
|
||||
|
||||
COPYASSIGNMOVE(core_terminal_t, delete)
|
||||
|
||||
/*! The object type.
|
||||
* \returns type of the object
|
||||
@ -713,7 +728,10 @@ namespace netlist
|
||||
};
|
||||
|
||||
net_t(netlist_state_t &nl, const pstring &aname, core_terminal_t *mr = nullptr);
|
||||
virtual ~net_t() = default;
|
||||
|
||||
COPYASSIGNMOVE(net_t, delete)
|
||||
|
||||
virtual ~net_t() noexcept = default;
|
||||
|
||||
void reset();
|
||||
|
||||
@ -916,6 +934,8 @@ namespace netlist
|
||||
|
||||
param_t(device_t &device, const pstring &name);
|
||||
|
||||
COPYASSIGNMOVE(param_t, delete)
|
||||
|
||||
param_type_t param_type() const;
|
||||
|
||||
protected:
|
||||
@ -946,6 +966,7 @@ namespace netlist
|
||||
{
|
||||
public:
|
||||
param_num_t(device_t &device, const pstring &name, const T val);
|
||||
|
||||
const T operator()() const NL_NOEXCEPT { return m_param; }
|
||||
void setTo(const T ¶m) { set(m_param, param); }
|
||||
private:
|
||||
@ -1086,7 +1107,9 @@ namespace netlist
|
||||
core_device_t(netlist_state_t &owner, const pstring &name);
|
||||
core_device_t(core_device_t &owner, const pstring &name);
|
||||
|
||||
virtual ~core_device_t() = default;
|
||||
COPYASSIGNMOVE(core_device_t, delete)
|
||||
|
||||
virtual ~core_device_t() noexcept = default;
|
||||
|
||||
void do_inc_active() NL_NOEXCEPT
|
||||
{
|
||||
@ -1155,6 +1178,8 @@ namespace netlist
|
||||
device_t(netlist_state_t &owner, const pstring &name);
|
||||
device_t(core_device_t &owner, const pstring &name);
|
||||
|
||||
COPYASSIGNMOVE(device_t, delete)
|
||||
|
||||
~device_t() override = default;
|
||||
|
||||
setup_t &setup();
|
||||
@ -1221,7 +1246,6 @@ namespace netlist
|
||||
public:
|
||||
using entry_t = pqentry_t<net_t *, netlist_time>;
|
||||
explicit queue_t(netlist_state_t &nl);
|
||||
~queue_t();
|
||||
|
||||
protected:
|
||||
|
||||
@ -1250,7 +1274,9 @@ namespace netlist
|
||||
std::unique_ptr<callbacks_t> &&callbacks,
|
||||
std::unique_ptr<setup_t> &&setup);
|
||||
|
||||
~netlist_state_t() = default;
|
||||
COPYASSIGNMOVE(netlist_state_t, delete)
|
||||
|
||||
~netlist_state_t() noexcept = default;
|
||||
|
||||
friend class netlist_t; // allow access to private members
|
||||
|
||||
@ -1378,7 +1404,10 @@ namespace netlist
|
||||
public:
|
||||
|
||||
explicit netlist_t(const pstring &aname, std::unique_ptr<callbacks_t> callbacks);
|
||||
~netlist_t() = default;
|
||||
|
||||
COPYASSIGNMOVE(netlist_t, delete)
|
||||
|
||||
~netlist_t() noexcept = default;
|
||||
|
||||
/* run functions */
|
||||
|
||||
|
@ -52,11 +52,6 @@ namespace netlist { namespace factory
|
||||
{
|
||||
}
|
||||
|
||||
list_t::~list_t()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void list_t::register_device(std::unique_ptr<element_t> &&factory)
|
||||
{
|
||||
for (auto & e : *this)
|
||||
|
@ -42,7 +42,7 @@ namespace factory {
|
||||
// net_dev class factory
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
class element_t : plib::nocopyassignmove
|
||||
class element_t
|
||||
{
|
||||
public:
|
||||
element_t(const pstring &name, const pstring &classname,
|
||||
@ -51,6 +51,8 @@ namespace factory {
|
||||
const pstring &def_param, const pstring &sourcefile);
|
||||
virtual ~element_t() = default;
|
||||
|
||||
COPYASSIGNMOVE(element_t, default)
|
||||
|
||||
virtual plib::owned_ptr<device_t> Create(netlist_state_t &anetlist, const pstring &name) = 0;
|
||||
virtual void macro_actions(netlist_state_t &anetlist, const pstring &name)
|
||||
{
|
||||
@ -91,7 +93,9 @@ namespace factory {
|
||||
{
|
||||
public:
|
||||
explicit list_t(setup_t &m_setup);
|
||||
~list_t();
|
||||
~list_t() = default;
|
||||
|
||||
COPYASSIGNMOVE(list_t, delete)
|
||||
|
||||
template<class device_class>
|
||||
void register_device(const pstring &name, const pstring &classname,
|
||||
|
@ -34,14 +34,14 @@ setup_t::setup_t(netlist_t &netlist)
|
||||
{
|
||||
}
|
||||
|
||||
setup_t::~setup_t()
|
||||
setup_t::~setup_t() noexcept
|
||||
{
|
||||
// FIXME: can't see a need any longer
|
||||
m_links.clear();
|
||||
m_alias.clear();
|
||||
m_params.clear();
|
||||
m_terminals.clear();
|
||||
m_param_values.clear();
|
||||
|
||||
m_sources.clear();
|
||||
}
|
||||
|
||||
|
@ -140,6 +140,7 @@ namespace netlist
|
||||
|
||||
struct tt_desc
|
||||
{
|
||||
tt_desc() : ni(0), no(0) { }
|
||||
pstring name;
|
||||
pstring classname;
|
||||
unsigned long ni;
|
||||
@ -187,7 +188,9 @@ namespace netlist
|
||||
: m_setup(setup), m_type(type)
|
||||
{}
|
||||
|
||||
virtual ~source_t() = default;
|
||||
COPYASSIGNMOVE(source_t, delete)
|
||||
|
||||
virtual ~source_t() noexcept = default;
|
||||
|
||||
virtual bool parse(const pstring &name);
|
||||
setup_t &setup() { return m_setup; }
|
||||
@ -206,15 +209,16 @@ namespace netlist
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class setup_t : plib::nocopyassignmove
|
||||
class setup_t
|
||||
{
|
||||
public:
|
||||
|
||||
using link_t = std::pair<pstring, pstring>;
|
||||
|
||||
explicit setup_t(netlist_t &netlist);
|
||||
~setup_t();
|
||||
~setup_t() noexcept;
|
||||
|
||||
COPYASSIGNMOVE(setup_t, delete)
|
||||
|
||||
netlist_state_t &netlist();
|
||||
const netlist_state_t &netlist() const;
|
||||
|
@ -30,6 +30,8 @@ namespace netlist
|
||||
|
||||
constexpr ptime() noexcept : m_time(0) {}
|
||||
|
||||
~ptime() noexcept = default;
|
||||
|
||||
constexpr ptime(const ptime &rhs) noexcept = default;
|
||||
constexpr ptime(ptime &&rhs) noexcept = default;
|
||||
constexpr explicit ptime(const internal_type &time) noexcept : m_time(time) {}
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "pconfig.h"
|
||||
#include "pomp.h"
|
||||
#include "pstate.h"
|
||||
#include "ptypes.h"
|
||||
#include "putil.h"
|
||||
|
||||
namespace plib
|
||||
@ -33,6 +34,8 @@ namespace plib
|
||||
using index_type = C;
|
||||
using value_type = T;
|
||||
|
||||
COPYASSIGNMOVE(matrix_compressed_rows_t, default)
|
||||
|
||||
enum constants_e
|
||||
{
|
||||
FILL_INFINITY = 9999999
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "palloc.h"
|
||||
#include "pexception.h"
|
||||
#include "pfmtlog.h"
|
||||
#include "pstream.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@ -28,7 +29,7 @@ mempool::~mempool()
|
||||
{
|
||||
if (b->m_num_alloc != 0)
|
||||
{
|
||||
fprintf(stderr, "Found block with %d dangling allocations\n", static_cast<int>(b->m_num_alloc));
|
||||
perrlogger("Found block with {} dangling allocations\n", b->m_num_alloc);
|
||||
}
|
||||
::operator delete(b->data);
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
#define PALLOC_H_
|
||||
|
||||
#include "pstring.h"
|
||||
#include "ptypes.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
@ -92,6 +93,15 @@ public:
|
||||
r.m_ptr = nullptr;
|
||||
}
|
||||
|
||||
owned_ptr &operator=(owned_ptr &&r) noexcept
|
||||
{
|
||||
m_is_owned = r.m_is_owned;
|
||||
m_ptr = r.m_ptr;
|
||||
r.m_is_owned = false;
|
||||
r.m_ptr = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename DC>
|
||||
owned_ptr(owned_ptr<DC> &&r) noexcept
|
||||
{
|
||||
@ -169,6 +179,9 @@ private:
|
||||
|
||||
public:
|
||||
mempool(size_t min_alloc, size_t min_align);
|
||||
|
||||
COPYASSIGNMOVE(mempool, delete)
|
||||
|
||||
~mempool();
|
||||
|
||||
void *alloc(size_t size);
|
||||
|
@ -9,6 +9,7 @@
|
||||
#define PCHRONO_H_
|
||||
|
||||
#include "pconfig.h"
|
||||
#include "ptypes.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
@ -175,10 +176,11 @@ namespace chrono {
|
||||
struct guard_t
|
||||
{
|
||||
guard_t() = delete;
|
||||
guard_t(const guard_t &g) noexcept = default;
|
||||
guard_t(guard_t &&g) noexcept = default;
|
||||
guard_t(timer &m) noexcept : m_m(m) { m_m.m_time -= T::start(); }
|
||||
~guard_t() { m_m.m_time += T::stop(); ++m_m.m_count; }
|
||||
|
||||
COPYASSIGNMOVE(guard_t, default)
|
||||
|
||||
private:
|
||||
timer &m_m;
|
||||
};
|
||||
@ -212,8 +214,7 @@ namespace chrono {
|
||||
struct guard_t
|
||||
{
|
||||
guard_t() = default;
|
||||
guard_t(const guard_t &g) noexcept = default;
|
||||
guard_t(guard_t &&g) noexcept = default;
|
||||
COPYASSIGNMOVE(guard_t, default)
|
||||
/* using default constructor will trigger warning on
|
||||
* unused local variable.
|
||||
*/
|
||||
|
@ -8,18 +8,21 @@
|
||||
#define PDYNLIB_H_
|
||||
|
||||
#include "pstring.h"
|
||||
#include "ptypes.h"
|
||||
|
||||
namespace plib {
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// pdynlib: dynamic loading of libraries ...
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
class dynlib
|
||||
class dynlib : public nocopyassignmove
|
||||
{
|
||||
public:
|
||||
explicit dynlib(const pstring libname);
|
||||
dynlib(const pstring path, const pstring libname);
|
||||
|
||||
~dynlib();
|
||||
COPYASSIGNMOVE(dynlib, delete)
|
||||
|
||||
bool isLoaded() const;
|
||||
|
||||
|
@ -87,10 +87,13 @@ static constexpr unsigned FP_ALL = 0x0001f;
|
||||
* Catch SIGFPE on linux for debugging purposes.
|
||||
*/
|
||||
|
||||
class fpsignalenabler : public nocopyassignmove
|
||||
class fpsignalenabler
|
||||
{
|
||||
public:
|
||||
explicit fpsignalenabler(unsigned fpexceptions);
|
||||
|
||||
COPYASSIGNMOVE(fpsignalenabler, delete)
|
||||
|
||||
~fpsignalenabler();
|
||||
|
||||
/* is the functionality supported ? */
|
||||
|
@ -157,8 +157,9 @@ public:
|
||||
: m_str(fmt), m_arg(0)
|
||||
{
|
||||
}
|
||||
pfmt(const pfmt &rhs) = default;
|
||||
~pfmt() = default;
|
||||
COPYASSIGNMOVE(pfmt, default)
|
||||
|
||||
~pfmt() noexcept = default;
|
||||
|
||||
operator pstring() const { return m_str; }
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
|
||||
@ -215,11 +216,13 @@ private:
|
||||
};
|
||||
|
||||
template <class T, bool build_enabled = true>
|
||||
class pfmt_writer_t : plib::nocopyassignmove
|
||||
class pfmt_writer_t
|
||||
{
|
||||
public:
|
||||
explicit pfmt_writer_t() : m_enabled(true) { }
|
||||
|
||||
COPYASSIGNMOVE(pfmt_writer_t, delete)
|
||||
|
||||
/* runtime enable */
|
||||
template<bool enabled, typename... Args>
|
||||
void log(const pstring & fmt, Args&&... args) const
|
||||
@ -249,7 +252,7 @@ public:
|
||||
bool is_enabled() const { return m_enabled; }
|
||||
|
||||
protected:
|
||||
~pfmt_writer_t() = default;
|
||||
~pfmt_writer_t() noexcept = default;
|
||||
|
||||
private:
|
||||
pfmt &xlog(pfmt &fmt) const { return fmt; }
|
||||
@ -270,7 +273,10 @@ class plog_channel : public pfmt_writer_t<plog_channel<T, L, build_enabled>, bui
|
||||
friend class pfmt_writer_t<plog_channel<T, L, build_enabled>, build_enabled>;
|
||||
public:
|
||||
explicit plog_channel(T &b) : pfmt_writer_t<plog_channel, build_enabled>(), m_base(b) { }
|
||||
~plog_channel() = default;
|
||||
|
||||
COPYASSIGNMOVE(plog_channel, delete)
|
||||
|
||||
~plog_channel() noexcept = default;
|
||||
|
||||
protected:
|
||||
void vdowrite(const pstring &ls) const
|
||||
@ -295,7 +301,9 @@ public:
|
||||
error(proxy),
|
||||
fatal(proxy)
|
||||
{}
|
||||
virtual ~plog_base() = default;
|
||||
|
||||
COPYASSIGNMOVE(plog_base, default)
|
||||
virtual ~plog_base() noexcept = default;
|
||||
|
||||
plog_channel<T, plog_level::DEBUG, debug_enabled> debug;
|
||||
plog_channel<T, plog_level::INFO> info;
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
#include "pstring.h"
|
||||
|
||||
#include <array>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
namespace plib {
|
||||
@ -34,6 +36,7 @@ public:
|
||||
|
||||
uninitialised_array_t() = default;
|
||||
|
||||
COPYASSIGNMOVE(uninitialised_array_t, delete)
|
||||
~uninitialised_array_t()
|
||||
{
|
||||
for (std::size_t i=0; i<N; i++)
|
||||
@ -74,7 +77,7 @@ private:
|
||||
|
||||
/* ensure proper alignment */
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays, modernize-avoid-c-arrays)
|
||||
typename std::aligned_storage<sizeof(C), alignof(C)>::type m_buf[N];
|
||||
std::array<typename std::aligned_storage<sizeof(C), alignof(C)>::type, N> m_buf;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
@ -180,14 +183,12 @@ public:
|
||||
friend class linkedlist_t<LC>;
|
||||
|
||||
constexpr element_t() : m_next(nullptr), m_prev(nullptr) {}
|
||||
constexpr element_t(const element_t &rhs) = delete;
|
||||
constexpr element_t(element_t &&rhs) = delete;
|
||||
~element_t() noexcept = default;
|
||||
|
||||
COPYASSIGNMOVE(element_t, delete)
|
||||
|
||||
constexpr LC *next() const noexcept { return m_next; }
|
||||
constexpr LC *prev() const noexcept { return m_prev; }
|
||||
|
||||
protected:
|
||||
~element_t() = default;
|
||||
private:
|
||||
LC * m_next;
|
||||
LC * m_prev;
|
||||
@ -205,6 +206,9 @@ public:
|
||||
iter_t& operator=(iter_t &&rhs) noexcept { std::swap(*this, rhs); return *this; }
|
||||
iter_t& operator++() noexcept {p = p->next();return *this;}
|
||||
iter_t operator++(int) noexcept {iter_t tmp(*this); operator++(); return tmp;}
|
||||
|
||||
~iter_t() = default;
|
||||
|
||||
constexpr bool operator==(const iter_t& rhs) const noexcept {return p == rhs.p;}
|
||||
constexpr bool operator!=(const iter_t& rhs) const noexcept {return p != rhs.p;}
|
||||
/* constexpr */ LC& operator*() noexcept {return *p;}
|
||||
|
@ -36,6 +36,9 @@ namespace plib {
|
||||
{
|
||||
public:
|
||||
app();
|
||||
|
||||
COPYASSIGNMOVE(app, delete)
|
||||
|
||||
virtual ~app() = default;
|
||||
|
||||
virtual pstring usage() = 0;
|
||||
|
@ -62,11 +62,6 @@ namespace plib {
|
||||
}
|
||||
}
|
||||
|
||||
options::~options()
|
||||
{
|
||||
m_opts.clear();
|
||||
}
|
||||
|
||||
void options::register_option(option_base *opt)
|
||||
{
|
||||
m_opts.push_back(opt);
|
||||
|
@ -27,6 +27,8 @@ public:
|
||||
option_base(options &parent, pstring help);
|
||||
virtual ~option_base() = default;
|
||||
|
||||
COPYASSIGNMOVE(option_base, delete)
|
||||
|
||||
pstring help() const { return m_help; }
|
||||
private:
|
||||
pstring m_help;
|
||||
@ -217,15 +219,13 @@ public:
|
||||
{}
|
||||
};
|
||||
|
||||
class options
|
||||
class options : public nocopyassignmove
|
||||
{
|
||||
public:
|
||||
|
||||
options();
|
||||
explicit options(option **o);
|
||||
|
||||
~options();
|
||||
|
||||
void register_option(option_base *opt);
|
||||
int parse(int argc, char **argv);
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
|
||||
namespace plib {
|
||||
class ptokenizer : public nocopyassignmove
|
||||
class ptokenizer
|
||||
{
|
||||
public:
|
||||
template <typename T>
|
||||
@ -26,6 +26,8 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
COPYASSIGNMOVE(ptokenizer, delete)
|
||||
|
||||
virtual ~ptokenizer() = default;
|
||||
|
||||
enum token_type
|
||||
@ -183,6 +185,10 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
COPYASSIGN(ppreprocessor, delete)
|
||||
ppreprocessor &operator=(ppreprocessor &&src) = delete;
|
||||
|
||||
|
||||
ppreprocessor(ppreprocessor &&s) noexcept
|
||||
: m_defines(std::move(s.m_defines))
|
||||
, m_expr_sep(std::move(s.m_expr_sep))
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
std::is_floating_point<T>::value);
|
||||
}
|
||||
|
||||
class callback_t : nocopyassignmove
|
||||
class callback_t
|
||||
{
|
||||
public:
|
||||
using list_t = std::vector<callback_t *>;
|
||||
@ -56,7 +56,9 @@ public:
|
||||
virtual void on_pre_save(state_manager_t &manager) = 0;
|
||||
virtual void on_post_load(state_manager_t &manager) = 0;
|
||||
protected:
|
||||
virtual ~callback_t() = default;
|
||||
callback_t() = default;
|
||||
~callback_t() = default;
|
||||
COPYASSIGNMOVE(callback_t, default)
|
||||
};
|
||||
|
||||
struct entry_t
|
||||
@ -70,8 +72,6 @@ public:
|
||||
entry_t(const pstring &stname, const void *owner, callback_t *callback)
|
||||
: m_name(stname), m_dt(datatype_t(true)), m_owner(owner), m_callback(callback), m_count(0), m_ptr(nullptr) { }
|
||||
|
||||
~entry_t() = default;
|
||||
|
||||
pstring m_name;
|
||||
const datatype_t m_dt;
|
||||
const void * m_owner;
|
||||
@ -81,7 +81,6 @@ public:
|
||||
};
|
||||
|
||||
state_manager_t() = default;
|
||||
~state_manager_t() = default;
|
||||
|
||||
template<typename C>
|
||||
void save_item(const void *owner, C &state, const pstring &stname)
|
||||
|
@ -41,7 +41,7 @@ typedef std::ostringstream pomemstream;
|
||||
// pstream: things common to all streams
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
class pstream : public nocopyassign
|
||||
class pstream
|
||||
{
|
||||
public:
|
||||
|
||||
@ -50,6 +50,9 @@ public:
|
||||
|
||||
static constexpr pos_type SEEK_EOF = static_cast<pos_type>(-1);
|
||||
|
||||
COPYASSIGN(pstream, delete)
|
||||
pstream &operator=(pstream &&) noexcept = delete;
|
||||
|
||||
bool seekable() const { return ((m_flags & FLAG_SEEKABLE) != 0); }
|
||||
|
||||
void seekp(const pos_type n)
|
||||
@ -69,9 +72,8 @@ protected:
|
||||
explicit pstream(const unsigned flags) : m_flags(flags)
|
||||
{
|
||||
}
|
||||
pstream(pstream &&src) noexcept : m_flags(src.m_flags)
|
||||
{
|
||||
}
|
||||
pstream(pstream &&src) noexcept = default;
|
||||
|
||||
virtual ~pstream() = default;
|
||||
|
||||
virtual void vseek(const pos_type n) = 0;
|
||||
@ -105,6 +107,11 @@ public:
|
||||
|
||||
using value_type = T;
|
||||
|
||||
~pistream_base() noexcept override = default;
|
||||
|
||||
COPYASSIGN(pistream_base, delete)
|
||||
pistream_base &operator=(pistream_base &&src) noexcept = delete;
|
||||
|
||||
bool eof() const { return ((flags() & FLAG_EOF) != 0); }
|
||||
|
||||
pos_type read(T *buf, const pos_type n)
|
||||
@ -116,6 +123,7 @@ protected:
|
||||
pistream_base() : pstream(0) {}
|
||||
explicit pistream_base(const unsigned flags) : pstream(flags) {}
|
||||
pistream_base(pistream_base &&src) noexcept : pstream(std::move(src)) {}
|
||||
|
||||
/* read up to n bytes from stream */
|
||||
virtual size_type vread(T *buf, const size_type n) = 0;
|
||||
};
|
||||
@ -134,6 +142,12 @@ public:
|
||||
|
||||
using value_type = T;
|
||||
|
||||
postream_base() = default;
|
||||
~postream_base() noexcept override = default;
|
||||
|
||||
COPYASSIGN(postream_base, delete)
|
||||
postream_base &operator=(postream_base &&src) noexcept = delete;
|
||||
|
||||
void write(const T *buf, const size_type n)
|
||||
{
|
||||
vwrite(buf, n);
|
||||
@ -142,6 +156,7 @@ public:
|
||||
protected:
|
||||
explicit postream_base(unsigned flags) : pstream(flags) {}
|
||||
postream_base(postream_base &&src) noexcept : pstream(std::move(src)) {}
|
||||
|
||||
/* write n bytes to stream */
|
||||
virtual void vwrite(const T *buf, const size_type n) = 0;
|
||||
|
||||
@ -160,6 +175,8 @@ public:
|
||||
|
||||
pomemstream();
|
||||
|
||||
COPYASSIGN(pomemstream, delete)
|
||||
|
||||
pomemstream(pomemstream &&src) noexcept
|
||||
: postream(std::move(src))
|
||||
, m_pos(src.m_pos)
|
||||
@ -169,6 +186,7 @@ public:
|
||||
{
|
||||
src.m_mem = nullptr;
|
||||
}
|
||||
pomemstream &operator=(pomemstream &&src) = delete;
|
||||
|
||||
~pomemstream() override;
|
||||
|
||||
@ -198,6 +216,9 @@ public:
|
||||
, m_buf(std::move(src.m_buf))
|
||||
{ src.m_buf = ""; }
|
||||
|
||||
COPYASSIGN(postringstream, delete)
|
||||
postringstream &operator=(postringstream &&src) = delete;
|
||||
|
||||
~postringstream() override = default;
|
||||
|
||||
const pstring &str() { return m_buf; }
|
||||
@ -234,6 +255,8 @@ public:
|
||||
src.m_file = nullptr;
|
||||
src.m_actually_close = false;
|
||||
}
|
||||
COPYASSIGN(pofilestream, delete)
|
||||
pofilestream &operator=(pofilestream &&src) = delete;
|
||||
|
||||
~pofilestream() override;
|
||||
|
||||
@ -262,6 +285,11 @@ class pstderr : public pofilestream
|
||||
{
|
||||
public:
|
||||
pstderr();
|
||||
pstderr(pstderr &&src) noexcept = default;
|
||||
pstderr &operator=(pstderr &&src) = delete;
|
||||
COPYASSIGN(pstderr, delete)
|
||||
|
||||
~pstderr() noexcept override= default;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -272,6 +300,11 @@ class pstdout : public pofilestream
|
||||
{
|
||||
public:
|
||||
pstdout();
|
||||
pstdout(pstdout &&src) noexcept = default;
|
||||
pstdout &operator=(pstdout &&src) = delete;
|
||||
COPYASSIGN(pstdout, delete)
|
||||
|
||||
~pstdout() noexcept override = default;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -295,6 +328,8 @@ public:
|
||||
src.m_actually_close = false;
|
||||
src.m_file = nullptr;
|
||||
}
|
||||
COPYASSIGN(pifilestream, delete)
|
||||
pifilestream &operator=(pifilestream &&src) = delete;
|
||||
|
||||
protected:
|
||||
pifilestream(void *file, const pstring &name, const bool do_close);
|
||||
@ -322,6 +357,9 @@ class pstdin : public pifilestream
|
||||
public:
|
||||
|
||||
pstdin();
|
||||
pstdin(pstdin &&src) noexcept = default;
|
||||
pstdin &operator=(pstdin &&src) = delete;
|
||||
COPYASSIGN(pstdin, delete)
|
||||
~pstdin() override = default;
|
||||
};
|
||||
|
||||
@ -344,6 +382,8 @@ public:
|
||||
{
|
||||
src.m_mem = nullptr;
|
||||
}
|
||||
COPYASSIGN(pimemstream, delete)
|
||||
pimemstream &operator=(pimemstream &&src) = delete;
|
||||
|
||||
explicit pimemstream(const pomemstream &ostrm);
|
||||
|
||||
@ -387,6 +427,9 @@ public:
|
||||
{
|
||||
set_mem(m_str.c_str(), std::strlen(m_str.c_str()));
|
||||
}
|
||||
COPYASSIGN(pistringstream, delete)
|
||||
pistringstream &operator=(pistringstream &&src) = delete;
|
||||
|
||||
~pistringstream() override = default;
|
||||
|
||||
private:
|
||||
@ -407,17 +450,20 @@ struct constructor_helper
|
||||
std::unique_ptr<pistream> operator()(T &&s) { return std::move(plib::make_unique<T>(std::move(s))); }
|
||||
};
|
||||
|
||||
class putf8_reader : plib::nocopyassign
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions)
|
||||
class putf8_reader
|
||||
{
|
||||
public:
|
||||
|
||||
COPYASSIGN(putf8_reader, delete)
|
||||
putf8_reader &operator=(putf8_reader &&src) = delete;
|
||||
virtual ~putf8_reader() = default;
|
||||
|
||||
template <typename T>
|
||||
friend struct constructor_helper;
|
||||
|
||||
template <typename T>
|
||||
putf8_reader(T &&strm) // NOLINT(misc-forwarding-reference-overload, bugprone-forwarding-reference-overload)
|
||||
putf8_reader(T &&strm) // NOLINT(cppcoreguidelines-special-member-functions, misc-forwarding-reference-overload, bugprone-forwarding-reference-overload)
|
||||
: m_strm(std::move(constructor_helper<T>()(std::move(strm)))) // NOLINT(bugprone-move-forwarding-reference)
|
||||
{}
|
||||
|
||||
@ -464,12 +510,16 @@ struct constructor_helper<std::unique_ptr<pistream>>
|
||||
// putf8writer_t: writer on top of ostream
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
class putf8_writer : plib::nocopyassign
|
||||
class putf8_writer
|
||||
{
|
||||
public:
|
||||
explicit putf8_writer(postream *strm) : m_strm(strm) {}
|
||||
|
||||
putf8_writer(putf8_writer &&src) noexcept : m_strm(src.m_strm) {}
|
||||
|
||||
COPYASSIGN(putf8_writer, delete)
|
||||
putf8_writer &operator=(putf8_writer &&src) = delete;
|
||||
|
||||
virtual ~putf8_writer() = default;
|
||||
|
||||
void writeline(const pstring &line) const
|
||||
@ -504,6 +554,8 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
COPYASSIGNMOVE(putf8_fmt_writer, delete)
|
||||
|
||||
~putf8_fmt_writer() override = default;
|
||||
|
||||
//protected:
|
||||
@ -516,11 +568,15 @@ private:
|
||||
// pbinary_writer_t: writer on top of ostream
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
class pbinary_writer : public plib::nocopyassign
|
||||
class pbinary_writer
|
||||
{
|
||||
public:
|
||||
explicit pbinary_writer(postream &strm) : m_strm(strm) {}
|
||||
pbinary_writer(pbinary_writer &&src) noexcept : m_strm(src.m_strm) {}
|
||||
|
||||
COPYASSIGN(pbinary_writer, delete)
|
||||
postringstream &operator=(pbinary_writer &&src) = delete;
|
||||
|
||||
virtual ~pbinary_writer() = default;
|
||||
|
||||
template <typename T>
|
||||
@ -549,11 +605,15 @@ private:
|
||||
postream &m_strm;
|
||||
};
|
||||
|
||||
class pbinary_reader : public plib::nocopyassign
|
||||
class pbinary_reader
|
||||
{
|
||||
public:
|
||||
explicit pbinary_reader(pistream &strm) : m_strm(strm) {}
|
||||
pbinary_reader(pbinary_reader &&src) noexcept : m_strm(src.m_strm) { }
|
||||
|
||||
COPYASSIGN(pbinary_reader, delete)
|
||||
pbinary_reader &operator=(pbinary_reader &&src) = delete;
|
||||
|
||||
virtual ~pbinary_reader() = default;
|
||||
|
||||
template <typename T>
|
||||
@ -594,6 +654,22 @@ inline void copystream(postream &dest, pistream &src)
|
||||
dest.write(buf.data(), r);
|
||||
}
|
||||
|
||||
struct perrlogger
|
||||
{
|
||||
template <typename ... Args>
|
||||
perrlogger(Args&& ... args)
|
||||
{
|
||||
h()(std::forward<Args>(args)...);
|
||||
}
|
||||
private:
|
||||
static putf8_fmt_writer &h()
|
||||
{
|
||||
static plib::pstderr perr_strm;
|
||||
static plib::putf8_fmt_writer perr(&perr_strm);
|
||||
return perr;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace plib
|
||||
|
||||
|
@ -92,7 +92,7 @@ public:
|
||||
|
||||
// simple construction/destruction
|
||||
pstring_t() = default;
|
||||
~pstring_t() = default;
|
||||
~pstring_t() noexcept = default;
|
||||
|
||||
// FIXME: Do something with encoding
|
||||
pstring_t(const mem_t *string)
|
||||
@ -115,13 +115,15 @@ public:
|
||||
m_str.assign(string, N - 1);
|
||||
}
|
||||
|
||||
pstring_t(const pstring_t &string) = default;
|
||||
|
||||
explicit pstring_t(const string_type &string)
|
||||
: m_str(string)
|
||||
{ }
|
||||
|
||||
pstring_t(const pstring_t &string) = default;
|
||||
pstring_t(pstring_t &&string) noexcept = default;
|
||||
pstring_t &operator=(const pstring_t &string) = default;
|
||||
pstring_t &operator=(pstring_t &&string) noexcept = default;
|
||||
|
||||
explicit pstring_t(code_t code)
|
||||
{
|
||||
@ -139,8 +141,6 @@ public:
|
||||
|
||||
operator string_type () const { return m_str; }
|
||||
|
||||
pstring_t &operator=(const pstring_t &string) = default;
|
||||
pstring_t &operator=(pstring_t &&string) noexcept = default;
|
||||
|
||||
template <typename T,
|
||||
class = typename std::enable_if<!std::is_same<T, pstring_t::traits_type>::value>::type>
|
||||
|
@ -14,6 +14,16 @@
|
||||
|
||||
#include "pconfig.h"
|
||||
|
||||
#define COPYASSIGNMOVE(name, def) \
|
||||
name(const name &) = def; \
|
||||
name(name &&) noexcept = def; \
|
||||
name &operator=(const name &) = def; \
|
||||
name &operator=(name &&) noexcept = def;
|
||||
|
||||
#define COPYASSIGN(name, def) \
|
||||
name(const name &) = def; \
|
||||
name &operator=(const name &) = def; \
|
||||
|
||||
namespace plib
|
||||
{
|
||||
template<typename T> struct is_integral : public std::is_integral<T> { };
|
||||
|
@ -172,8 +172,6 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
~netlist_tool_t() = default;
|
||||
|
||||
void init()
|
||||
{
|
||||
}
|
||||
|
@ -34,6 +34,9 @@ public:
|
||||
write(m_fmt);
|
||||
write(m_data);
|
||||
}
|
||||
|
||||
COPYASSIGNMOVE(wav_t, delete)
|
||||
|
||||
~wav_t()
|
||||
{
|
||||
if (m_f.seekable())
|
||||
|
@ -114,7 +114,6 @@ public:
|
||||
: analog_output_t(dev, aname)
|
||||
, m_proxied_net(pnet)
|
||||
{ }
|
||||
~proxied_analog_output_t() override = default;
|
||||
|
||||
analog_net_t *proxied_net() const { return m_proxied_net;}
|
||||
private:
|
||||
@ -136,8 +135,6 @@ public:
|
||||
PREFER_BAND_MATRIX
|
||||
};
|
||||
|
||||
~matrix_solver_t() override = default;
|
||||
|
||||
void setup(analog_net_t::list_t &nets)
|
||||
{
|
||||
vsetup(nets);
|
||||
|
@ -32,8 +32,6 @@ public:
|
||||
matrix_solver_direct_t(netlist_state_t &anetlist, const pstring &name, const solver_parameters_t *params, const std::size_t size);
|
||||
matrix_solver_direct_t(netlist_state_t &anetlist, const pstring &name, const eSortType sort, const solver_parameters_t *params, const std::size_t size);
|
||||
|
||||
~matrix_solver_direct_t() override = default;
|
||||
|
||||
void vsetup(analog_net_t::list_t &nets) override;
|
||||
void reset() override { matrix_solver_t::reset(); }
|
||||
|
||||
|
@ -44,8 +44,6 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
~matrix_solver_GCR_t() override = default;
|
||||
|
||||
constexpr std::size_t N() const { return m_dim; }
|
||||
|
||||
void vsetup(analog_net_t::list_t &nets) override;
|
||||
@ -55,8 +53,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
//typedef typename mat_cr_t<storage_N>::type mattype;
|
||||
typedef typename plib::matrix_compressed_rows_t<FT, SIZE>::index_type mat_index_type;
|
||||
using mat_index_type = typename plib::matrix_compressed_rows_t<FT, SIZE>::index_type;
|
||||
|
||||
void csc_private(plib::putf8_fmt_writer &strm);
|
||||
|
||||
|
@ -44,8 +44,6 @@ namespace devices
|
||||
{
|
||||
}
|
||||
|
||||
~matrix_solver_GMRES_t() override = default;
|
||||
|
||||
void vsetup(analog_net_t::list_t &nets) override;
|
||||
unsigned vsolve_non_dynamic(const bool newton_raphson) override;
|
||||
|
||||
|
@ -59,8 +59,6 @@ public:
|
||||
matrix_solver_sm_t(netlist_state_t &anetlist, const pstring &name,
|
||||
const solver_parameters_t *params, const std::size_t size);
|
||||
|
||||
~matrix_solver_sm_t() override = default;
|
||||
|
||||
void vsetup(analog_net_t::list_t &nets) override;
|
||||
void reset() override { matrix_solver_t::reset(); }
|
||||
|
||||
|
@ -39,8 +39,6 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
~matrix_solver_SOR_t() override = default;
|
||||
|
||||
void vsetup(analog_net_t::list_t &nets) override;
|
||||
unsigned vsolve_non_dynamic(const bool newton_raphson) override;
|
||||
|
||||
|
@ -40,8 +40,6 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
~matrix_solver_SOR_mat_t() override = default;
|
||||
|
||||
void vsetup(analog_net_t::list_t &nets) override;
|
||||
|
||||
unsigned vsolve_non_dynamic(const bool newton_raphson) override;
|
||||
|
@ -65,8 +65,6 @@ public:
|
||||
|
||||
matrix_solver_w_t(netlist_state_t &anetlist, const pstring &name, const solver_parameters_t *params, const std::size_t size);
|
||||
|
||||
~matrix_solver_w_t() override = default;
|
||||
|
||||
void vsetup(analog_net_t::list_t &nets) override;
|
||||
void reset() override { matrix_solver_t::reset(); }
|
||||
|
||||
@ -293,7 +291,7 @@ unsigned matrix_solver_w_t<FT, SIZE>::solve_non_dynamic(const bool newton_raphso
|
||||
for (unsigned i = 0; i < rowcount; i++)
|
||||
{
|
||||
if (H[i][i] == 0.0)
|
||||
printf("%s H singular\n", this->name().c_str());
|
||||
plib::perrlogger("{} H singular\n", this->name());
|
||||
const float_type f = 1.0 / H[i][i];
|
||||
for (unsigned j = i+1; j < rowcount; j++)
|
||||
{
|
||||
@ -348,7 +346,7 @@ unsigned matrix_solver_w_t<FT, SIZE>::solve_non_dynamic(const bool newton_raphso
|
||||
tmp += A(i,j) * new_V[j];
|
||||
}
|
||||
if (std::abs(tmp-RHS(i)) > 1e-6)
|
||||
printf("%s failed on row %d: %f RHS: %f\n", this->name().c_str(), i, std::abs(tmp-RHS(i)), RHS(i));
|
||||
plib::perrlogger("{} failed on row {}: {} RHS: {}\n", this->name(), i, std::abs(tmp-RHS(i)), RHS(i));
|
||||
}
|
||||
|
||||
const float_type err = (newton_raphson ? delta(new_V) : 0.0);
|
||||
|
@ -33,6 +33,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath> // <<= needed by windows build
|
||||
#include <memory>
|
||||
|
||||
#include "../nl_lists.h"
|
||||
|
||||
@ -80,14 +81,6 @@ void NETLIB_NAME(solver)::stop()
|
||||
s->log_stats();
|
||||
}
|
||||
|
||||
NETLIB_NAME(solver)::~NETLIB_NAME(solver)()
|
||||
{
|
||||
for (auto &s : m_mat_solvers)
|
||||
{
|
||||
plib::pfree(s);
|
||||
}
|
||||
}
|
||||
|
||||
NETLIB_UPDATE(solver)
|
||||
{
|
||||
if (m_params.m_dynamic_ts)
|
||||
@ -100,7 +93,7 @@ NETLIB_UPDATE(solver)
|
||||
|
||||
std::size_t nthreads = std::min(static_cast<std::size_t>(m_parallel()), plib::omp::get_max_threads());
|
||||
|
||||
std::vector<matrix_solver_t *> &solvers = (force_solve ? m_mat_solvers : m_mat_solvers_timestepping);
|
||||
std::vector<matrix_solver_t *> &solvers = (force_solve ? m_mat_solvers_all : m_mat_solvers_timestepping);
|
||||
|
||||
if (nthreads > 1 && solvers.size() > 1)
|
||||
{
|
||||
@ -129,13 +122,13 @@ NETLIB_UPDATE(solver)
|
||||
}
|
||||
|
||||
template <class C>
|
||||
matrix_solver_t * create_it(netlist_state_t &nl, pstring name, solver_parameters_t ¶ms, std::size_t size)
|
||||
std::unique_ptr<matrix_solver_t> create_it(netlist_state_t &nl, pstring name, solver_parameters_t ¶ms, std::size_t size)
|
||||
{
|
||||
return plib::palloc<C>(nl, name, ¶ms, size);
|
||||
return plib::make_unique<C>(nl, name, ¶ms, size);
|
||||
}
|
||||
|
||||
template <typename FT, int SIZE>
|
||||
matrix_solver_t * NETLIB_NAME(solver)::create_solver(std::size_t size, const pstring &solvername)
|
||||
std::unique_ptr<matrix_solver_t> NETLIB_NAME(solver)::create_solver(std::size_t size, const pstring &solvername)
|
||||
{
|
||||
if (m_method() == "SOR_MAT")
|
||||
{
|
||||
@ -283,7 +276,7 @@ void NETLIB_NAME(solver)::post_start()
|
||||
log().verbose("Found {1} net groups in {2} nets\n", splitter.groups.size(), state().nets().size());
|
||||
for (auto & grp : splitter.groups)
|
||||
{
|
||||
matrix_solver_t *ms;
|
||||
std::unique_ptr<matrix_solver_t> ms;
|
||||
std::size_t net_count = grp.size();
|
||||
pstring sname = plib::pfmt("Solver_{1}")(m_mat_solvers.size());
|
||||
|
||||
@ -292,13 +285,13 @@ void NETLIB_NAME(solver)::post_start()
|
||||
#if 1
|
||||
case 1:
|
||||
if (use_specific)
|
||||
ms = plib::palloc<matrix_solver_direct1_t<double>>(state(), sname, &m_params);
|
||||
ms = plib::make_unique<matrix_solver_direct1_t<double>>(state(), sname, &m_params);
|
||||
else
|
||||
ms = create_solver<double, 1>(1, sname);
|
||||
break;
|
||||
case 2:
|
||||
if (use_specific)
|
||||
ms = plib::palloc<matrix_solver_direct2_t<double>>(state(), sname, &m_params);
|
||||
ms = plib::make_unique<matrix_solver_direct2_t<double>>(state(), sname, &m_params);
|
||||
else
|
||||
ms = create_solver<double, 2>(2, sname);
|
||||
break;
|
||||
@ -403,9 +396,11 @@ void NETLIB_NAME(solver)::post_start()
|
||||
}
|
||||
}
|
||||
|
||||
m_mat_solvers.push_back(ms);
|
||||
m_mat_solvers_all.push_back(ms.get());
|
||||
if (ms->has_timestep_devices())
|
||||
m_mat_solvers_timestepping.push_back(ms);
|
||||
m_mat_solvers_timestepping.push_back(ms.get());
|
||||
|
||||
m_mat_solvers.emplace_back(std::move(ms));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,8 @@
|
||||
#define NLD_SOLVER_H_
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "../nl_base.h"
|
||||
#include "../plib/pstream.h"
|
||||
@ -63,8 +65,6 @@ NETLIB_OBJECT(solver)
|
||||
connect(m_fb_step, m_Q_step);
|
||||
}
|
||||
|
||||
~NETLIB_NAME(solver)() override;
|
||||
|
||||
void post_start();
|
||||
void stop();
|
||||
|
||||
@ -97,13 +97,14 @@ protected:
|
||||
param_logic_t m_log_stats;
|
||||
|
||||
private:
|
||||
std::vector<matrix_solver_t *> m_mat_solvers;
|
||||
std::vector<std::unique_ptr<matrix_solver_t>> m_mat_solvers;
|
||||
std::vector<matrix_solver_t *> m_mat_solvers_all;
|
||||
std::vector<matrix_solver_t *> m_mat_solvers_timestepping;
|
||||
|
||||
solver_parameters_t m_params;
|
||||
|
||||
template <typename FT, int SIZE>
|
||||
matrix_solver_t * create_solver(std::size_t size, const pstring &solvername);
|
||||
std::unique_ptr<matrix_solver_t> create_solver(std::size_t size, const pstring &solvername);
|
||||
};
|
||||
|
||||
} //namespace devices
|
||||
|
@ -201,7 +201,7 @@ double nl_convert_base_t::get_sp_unit(const pstring &unit)
|
||||
return m_units[i].m_mult;
|
||||
i++;
|
||||
}
|
||||
fprintf(stderr, "Unit %s unknown\n", unit.c_str());
|
||||
plib::perrlogger("Unit {} unknown\n", unit);
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@ -250,10 +250,10 @@ void nl_convert_spice_t::convert(const pstring &contents)
|
||||
|
||||
pstring line = "";
|
||||
|
||||
for (std::size_t i=0; i < spnl.size(); i++)
|
||||
for (const auto &i : spnl)
|
||||
{
|
||||
// Basic preprocessing
|
||||
pstring inl = plib::ucase(plib::trim(spnl[i]));
|
||||
pstring inl = plib::ucase(plib::trim(i));
|
||||
if (plib::startsWith(inl, "+"))
|
||||
line = line + inl.substr(1);
|
||||
else
|
||||
@ -316,7 +316,7 @@ void nl_convert_spice_t::process_line(const pstring &line)
|
||||
if (m.size() == 2)
|
||||
{
|
||||
if (m[1].length() != 4)
|
||||
fprintf(stderr, "error with model desc %s\n", model.c_str());
|
||||
plib::perrlogger("error with model desc {}\n", model);
|
||||
pins = plib::left(m[1], 3);
|
||||
}
|
||||
add_device("QBJT_EB", tt[0], m[0]);
|
||||
@ -358,7 +358,7 @@ void nl_convert_spice_t::process_line(const pstring &line)
|
||||
//add_term(tt[2], tt[0] + ".2");
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "Voltage Source %s not connected to GND\n", tt[0].c_str());
|
||||
plib::perrlogger("Voltage Source {} not connected to GND\n", tt[0]);
|
||||
break;
|
||||
case 'I': // Input pin special notation
|
||||
{
|
||||
|
@ -10,6 +10,7 @@
|
||||
#ifndef NL_CONVERT_H_
|
||||
#define NL_CONVERT_H_
|
||||
|
||||
#include "../plib/ptypes.h"
|
||||
#include "../plib/plists.h"
|
||||
#include "../plib/pparser.h"
|
||||
#include "../plib/pstring.h"
|
||||
@ -23,6 +24,8 @@ class nl_convert_base_t
|
||||
{
|
||||
public:
|
||||
|
||||
COPYASSIGNMOVE(nl_convert_base_t, delete)
|
||||
|
||||
virtual ~nl_convert_base_t();
|
||||
|
||||
const pstring &result() { return m_buf.str(); }
|
||||
@ -140,7 +143,6 @@ class nl_convert_spice_t : public nl_convert_base_t
|
||||
public:
|
||||
|
||||
nl_convert_spice_t() : nl_convert_base_t() {}
|
||||
~nl_convert_spice_t() override = default;
|
||||
|
||||
void convert(const pstring &contents) override;
|
||||
|
||||
@ -157,7 +159,6 @@ class nl_convert_eagle_t : public nl_convert_base_t
|
||||
public:
|
||||
|
||||
nl_convert_eagle_t() : nl_convert_base_t() {}
|
||||
~nl_convert_eagle_t() override = default;
|
||||
|
||||
class tokenizer : public plib::ptokenizer
|
||||
{
|
||||
@ -191,7 +192,6 @@ class nl_convert_rinf_t : public nl_convert_base_t
|
||||
public:
|
||||
|
||||
nl_convert_rinf_t() : nl_convert_base_t() {}
|
||||
~nl_convert_rinf_t() override = default;
|
||||
|
||||
class tokenizer : public plib::ptokenizer
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user