diff --git a/src/beast/Builds/VisualStudio2012/beast.vcxproj b/src/beast/Builds/VisualStudio2012/beast.vcxproj index 27e6fbd84..8914c8f9a 100644 --- a/src/beast/Builds/VisualStudio2012/beast.vcxproj +++ b/src/beast/Builds/VisualStudio2012/beast.vcxproj @@ -162,7 +162,6 @@ - diff --git a/src/beast/Builds/VisualStudio2012/beast.vcxproj.filters b/src/beast/Builds/VisualStudio2012/beast.vcxproj.filters index 9caf855ab..0f09ebf75 100644 --- a/src/beast/Builds/VisualStudio2012/beast.vcxproj.filters +++ b/src/beast/Builds/VisualStudio2012/beast.vcxproj.filters @@ -1158,9 +1158,6 @@ beast\smart_ptr - - beast - beast diff --git a/src/beast/beast/STL.h b/src/beast/beast/STL.h deleted file mode 100644 index 730eb22eb..000000000 --- a/src/beast/beast/STL.h +++ /dev/null @@ -1,25 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_STL_H_INCLUDED -#define BEAST_STL_H_INCLUDED - -#include "stl/shared_ptr.h" - -#endif diff --git a/src/beast/beast/insight/CounterImpl.h b/src/beast/beast/insight/CounterImpl.h index 963151490..f6c0b6e0d 100644 --- a/src/beast/beast/insight/CounterImpl.h +++ b/src/beast/beast/insight/CounterImpl.h @@ -20,7 +20,6 @@ #ifndef BEAST_INSIGHT_COUNTERIMPL_H_INCLUDED #define BEAST_INSIGHT_COUNTERIMPL_H_INCLUDED -#include #include namespace beast { diff --git a/src/beast/beast/insight/GaugeImpl.h b/src/beast/beast/insight/GaugeImpl.h index 50ff9b586..e816e6ce7 100644 --- a/src/beast/beast/insight/GaugeImpl.h +++ b/src/beast/beast/insight/GaugeImpl.h @@ -20,6 +20,9 @@ #ifndef BEAST_INSIGHT_GAUGEIMPL_H_INCLUDED #define BEAST_INSIGHT_GAUGEIMPL_H_INCLUDED +#include +#include + namespace beast { namespace insight { diff --git a/src/beast/beast/insight/Hook.h b/src/beast/beast/insight/Hook.h index 3b45992e3..a529c0e1b 100644 --- a/src/beast/beast/insight/Hook.h +++ b/src/beast/beast/insight/Hook.h @@ -22,7 +22,7 @@ #include "HookImpl.h" -#include "../stl/shared_ptr.h" +#include namespace beast { namespace insight { diff --git a/src/beast/beast/insight/Meter.h b/src/beast/beast/insight/Meter.h index bc7c72f9b..3471fb31f 100644 --- a/src/beast/beast/insight/Meter.h +++ b/src/beast/beast/insight/Meter.h @@ -22,7 +22,7 @@ #include "MeterImpl.h" -#include "../stl/shared_ptr.h" +#include namespace beast { namespace insight { diff --git a/src/beast/beast/make_unique.h b/src/beast/beast/make_unique.h index c48e7e0d3..e26402ae2 100644 --- a/src/beast/beast/make_unique.h +++ b/src/beast/beast/make_unique.h @@ -24,6 +24,12 @@ namespace std { +#ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES +# ifdef _MSC_VER +# define BOOST_NO_CXX11_VARIADIC_TEMPLATES +# endif +#endif + #ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES template diff --git a/src/beast/beast/stl/STL.cpp b/src/beast/beast/stl/STL.cpp deleted file mode 100644 index 24ed420bf..000000000 --- a/src/beast/beast/stl/STL.cpp +++ /dev/null @@ -1,22 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include "BeastConfig.h" - -#include "shared_ptr.h" diff --git a/src/beast/beast/stl/shared_ptr.h b/src/beast/beast/stl/shared_ptr.h deleted file mode 100644 index 3d2875b4d..000000000 --- a/src/beast/beast/stl/shared_ptr.h +++ /dev/null @@ -1,33 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_STL_SHARED_PTR_H_INCLUDED -#define BEAST_STL_SHARED_PTR_H_INCLUDED - -#include - -namespace beast { - -using boost::shared_ptr; -using boost::make_shared; -using boost::enable_shared_from_this; - -} - -#endif diff --git a/src/beast/modules/beast_core/beast_core.h b/src/beast/modules/beast_core/beast_core.h index c3526cf91..faec9deb1 100644 --- a/src/beast/modules/beast_core/beast_core.h +++ b/src/beast/modules/beast_core/beast_core.h @@ -61,7 +61,6 @@ #include "../../beast/Threads.h" #include "../../beast/Utility.h" #include "../../beast/Chrono.h" -#include "../../beast/STL.h" #include "system/StandardIncludes.h" diff --git a/src/beast/modules/beast_sqdb/source/session.cpp b/src/beast/modules/beast_sqdb/source/session.cpp index 6e18c66eb..ff8a71cc8 100644 --- a/src/beast/modules/beast_sqdb/source/session.cpp +++ b/src/beast/modules/beast_sqdb/source/session.cpp @@ -139,7 +139,8 @@ Error session::open(String fileName, std::string options) std::stringstream ssconn(options); - while (!err && !ssconn.eof() && ssconn.str().find('=') >= 0) + while (!err && !ssconn.eof() && + ssconn.str().find('=') != std::string::npos) { std::string key, val; std::getline(ssconn, key, '='); diff --git a/src/ripple_app/main/Application.cpp b/src/ripple_app/main/Application.cpp index 7dca258b6..ce85ba673 100644 --- a/src/ripple_app/main/Application.cpp +++ b/src/ripple_app/main/Application.cpp @@ -1363,9 +1363,9 @@ Application::Application () { } -Application* Application::New () +std::unique_ptr make_Application () { - return new ApplicationImp; + return std::make_unique (); } Application& getApp () diff --git a/src/ripple_app/main/Application.h b/src/ripple_app/main/Application.h index eb30fe1f9..2e2fd2039 100644 --- a/src/ripple_app/main/Application.h +++ b/src/ripple_app/main/Application.h @@ -72,8 +72,6 @@ public: virtual LockType& getMasterLock () = 0; public: - static Application* New (); - Application (); virtual ~Application () { } @@ -127,6 +125,26 @@ public: virtual void signalStop () = 0; }; +/** Create an instance of the Application object. + As long as there are legacy calls to getApp it is not safe + to create more than one Application object at a time. +*/ +std::unique_ptr make_Application(); + +// VFALCO DEPRECATED +// +// Please do not write new code that calls getApp(). Instead, +// Use dependency injection to construct your class with a +// reference to the desired interface (Application in this case). +// Or better yet, instead of relying on the entire Application +// object, construct with just the interfaces that you need. +// +// When working in existing code, try to clean it up by rewriting +// calls to getApp to use a data member instead, and inject the +// needed interfaces in the constructor. +// +// http://en.wikipedia.org/wiki/Dependency_injection +// extern Application& getApp (); #endif diff --git a/src/ripple_app/main/RippleMain.cpp b/src/ripple_app/main/RippleMain.cpp index 944dc85a7..dae87bb28 100644 --- a/src/ripple_app/main/RippleMain.cpp +++ b/src/ripple_app/main/RippleMain.cpp @@ -154,7 +154,7 @@ public: // code demands the Application object exists. // // TODO To find out who, just comment the next line out - m_app.reset (Application::New ()); + m_app = make_Application(); setAssertOnFailure (false); } @@ -455,7 +455,7 @@ int RippleMain::run (int argc, char const* const* argv) if (!vm.count ("parameters")) { // No arguments. Run server. - std::unique_ptr app (Application::New ()); + std::unique_ptr app (make_Application ()); setupServer (); startServer (); } diff --git a/src/ripple_app/ripple_app.cpp b/src/ripple_app/ripple_app.cpp index 881db08bc..30288f57a 100644 --- a/src/ripple_app/ripple_app.cpp +++ b/src/ripple_app/ripple_app.cpp @@ -42,6 +42,7 @@ #include "beast/beast/Asio.h" #include "beast/beast/asio/io_latency_probe.h" +#include "beast/beast/make_unique.h" # include "main/CollectorManager.h" #include "main/CollectorManager.cpp" diff --git a/src/ripple_app/shamap/FetchPackTests.cpp b/src/ripple_app/shamap/FetchPackTests.cpp index bfb17bb28..96ffd43f8 100644 --- a/src/ripple_app/shamap/FetchPackTests.cpp +++ b/src/ripple_app/shamap/FetchPackTests.cpp @@ -73,9 +73,9 @@ public: beginTestCase ("Build"); - shared_ptr t1 (beast::make_shared
(smtFREE)); + boost::shared_ptr
t1 (boost::make_shared
(smtFREE)); add_random_items (tableItems, *t1, random()); - shared_ptr
t2 (t1->snapShot (true)); + boost::shared_ptr
t2 (t1->snapShot (true)); add_random_items (tableItemsExtra, *t1, random ()); add_random_items (tableItemsExtra, *t2, random ()); @@ -88,23 +88,22 @@ public: &FetchPackTests::on_fetch, this, boost::ref (map), _1, _2)); // try to rebuild t2 from the fetch pack - shared_ptr
t3; + boost::shared_ptr
t3; try { TestFilter filter (map, journal ()); - t3 = beast::make_shared
(smtFREE, t2->getHash () ); + t3 = boost::make_shared
(smtFREE, t2->getHash () ); expect (t3->fetchRoot (t2->getHash (), &filter), "unable to get root"); // everything should be in the pack, no hashes should be needed - std::vector hashes = t3->getNeededHashes(1, &filter); + std::vector hashes = t3->getNeededHashes(1, &filter); expect (hashes.empty(), "missing hashes"); } catch (...) { - journal().fatal << "exception"; - fail (); + failException (); } expect (t3->getHash () == t2->getHash (), "root hashes do not match"); diff --git a/src/ripple_app/shamap/RadixMapTest.cpp b/src/ripple_app/shamap/RadixMapTest.cpp index 36eeb838e..13ada695c 100644 --- a/src/ripple_app/shamap/RadixMapTest.cpp +++ b/src/ripple_app/shamap/RadixMapTest.cpp @@ -20,12 +20,12 @@ namespace ripple { namespace RadixMap { -shared_ptr make_random_item (Random& r) +boost::shared_ptr make_random_item (Random& r) { Serializer s; for (int d = 0; d < 3; ++d) s.add32 (r.nextInt ()); - return beast::make_shared ( + return boost::make_shared ( s.getRIPEMD160().to256(), s.peekData ()); } @@ -35,7 +35,7 @@ void add_random_items (std::size_t n, Table& t, Random& r) { while (n--) { - shared_ptr item ( + boost::shared_ptr item ( make_random_item (r)); meets_postcondition ( t.addItem (*item, false, false)); diff --git a/src/ripple_app/shamap/RadixMapTest.h b/src/ripple_app/shamap/RadixMapTest.h index a66af04d7..9f7d22869 100644 --- a/src/ripple_app/shamap/RadixMapTest.h +++ b/src/ripple_app/shamap/RadixMapTest.h @@ -26,7 +26,7 @@ typedef SHAMapItem Item; // Utility functions for RadixMap::Table (a.k.a. SHAMap) unit tests /** Returns a pseudo random Table item. */ -shared_ptr make_random_item (Random& r); +boost::shared_ptr make_random_item (Random& r); /** Adds a set of random items to the Table. @param n The number of items to add. diff --git a/src/ripple_basics/containers/TaggedCache.cpp b/src/ripple_basics/containers/TaggedCache.cpp index 19308bcfc..95ab48109 100644 --- a/src/ripple_basics/containers/TaggedCache.cpp +++ b/src/ripple_basics/containers/TaggedCache.cpp @@ -97,7 +97,7 @@ public: { Cache::mapped_ptr const p1 (c.fetch (3)); - Cache::mapped_ptr p2 (make_shared ("three")); + Cache::mapped_ptr p2 (boost::make_shared ("three")); c.canonicalize (3, p2); expect (p1.get() == p2.get()); }