Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-5879 Remove use of Boost smart pointers throughout the Science Pipelines #15

Merged
merged 6 commits into from
May 4, 2016
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions include/lsst/daf/persistence/BoostStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/scoped_ptr.hpp>
#include <memory>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix order

#include <fstream>

namespace lsst {
Expand All @@ -57,7 +57,7 @@ namespace persistence {

class BoostStorage : public Storage {
public:
typedef boost::shared_ptr<BoostStorage> Ptr;
typedef std::shared_ptr<BoostStorage> Ptr;

BoostStorage(void);
virtual ~BoostStorage(void);
Expand All @@ -73,11 +73,11 @@ class BoostStorage : public Storage {
virtual boost::archive::text_iarchive& getIArchive(void);

private:
boost::scoped_ptr<std::ofstream> _ostream; ///< Output stream.
boost::scoped_ptr<std::ifstream> _istream; ///< Input stream.
boost::scoped_ptr<boost::archive::text_oarchive> _oarchive;
std::unique_ptr<std::ofstream> _ostream; ///< Output stream.
std::unique_ptr<std::ifstream> _istream; ///< Input stream.
std::unique_ptr<boost::archive::text_oarchive> _oarchive;
///< boost::serialization archive wrapper for output stream.
boost::scoped_ptr<boost::archive::text_iarchive> _iarchive;
std::unique_ptr<boost::archive::text_iarchive> _iarchive;
///< boost::serialization archive wrapper for input stream.
};

Expand Down
6 changes: 3 additions & 3 deletions include/lsst/daf/persistence/DbStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

#include <string>
#include <vector>
#include <boost/scoped_ptr.hpp>
#include <memory>

namespace lsst {
namespace daf {
Expand All @@ -62,7 +62,7 @@ class DbStorageLocation;

class DbStorage : public Storage {
public:
typedef boost::shared_ptr<DbStorage> Ptr;
typedef std::shared_ptr<DbStorage> Ptr;

DbStorage(void);
~DbStorage(void);
Expand Down Expand Up @@ -110,7 +110,7 @@ class DbStorage : public Storage {
explicit DbStorage(std::type_info const& type);

private:
boost::scoped_ptr<DbStorageImpl> _impl;
std::unique_ptr<DbStorageImpl> _impl;
///< Implementation class for isolation.
};

Expand Down
4 changes: 2 additions & 2 deletions include/lsst/daf/persistence/DbStorageLocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
* @ingroup daf_persistence
*/

#include <boost/shared_ptr.hpp>
#include <memory>
#include <string>

#include "lsst/daf/base/Citizen.h"
Expand All @@ -57,7 +57,7 @@ namespace persistence {

class DbStorageLocation : public lsst::daf::base::Citizen {
public:
typedef boost::shared_ptr<DbStorageLocation> Ptr;
typedef std::shared_ptr<DbStorageLocation> Ptr;

DbStorageLocation(void);
DbStorageLocation(std::string const& url);
Expand Down
6 changes: 3 additions & 3 deletions include/lsst/daf/persistence/DbTsvStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

#include "lsst/daf/persistence/DbStorage.h"

#include <boost/scoped_ptr.hpp>
#include <memory>
#include <fstream>
#include <map>
#include <sstream>
Expand All @@ -65,7 +65,7 @@ namespace persistence {

class DbTsvStorage : public DbStorage {
public:
typedef boost::shared_ptr<DbTsvStorage> Ptr;
typedef std::shared_ptr<DbTsvStorage> Ptr;

DbTsvStorage(void);
~DbTsvStorage(void);
Expand Down Expand Up @@ -106,7 +106,7 @@ class DbTsvStorage : public DbStorage {
std::map<std::string, int> _colMap; ///< Map from column names to positions.
std::ostringstream _convertStream; ///< Stream to convert to text.
std::vector<std::string> _rowBuffer;
boost::scoped_ptr<std::ofstream> _osp; ///< Output TSV stream.
std::unique_ptr<std::ofstream> _osp; ///< Output TSV stream.

int _getColumnIndex(std::string const& columnName);
};
Expand Down
2 changes: 1 addition & 1 deletion include/lsst/daf/persistence/FitsStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace persistence {

class FitsStorage : public Storage {
public:
typedef boost::shared_ptr<FitsStorage> Ptr;
typedef std::shared_ptr<FitsStorage> Ptr;

FitsStorage(void);
virtual ~FitsStorage(void);
Expand Down
4 changes: 2 additions & 2 deletions include/lsst/daf/persistence/Formatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
* @ingroup daf_persistence
*/

#include <boost/shared_ptr.hpp>
#include <memory>
#include <string>
#include <typeinfo>

Expand All @@ -78,7 +78,7 @@ class LogicalLocation;

class Formatter : public lsst::daf::base::Citizen {
public:
typedef boost::shared_ptr<Formatter> Ptr;
typedef std::shared_ptr<Formatter> Ptr;

/** Pointer to a (static) factory function for a Formatter subclass.
*/
Expand Down
4 changes: 2 additions & 2 deletions include/lsst/daf/persistence/LogicalLocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
* @ingroup daf_persistence
*/

#include <boost/shared_ptr.hpp>
#include <memory>
#include <string>

#include "lsst/base.h"
Expand All @@ -59,7 +59,7 @@ namespace dafBase = lsst::daf::base;

class LogicalLocation : public dafBase::Citizen {
public:
typedef boost::shared_ptr<LogicalLocation> Ptr;
typedef std::shared_ptr<LogicalLocation> Ptr;

LogicalLocation(std::string const& locString,
CONST_PTR(dafBase::PropertySet) additionalData = CONST_PTR(dafBase::PropertySet)());
Expand Down
4 changes: 2 additions & 2 deletions include/lsst/daf/persistence/Persistence.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
* @ingroup daf_persistence
*/

#include <boost/shared_ptr.hpp>
#include <memory>
#include <map>
#include <string>
#include <vector>
Expand All @@ -67,7 +67,7 @@ class LogicalLocation;

class Persistence : public lsst::daf::base::Citizen {
public:
typedef boost::shared_ptr<Persistence> Ptr;
typedef std::shared_ptr<Persistence> Ptr;

virtual ~Persistence(void);

Expand Down
4 changes: 2 additions & 2 deletions include/lsst/daf/persistence/Storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
* @ingroup daf_persistence
*/

#include <boost/shared_ptr.hpp>
#include <memory>
#include <map>
#include <string>
#include <typeinfo>
Expand All @@ -59,7 +59,7 @@ class LogicalLocation;

class Storage : public lsst::daf::base::Citizen {
public:
typedef boost::shared_ptr<Storage> Ptr;
typedef std::shared_ptr<Storage> Ptr;
typedef std::vector<Ptr> List;

virtual ~Storage(void);
Expand Down
2 changes: 1 addition & 1 deletion include/lsst/daf/persistence/StorageRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
* @ingroup daf_persistence
*/

#include <boost/shared_ptr.hpp>
#include <memory>
#include <string>

// #include "lsst/daf/base/Citizen.h"
Expand Down
12 changes: 6 additions & 6 deletions include/lsst/daf/persistence/XmlStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

#include <boost/archive/xml_oarchive.hpp>
#include <boost/archive/xml_iarchive.hpp>
#include <boost/scoped_ptr.hpp>
#include <memory>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix order of imports

#include <fstream>

namespace lsst {
Expand All @@ -56,7 +56,7 @@ namespace persistence {

class XmlStorage : public Storage {
public:
typedef boost::shared_ptr<XmlStorage> Ptr;
typedef std::shared_ptr<XmlStorage> Ptr;

XmlStorage(void);
virtual ~XmlStorage(void);
Expand All @@ -72,13 +72,13 @@ class XmlStorage : public Storage {
virtual boost::archive::xml_iarchive& getIArchive(void);

private:
boost::scoped_ptr<std::ofstream> _ostream;
std::unique_ptr<std::ofstream> _ostream;
///< Underlying output stream.
boost::scoped_ptr<std::ifstream> _istream;
std::unique_ptr<std::ifstream> _istream;
///< Underlying input stream.
boost::scoped_ptr<boost::archive::xml_oarchive> _oarchive;
std::unique_ptr<boost::archive::xml_oarchive> _oarchive;
///< Boost XML output archive.
boost::scoped_ptr<boost::archive::xml_iarchive> _iarchive;
std::unique_ptr<boost::archive::xml_iarchive> _iarchive;
///< Boost XML input archive.
};

Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/persistence/persistenceLib.i
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Access to the lsst::daf::persistence classes
%newobject lsst::daf::persistence::Persistence::getRetrieveStorage;
%newobject lsst::daf::persistence::Persistence::unsafeRetrieve;

%template(StorageList) std::vector<boost::shared_ptr<lsst::daf::persistence::Storage> >;
%template(StorageList) std::vector<std::shared_ptr<lsst::daf::persistence::Storage> >;
%template(TableList) std::vector<std::string>;

%include "lsst/daf/persistence/DbAuth.h"
Expand Down
10 changes: 5 additions & 5 deletions src/BoostStorage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace persistence {
/** Constructor.
*/
BoostStorage::BoostStorage(void) : Storage(typeid(*this)),
_ostream(0), _istream(0), _oarchive(0), _iarchive(0) {
_ostream{}, _istream{}, _oarchive{}, _iarchive{} {
}

/** Destructor.
Expand Down Expand Up @@ -102,10 +102,10 @@ void BoostStorage::startTransaction(void) {
* No transaction support for now.
*/
void BoostStorage::endTransaction(void) {
_oarchive.reset(0);
_ostream.reset(0);
_iarchive.reset(0);
_istream.reset(0);
_oarchive.reset();
_ostream.reset();
_iarchive.reset();
_istream.reset();
}

/** Get a \c boost::serialization archive suitable for output.
Expand Down
10 changes: 5 additions & 5 deletions src/XmlStorage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace persistence {
/** Constructor.
*/
XmlStorage::XmlStorage(void) : Storage(typeid(*this)),
_ostream(0), _istream(0), _oarchive(0), _iarchive(0) {
_ostream{}, _istream{}, _oarchive{}, _iarchive{} {
}

/** Destructor.
Expand Down Expand Up @@ -95,10 +95,10 @@ void XmlStorage::startTransaction(void) {
* No transaction support for now, but close streams.
*/
void XmlStorage::endTransaction(void) {
_oarchive.reset(0);
_ostream.reset(0);
_iarchive.reset(0);
_istream.reset(0);
_oarchive.reset();
_ostream.reset();
_iarchive.reset();
_istream.reset();
}

/** Get a \c boost::serialization XML archive suitable for output.
Expand Down
8 changes: 4 additions & 4 deletions tests/Persistence_1.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class MyFormatter;

class MyPersistable : public dafBase::Persistable {
public:
typedef boost::shared_ptr<MyPersistable> Ptr;
typedef std::shared_ptr<MyPersistable> Ptr;
MyPersistable(double ra = 0.0, double decl = 0.0) : _ra(ra), _decl(decl) { };
double getRa(void) const { return _ra; };
double getDecl(void) const { return _decl; };
Expand Down Expand Up @@ -236,7 +236,7 @@ BOOST_AUTO_TEST_CASE(PersistenceTest) {
dafBase::Persistable::Ptr pp = persist->retrieve("MyPersistable", storageList, additionalData);
BOOST_CHECK(pp != 0);
BOOST_CHECK(typeid(*pp) == typeid(MyPersistable));
MyPersistable::Ptr mp1 = boost::dynamic_pointer_cast<MyPersistable, dafBase::Persistable>(pp);
MyPersistable::Ptr mp1 = std::dynamic_pointer_cast<MyPersistable, dafBase::Persistable>(pp);
BOOST_CHECK(mp1);
BOOST_CHECK(mp1.get() != &mp);
BOOST_CHECK_EQUAL(mp1->getRa(), 1.73205);
Expand All @@ -251,7 +251,7 @@ BOOST_AUTO_TEST_CASE(PersistenceTest) {
dafBase::Persistable::Ptr pp = persist->retrieve("MyPersistable", storageList, additionalData);
BOOST_CHECK(pp);
BOOST_CHECK(typeid(*pp) == typeid(MyPersistable));
MyPersistable::Ptr mp1 = boost::dynamic_pointer_cast<MyPersistable, dafBase::Persistable>(pp);
MyPersistable::Ptr mp1 = std::dynamic_pointer_cast<MyPersistable, dafBase::Persistable>(pp);
BOOST_CHECK(mp1);
BOOST_CHECK(mp1.get() != &mp);
BOOST_CHECK_EQUAL(mp1->getRa(), 1.73205);
Expand All @@ -274,7 +274,7 @@ BOOST_AUTO_TEST_CASE(PersistenceTest) {
dafBase::Persistable::Ptr pp = persist->retrieve("MyPersistable", storageList, additionalData);
BOOST_CHECK(pp);
BOOST_CHECK(typeid(*pp) == typeid(MyPersistable));
MyPersistable::Ptr mp1 = boost::dynamic_pointer_cast<MyPersistable, dafBase::Persistable>(pp);
MyPersistable::Ptr mp1 = std::dynamic_pointer_cast<MyPersistable, dafBase::Persistable>(pp);
BOOST_CHECK(mp1);
BOOST_CHECK(mp1.get() != &mp);
BOOST_CHECK_EQUAL(mp1->getRa(), 1.73205);
Expand Down
4 changes: 2 additions & 2 deletions tests/Persistence_2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class MyFormatter;

class MyPersistable : public dafBase::Persistable {
public:
typedef boost::shared_ptr<MyPersistable> Ptr;
typedef std::shared_ptr<MyPersistable> Ptr;
MyPersistable(double ra = 0.0, double decl = 0.0) : _ra(ra), _decl(decl) { };
double getRa(void) const { return _ra; };
double getDecl(void) const { return _decl; };
Expand Down Expand Up @@ -236,7 +236,7 @@ BOOST_AUTO_TEST_CASE(Persistence2Test) {
dafBase::Persistable::Ptr pp = persist->retrieve("MyPersistable", storageList, additionalData);
BOOST_CHECK_MESSAGE(pp != 0, "Didn't get a Persistable");
BOOST_CHECK_MESSAGE(typeid(*pp) == typeid(MyPersistable), "Didn't get MyPersistable");
MyPersistable::Ptr mp1 = boost::dynamic_pointer_cast<MyPersistable, dafBase::Persistable>(pp);
MyPersistable::Ptr mp1 = std::dynamic_pointer_cast<MyPersistable, dafBase::Persistable>(pp);
BOOST_CHECK_MESSAGE(mp1, "Couldn't cast to MyPersistable");
BOOST_CHECK_MESSAGE(mp1.get() != &mp, "Got same MyPersistable");
BOOST_CHECK_MESSAGE(mp1->getRa() == 1.73205, "RA is incorrect");
Expand Down
6 changes: 3 additions & 3 deletions tests/Persistence_3.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class MyFormatter;

class MyPersistable : public dafBase::Persistable {
public:
typedef boost::shared_ptr<MyPersistable> Ptr;
typedef std::shared_ptr<MyPersistable> Ptr;
MyPersistable(double ra = 0.0, double decl = 0.0) : _ra(ra), _decl(decl) { };
double getRa(void) const { return _ra; };
double getDecl(void) const { return _decl; };
Expand Down Expand Up @@ -158,13 +158,13 @@ BOOST_AUTO_TEST_CASE(Persistence3Test) {
dafBase::Persistable::Ptr pp = persist->retrieve("PropertySet", storageList, additionalData);
BOOST_CHECK_MESSAGE(pp != 0, "Didn't get a Persistable");
BOOST_CHECK_MESSAGE(typeid(*pp) == typeid(dafBase::PropertySet), "Didn't get PropertySet");
dafBase::PropertySet::Ptr dp = boost::dynamic_pointer_cast<dafBase::PropertySet, dafBase::Persistable>(pp);
dafBase::PropertySet::Ptr dp = std::dynamic_pointer_cast<dafBase::PropertySet, dafBase::Persistable>(pp);
BOOST_CHECK_MESSAGE(dp, "Couldn't cast to PropertySet");
BOOST_CHECK_MESSAGE(dp != theProperty, "Got same PropertySet");
dafBase::Persistable::Ptr pp1 = dp->getAsPersistablePtr("prop");
BOOST_CHECK_MESSAGE(pp1, "Couldn't retrieve Persistable");
BOOST_CHECK_MESSAGE(typeid(*pp1) == typeid(MyPersistable), "Not a MyPersistable");
MyPersistable::Ptr mp = boost::dynamic_pointer_cast<MyPersistable, dafBase::Persistable>(pp1);
MyPersistable::Ptr mp = std::dynamic_pointer_cast<MyPersistable, dafBase::Persistable>(pp1);
BOOST_CHECK_MESSAGE(mp, "Couldn't retrieve MyPersistable");
BOOST_CHECK_MESSAGE(mp->getRa() == 1.73205, "RA is incorrect");
BOOST_CHECK_MESSAGE(mp->getDecl() == 1.61803, "Decl is incorrect");
Expand Down