General refactoring, using C++11

* Remove broken RecycledObjectPool

* Fix beast::ServiceQueue using List instead of LockFreeStack

* Add class semaphore, fixes broken Semaphore

* Move crytpo module files to new beast directory

* Use c++11 replacements for boost and beast types:
  - std::atomic instead of beast::Atomic
  - std::function instead of boost::function, beast::function
  - std::unique_ptr instead of beast::ScopedPointer
  - std::shared_ptr instead of boost::shared_ptr

* Remove modules:
  - beast_db
  - beast_crypto
  - beast_extras

* Remove unnecessary classes:
  - AbstractFifo
  - AddConst
  - AtomicCounter
  - AtomicFlag
  - AtomicPointer
  - AtomicState
  - CopyConst
  - Expression
  - ForwardList
  - IfCond
  - Interval
  - IntrusiveArray
  - KeyvaDB
  - PointerToOther
  - PointerTraits
  - RemoveConst
  - RemoveConstVolatile
  - RemoveReference
  - RemoveVolatile
  - SharedObjectArray
  - SingleThreadedSharedObject
  - SophiaDB factory
  - SortedSet
  - WeakReference
  - beast::unique_ptr
This commit is contained in:
Vinnie Falco
2013-12-31 08:28:12 -08:00
parent 52333b8bd4
commit 087301933a
164 changed files with 827 additions and 8812 deletions

View File

@@ -1214,7 +1214,7 @@ STAmount STAmount::getPay (const STAmount& offerOut, const STAmount& offerIn, co
STAmount STAmount::deserialize (SerializerIterator& it)
{
UPTR_T<STAmount> s (dynamic_cast<STAmount*> (construct (it, sfGeneric)));
std::unique_ptr<STAmount> s (dynamic_cast<STAmount*> (construct (it, sfGeneric)));
STAmount ret (*s);
return ret;
}

View File

@@ -19,56 +19,56 @@
SETUP_LOG (STObject)
UPTR_T<SerializedType> STObject::makeDefaultObject (SerializedTypeID id, SField::ref name)
std::unique_ptr<SerializedType> STObject::makeDefaultObject (SerializedTypeID id, SField::ref name)
{
assert ((id == STI_NOTPRESENT) || (id == name.fieldType));
switch (id)
{
case STI_NOTPRESENT:
return UPTR_T<SerializedType> (new SerializedType (name));
return std::unique_ptr<SerializedType> (new SerializedType (name));
case STI_UINT8:
return UPTR_T<SerializedType> (new STUInt8 (name));
return std::unique_ptr<SerializedType> (new STUInt8 (name));
case STI_UINT16:
return UPTR_T<SerializedType> (new STUInt16 (name));
return std::unique_ptr<SerializedType> (new STUInt16 (name));
case STI_UINT32:
return UPTR_T<SerializedType> (new STUInt32 (name));
return std::unique_ptr<SerializedType> (new STUInt32 (name));
case STI_UINT64:
return UPTR_T<SerializedType> (new STUInt64 (name));
return std::unique_ptr<SerializedType> (new STUInt64 (name));
case STI_AMOUNT:
return UPTR_T<SerializedType> (new STAmount (name));
return std::unique_ptr<SerializedType> (new STAmount (name));
case STI_HASH128:
return UPTR_T<SerializedType> (new STHash128 (name));
return std::unique_ptr<SerializedType> (new STHash128 (name));
case STI_HASH160:
return UPTR_T<SerializedType> (new STHash160 (name));
return std::unique_ptr<SerializedType> (new STHash160 (name));
case STI_HASH256:
return UPTR_T<SerializedType> (new STHash256 (name));
return std::unique_ptr<SerializedType> (new STHash256 (name));
case STI_VECTOR256:
return UPTR_T<SerializedType> (new STVector256 (name));
return std::unique_ptr<SerializedType> (new STVector256 (name));
case STI_VL:
return UPTR_T<SerializedType> (new STVariableLength (name));
return std::unique_ptr<SerializedType> (new STVariableLength (name));
case STI_ACCOUNT:
return UPTR_T<SerializedType> (new STAccount (name));
return std::unique_ptr<SerializedType> (new STAccount (name));
case STI_PATHSET:
return UPTR_T<SerializedType> (new STPathSet (name));
return std::unique_ptr<SerializedType> (new STPathSet (name));
case STI_OBJECT:
return UPTR_T<SerializedType> (new STObject (name));
return std::unique_ptr<SerializedType> (new STObject (name));
case STI_ARRAY:
return UPTR_T<SerializedType> (new STArray (name));
return std::unique_ptr<SerializedType> (new STArray (name));
default:
WriteLog (lsFATAL, STObject) << "Object type: " << lexicalCast <std::string> (id);
@@ -78,7 +78,7 @@ UPTR_T<SerializedType> STObject::makeDefaultObject (SerializedTypeID id, SField:
}
// VFALCO TODO Remove the 'depth' parameter
UPTR_T<SerializedType> STObject::makeDeserializedObject (SerializedTypeID id, SField::ref name,
std::unique_ptr<SerializedType> STObject::makeDeserializedObject (SerializedTypeID id, SField::ref name,
SerializerIterator& sit, int depth)
{
switch (id)
@@ -297,10 +297,10 @@ bool STObject::set (SerializerIterator& sit, int depth)
}
UPTR_T<SerializedType> STObject::deserialize (SerializerIterator& sit, SField::ref name)
std::unique_ptr<SerializedType> STObject::deserialize (SerializerIterator& sit, SField::ref name)
{
STObject* o;
UPTR_T<SerializedType> object (o = new STObject (name));
std::unique_ptr<SerializedType> object (o = new STObject (name));
o->set (sit, 1);
return object;
}
@@ -1232,7 +1232,7 @@ void STArray::sort (bool (*compare) (const STObject&, const STObject&))
value.sort (compare);
}
UPTR_T<STObject> STObject::parseJson (const Json::Value& object, SField::ref inName, int depth)
std::unique_ptr<STObject> STObject::parseJson (const Json::Value& object, SField::ref inName, int depth)
{
if (!object.isObject ())
throw std::runtime_error ("Value is not an object");
@@ -1604,7 +1604,7 @@ UPTR_T<STObject> STObject::parseJson (const Json::Value& object, SField::ref inN
}
}
return UPTR_T<STObject> (new STObject (*name, data));
return std::unique_ptr<STObject> (new STObject (*name, data));
}
//------------------------------------------------------------------------------
@@ -1652,7 +1652,7 @@ public:
"\"DeletedNode\":{\"Sequence\":1}"
"}]}");
UPTR_T<STObject> so;
std::unique_ptr<STObject> so;
Json::Value faultyJson;
bool parsedOK (parseJSONString(faulty, faultyJson));
unexpected(!parsedOK, "failed to parse");
@@ -1677,7 +1677,7 @@ public:
bool parsedOK (parseJSONString(json, jsonObject));
if (parsedOK)
{
UPTR_T<STObject> so;
std::unique_ptr<STObject> so;
so = STObject::parseJson (jsonObject);
Json::FastWriter writer;
std::string const& serialized (writer.write(so->getJson(0)));

View File

@@ -48,19 +48,19 @@ public:
setType (type);
}
UPTR_T<STObject> oClone () const
std::unique_ptr<STObject> oClone () const
{
return UPTR_T<STObject> (new STObject (*this));
return std::unique_ptr<STObject> (new STObject (*this));
}
static UPTR_T<STObject> parseJson (const Json::Value & value, SField::ref name = sfGeneric, int depth = 0);
static std::unique_ptr<STObject> parseJson (const Json::Value & value, SField::ref name = sfGeneric, int depth = 0);
virtual ~STObject ()
{
;
}
static UPTR_T<SerializedType> deserialize (SerializerIterator & sit, SField::ref name);
static std::unique_ptr<SerializedType> deserialize (SerializerIterator & sit, SField::ref name);
bool setType (const SOTemplate & type);
bool isValidForType ();
@@ -108,7 +108,7 @@ public:
mData.push_back (t.clone ().release ());
return mData.size () - 1;
}
int giveObject (UPTR_T<SerializedType> t)
int giveObject (std::unique_ptr<SerializedType> t)
{
mData.push_back (t.release ());
return mData.size () - 1;
@@ -223,21 +223,21 @@ public:
bool delField (SField::ref field);
void delField (int index);
static UPTR_T <SerializedType> makeDefaultObject (SerializedTypeID id, SField::ref name);
static std::unique_ptr <SerializedType> makeDefaultObject (SerializedTypeID id, SField::ref name);
// VFALCO TODO remove the 'depth' parameter
static UPTR_T<SerializedType> makeDeserializedObject (
static std::unique_ptr<SerializedType> makeDeserializedObject (
SerializedTypeID id,
SField::ref name,
SerializerIterator&,
int depth);
static UPTR_T<SerializedType> makeNonPresentObject (SField::ref name)
static std::unique_ptr<SerializedType> makeNonPresentObject (SField::ref name)
{
return makeDefaultObject (STI_NOTPRESENT, name);
}
static UPTR_T<SerializedType> makeDefaultObject (SField::ref name)
static std::unique_ptr<SerializedType> makeDefaultObject (SField::ref name)
{
return makeDefaultObject (name.fieldType, name);
}
@@ -373,9 +373,9 @@ public:
;
}
static UPTR_T<SerializedType> deserialize (SerializerIterator & sit, SField::ref name)
static std::unique_ptr<SerializedType> deserialize (SerializerIterator & sit, SField::ref name)
{
return UPTR_T<SerializedType> (construct (sit, name));
return std::unique_ptr<SerializedType> (construct (sit, name));
}
const vector& getValue () const

View File

@@ -330,7 +330,7 @@ STVector256* STVector256::construct (SerializerIterator& u, SField::ref name)
Blob data = u.getVL ();
Blob ::iterator begin = data.begin ();
UPTR_T<STVector256> vec (new STVector256 (name));
std::unique_ptr<STVector256> vec (new STVector256 (name));
int count = data.size () / (256 / 8);
vec->mValue.reserve (count);

View File

@@ -83,9 +83,9 @@ public:
virtual ~SerializedType () { }
static UPTR_T<SerializedType> deserialize (SField::ref name)
static std::unique_ptr<SerializedType> deserialize (SField::ref name)
{
return UPTR_T<SerializedType> (new SerializedType (name));
return std::unique_ptr<SerializedType> (new SerializedType (name));
}
void setFName (SField::ref n)
@@ -106,9 +106,9 @@ public:
{
return STI_NOTPRESENT;
}
UPTR_T<SerializedType> clone () const
std::unique_ptr<SerializedType> clone () const
{
return UPTR_T<SerializedType> (duplicate ());
return std::unique_ptr<SerializedType> (duplicate ());
}
virtual std::string getFullText () const;
@@ -185,9 +185,9 @@ public:
{
;
}
static UPTR_T<SerializedType> deserialize (SerializerIterator& sit, SField::ref name)
static std::unique_ptr<SerializedType> deserialize (SerializerIterator& sit, SField::ref name)
{
return UPTR_T<SerializedType> (construct (sit, name));
return std::unique_ptr<SerializedType> (construct (sit, name));
}
SerializedTypeID getSType () const
@@ -242,9 +242,9 @@ public:
{
;
}
static UPTR_T<SerializedType> deserialize (SerializerIterator& sit, SField::ref name)
static std::unique_ptr<SerializedType> deserialize (SerializerIterator& sit, SField::ref name)
{
return UPTR_T<SerializedType> (construct (sit, name));
return std::unique_ptr<SerializedType> (construct (sit, name));
}
SerializedTypeID getSType () const
@@ -299,9 +299,9 @@ public:
{
;
}
static UPTR_T<SerializedType> deserialize (SerializerIterator& sit, SField::ref name)
static std::unique_ptr<SerializedType> deserialize (SerializerIterator& sit, SField::ref name)
{
return UPTR_T<SerializedType> (construct (sit, name));
return std::unique_ptr<SerializedType> (construct (sit, name));
}
SerializedTypeID getSType () const
@@ -356,9 +356,9 @@ public:
{
;
}
static UPTR_T<SerializedType> deserialize (SerializerIterator& sit, SField::ref name)
static std::unique_ptr<SerializedType> deserialize (SerializerIterator& sit, SField::ref name)
{
return UPTR_T<SerializedType> (construct (sit, name));
return std::unique_ptr<SerializedType> (construct (sit, name));
}
SerializedTypeID getSType () const
@@ -492,9 +492,9 @@ public:
static STAmount createFromInt64 (SField::ref n, int64 v);
static UPTR_T<SerializedType> deserialize (SerializerIterator& sit, SField::ref name)
static std::unique_ptr<SerializedType> deserialize (SerializerIterator& sit, SField::ref name)
{
return UPTR_T<SerializedType> (construct (sit, name));
return std::unique_ptr<SerializedType> (construct (sit, name));
}
bool bSetJson (const Json::Value& jvSource);
@@ -832,9 +832,9 @@ public:
{
;
}
static UPTR_T<SerializedType> deserialize (SerializerIterator& sit, SField::ref name)
static std::unique_ptr<SerializedType> deserialize (SerializerIterator& sit, SField::ref name)
{
return UPTR_T<SerializedType> (construct (sit, name));
return std::unique_ptr<SerializedType> (construct (sit, name));
}
SerializedTypeID getSType () const
@@ -903,9 +903,9 @@ public:
{
;
}
static UPTR_T<SerializedType> deserialize (SerializerIterator& sit, SField::ref name)
static std::unique_ptr<SerializedType> deserialize (SerializerIterator& sit, SField::ref name)
{
return UPTR_T<SerializedType> (construct (sit, name));
return std::unique_ptr<SerializedType> (construct (sit, name));
}
SerializedTypeID getSType () const
@@ -974,9 +974,9 @@ public:
{
;
}
static UPTR_T<SerializedType> deserialize (SerializerIterator& sit, SField::ref name)
static std::unique_ptr<SerializedType> deserialize (SerializerIterator& sit, SField::ref name)
{
return UPTR_T<SerializedType> (construct (sit, name));
return std::unique_ptr<SerializedType> (construct (sit, name));
}
SerializedTypeID getSType () const
@@ -1039,9 +1039,9 @@ public:
{
;
}
static UPTR_T<SerializedType> deserialize (SerializerIterator& sit, SField::ref name)
static std::unique_ptr<SerializedType> deserialize (SerializerIterator& sit, SField::ref name)
{
return UPTR_T<SerializedType> (construct (sit, name));
return std::unique_ptr<SerializedType> (construct (sit, name));
}
virtual SerializedTypeID getSType () const
@@ -1111,9 +1111,9 @@ public:
{
;
}
static UPTR_T<SerializedType> deserialize (SerializerIterator& sit, SField::ref name)
static std::unique_ptr<SerializedType> deserialize (SerializerIterator& sit, SField::ref name)
{
return UPTR_T<SerializedType> (construct (sit, name));
return std::unique_ptr<SerializedType> (construct (sit, name));
}
SerializedTypeID getSType () const
@@ -1346,9 +1346,9 @@ public:
;
}
static UPTR_T<SerializedType> deserialize (SerializerIterator& sit, SField::ref name)
static std::unique_ptr<SerializedType> deserialize (SerializerIterator& sit, SField::ref name)
{
return UPTR_T<SerializedType> (construct (sit, name));
return std::unique_ptr<SerializedType> (construct (sit, name));
}
// std::string getText() const;
@@ -1508,9 +1508,9 @@ public:
}
void add (Serializer& s) const;
static UPTR_T<SerializedType> deserialize (SerializerIterator& sit, SField::ref name)
static std::unique_ptr<SerializedType> deserialize (SerializerIterator& sit, SField::ref name)
{
return UPTR_T<SerializedType> (construct (sit, name));
return std::unique_ptr<SerializedType> (construct (sit, name));
}
const std::vector<uint256>& peekValue () const