From 805033d99b0c9542b93a8923ad28b06e8dbeb8ff Mon Sep 17 00:00:00 2001 From: Johannes Feldmann Date: Wed, 30 May 2018 11:02:36 +0200 Subject: [PATCH 1/2] Make static methods for instance handling private in derived classes. --- DRAMSys/library/src/common/jsonAddressDecoder.h | 3 +++ DRAMSys/library/src/common/xmlAddressdecoder.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/DRAMSys/library/src/common/jsonAddressDecoder.h b/DRAMSys/library/src/common/jsonAddressDecoder.h index 10180f21..e6838da2 100644 --- a/DRAMSys/library/src/common/jsonAddressDecoder.h +++ b/DRAMSys/library/src/common/jsonAddressDecoder.h @@ -65,6 +65,9 @@ private: vector> m_vColumnBits; // This container stores for each column bit a pair which consists of "First/Number of the column bit" and "Second/Number of the address bit" + static AddressDecoder &getInstance(); + static void createInstance(Type t); + public: virtual void setConfiguration(std::string url); diff --git a/DRAMSys/library/src/common/xmlAddressdecoder.h b/DRAMSys/library/src/common/xmlAddressdecoder.h index 4178ca98..97cbd9eb 100644 --- a/DRAMSys/library/src/common/xmlAddressdecoder.h +++ b/DRAMSys/library/src/common/xmlAddressdecoder.h @@ -59,6 +59,9 @@ private: tinyxml2::XMLElement *addressmapping; + static AddressDecoder &getInstance(); + static void createInstance(Type t); + public: virtual DecodedAddress decodeAddress(sc_dt::uint64 addr); virtual sc_dt::uint64 encodeAddress(DecodedAddress n); From 534f75377076cbecb85db36a0240c41758d11f57 Mon Sep 17 00:00:00 2001 From: Johannes Feldmann Date: Mon, 4 Jun 2018 15:06:12 +0200 Subject: [PATCH 2/2] Better way to make the static functions not accessible with the derived classes --- DRAMSys/library/src/common/jsonAddressDecoder.h | 9 +++------ DRAMSys/library/src/common/xmlAddressdecoder.h | 9 +++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/DRAMSys/library/src/common/jsonAddressDecoder.h b/DRAMSys/library/src/common/jsonAddressDecoder.h index e6838da2..3ab157e1 100644 --- a/DRAMSys/library/src/common/jsonAddressDecoder.h +++ b/DRAMSys/library/src/common/jsonAddressDecoder.h @@ -46,15 +46,13 @@ using std::pair; using std::map; class JSONAddressDecoder - : public AddressDecoder + : private AddressDecoder { // Friendship needed so that the AddressDecoder can access the // constructor of this class to create the object in CreateInstance. friend class AddressDecoder; private: - JSONAddressDecoder(); - vector> m_vXor; // This container stores for each used xor gate a pair which consists of "First/Number of an address bit which corresponds to a bank" // and "Second/Number of an address bit which corresponds to a row" @@ -65,10 +63,9 @@ private: vector> m_vColumnBits; // This container stores for each column bit a pair which consists of "First/Number of the column bit" and "Second/Number of the address bit" - static AddressDecoder &getInstance(); - static void createInstance(Type t); - public: + JSONAddressDecoder(); + virtual void setConfiguration(std::string url); virtual DecodedAddress decodeAddress(sc_dt::uint64 addr); diff --git a/DRAMSys/library/src/common/xmlAddressdecoder.h b/DRAMSys/library/src/common/xmlAddressdecoder.h index 97cbd9eb..063bc25e 100644 --- a/DRAMSys/library/src/common/xmlAddressdecoder.h +++ b/DRAMSys/library/src/common/xmlAddressdecoder.h @@ -45,24 +45,21 @@ #include "AddressDecoder.h" class xmlAddressDecoder - : public AddressDecoder + : private AddressDecoder { // Friendship needed so that the AddressDecoder can access the // constructor of this class to create the object in CreateInstance. friend class AddressDecoder; private: - xmlAddressDecoder(); - std::map masks; std::map shifts; tinyxml2::XMLElement *addressmapping; - static AddressDecoder &getInstance(); - static void createInstance(Type t); - public: + xmlAddressDecoder(); + virtual DecodedAddress decodeAddress(sc_dt::uint64 addr); virtual sc_dt::uint64 encodeAddress(DecodedAddress n);