Miscellaneous cleanups:

* Limit HashPrefix construction and disallow assignment

* Give KnownFormats deleted copy members so that derived
  classes will give the right answers if queried with the
  std::is_copy_constructible/assignable traits.

* Replace SharedSingleton with a local static in
  LedgerFormats::getInstance() to be consistent with
  similar code in other places.  This also allows the
  LedgerFormats default constructor to be marked private
  so that the compiler enforces the design that
  LedgerFormats is a singleton type.

* Change return types of LedgerFormats::getInstance() and
  TxFormats::getInstance() from pointer to non-const to
  reference to const so as follow more established design
  guidelines for singletons.  This prevents pointers being
  mistaken for heap-allocated objects, and the const
  ensures the singleton isn't mutable.

* Change RippleAddress to inherit privately from
  CBase58Data instead of publicly.  This lets the compiler
  enforce that there are no unintended conversions from
  RippleAddress to CBase58Data.  This change allows us
  to remove a comment warning about unwanted conversions.
This commit is contained in:
Howard Hinnant
2014-09-29 12:48:37 -04:00
committed by Vinnie Falco
parent 8e91ce67c5
commit 616be1d76c
11 changed files with 86 additions and 22 deletions

View File

@@ -46,7 +46,7 @@ SerializedLedgerEntry::SerializedLedgerEntry (
void SerializedLedgerEntry::setSLEType ()
{
mFormat = LedgerFormats::getInstance()->findByType (
mFormat = LedgerFormats::getInstance().findByType (
static_cast <LedgerEntryType> (getFieldU16 (sfLedgerEntryType)));
if (mFormat == nullptr)
@@ -65,7 +65,7 @@ void SerializedLedgerEntry::setSLEType ()
SerializedLedgerEntry::SerializedLedgerEntry (LedgerEntryType type, uint256 const& index) :
STObject (sfLedgerEntry), mIndex (index), mType (type), mMutable (true)
{
mFormat = LedgerFormats::getInstance()->findByType (type);
mFormat = LedgerFormats::getInstance().findByType (type);
if (mFormat == nullptr)
throw std::runtime_error ("invalid ledger entry type");