Change "trivial" occurrences of gmx_unique_ptr to boost::shared_ptr in
cases where there is a simple factory or a sink function where the
ownership of the object passes in or out from the library.
The main advantages:
- Removes GMX_CXX11 dependencies from installed headers.
- Improves memory management, where the memory is deallocated in the
same library/executable that allocated it (through the shared_ptr
deleter that gets created during construction).
The only disadvantage is that this blurs the ownership of the objects
slightly.
There are only two other instances of gmx_unique_ptr left in installed
headers, and those should be relatively easy to remove as well with a
bit of refactoring.
Related to #1454.
Change-Id: I1f694b30e4f8129f5d010115c0968a444e927ca0
/*
* This file is part of the GROMACS molecular simulation package.
*
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2010,2011,2012,2013, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#ifndef GMX_ANALYSISDATA_MODULES_HISTOGRAM_H
#define GMX_ANALYSISDATA_MODULES_HISTOGRAM_H
#ifndef GMX_ANALYSISDATA_MODULES_HISTOGRAM_H
#define GMX_ANALYSISDATA_MODULES_HISTOGRAM_H
+#include <boost/shared_ptr.hpp>
+
#include "../abstractdata.h"
#include "../arraydata.h"
#include "../datamodule.h"
#include "../abstractdata.h"
#include "../arraydata.h"
#include "../datamodule.h"
-#include "../../utility/uniqueptr.h"
class AbstractAverageHistogram;
//! Smart pointer to manage an AbstractAverageHistogram object.
class AbstractAverageHistogram;
//! Smart pointer to manage an AbstractAverageHistogram object.
-typedef gmx_unique_ptr<AbstractAverageHistogram>::type
+typedef boost::shared_ptr<AbstractAverageHistogram>
AverageHistogramPointer;
/*! \brief
AverageHistogramPointer;
/*! \brief
CommandLineProgramContext::Impl::Impl(int argc, const char *const argv[],
ExecutableEnvironmentPointer env)
CommandLineProgramContext::Impl::Impl(int argc, const char *const argv[],
ExecutableEnvironmentPointer env)
- : executableEnv_(move(env))
{
invokedName_ = (argc != 0 ? argv[0] : "");
programName_ = Path::getFilename(invokedName_);
{
invokedName_ = (argc != 0 ? argv[0] : "");
programName_ = Path::getFilename(invokedName_);
CommandLineProgramContext::CommandLineProgramContext(
int argc, const char *const argv[], ExecutableEnvironmentPointer env)
CommandLineProgramContext::CommandLineProgramContext(
int argc, const char *const argv[], ExecutableEnvironmentPointer env)
- : impl_(new Impl(argc, argv, move(env)))
+ : impl_(new Impl(argc, argv, env))
#include <string>
#include <vector>
#include <string>
#include <vector>
+#include <boost/shared_ptr.hpp>
+
#include "../utility/common.h"
#include "../utility/programcontext.h"
#include "../utility/common.h"
#include "../utility/programcontext.h"
-#include "../utility/uniqueptr.h"
};
//! Shorthand for a smart pointer to ExecutableEnvironmentInterface.
};
//! Shorthand for a smart pointer to ExecutableEnvironmentInterface.
-typedef gmx_unique_ptr<ExecutableEnvironmentInterface>::type
+typedef boost::shared_ptr<ExecutableEnvironmentInterface>
ExecutableEnvironmentPointer;
/*! \libinternal \brief
ExecutableEnvironmentPointer;
/*! \libinternal \brief
#include <string>
#include <vector>
#include <string>
#include <vector>
+#include <boost/shared_ptr.hpp>
#include <gtest/gtest.h>
#include "gromacs/commandline/cmdlineprogramcontext.h"
#include "gromacs/utility/common.h"
#include "gromacs/utility/path.h"
#include <gtest/gtest.h>
#include "gromacs/commandline/cmdlineprogramcontext.h"
#include "gromacs/utility/common.h"
#include "gromacs/utility/path.h"
-#include "gromacs/utility/uniqueptr.h"
#include "testutils/cmdlinetest.h"
#include "testutils/cmdlinetest.h"
};
//! Shorthand for a smart pointer to TestExecutableEnvironment.
};
//! Shorthand for a smart pointer to TestExecutableEnvironment.
-typedef gmx::gmx_unique_ptr<TestExecutableEnvironment>::type
+typedef boost::shared_ptr<TestExecutableEnvironment>
TestExecutableEnvironmentPointer;
class CommandLineProgramContextTest : public ::testing::Test
TestExecutableEnvironmentPointer;
class CommandLineProgramContextTest : public ::testing::Test
void testBinaryPathSearch(const char *argv0)
{
ASSERT_TRUE(env_.get() != NULL);
void testBinaryPathSearch(const char *argv0)
{
ASSERT_TRUE(env_.get() != NULL);
- gmx::CommandLineProgramContext info(1, &argv0, move(env_));
+ gmx::CommandLineProgramContext info(1, &argv0, env_);
EXPECT_EQ(expectedExecutable_, info.fullBinaryPath());
}
void testBinaryPathSearch(const std::string &argv0)
EXPECT_EQ(expectedExecutable_, info.fullBinaryPath());
}
void testBinaryPathSearch(const std::string &argv0)
#include <string>
#include <vector>
#include <string>
#include <vector>
+#include <boost/shared_ptr.hpp>
+
#include "../selection/selection.h" // For gmx::SelectionList
#include "../utility/common.h"
#include "../selection/selection.h" // For gmx::SelectionList
#include "../utility/common.h"
-#include "../utility/uniqueptr.h"
struct t_pbc;
struct t_trxframe;
struct t_pbc;
struct t_trxframe;
};
//! Smart pointer to manage a TrajectoryAnalysisModuleData object.
};
//! Smart pointer to manage a TrajectoryAnalysisModuleData object.
-typedef gmx_unique_ptr<TrajectoryAnalysisModuleData>::type
+typedef boost::shared_ptr<TrajectoryAnalysisModuleData>
TrajectoryAnalysisModuleDataPointer;
/*! \brief
TrajectoryAnalysisModuleDataPointer;
/*! \brief
};
//! Smart pointer to manage a TrajectoryAnalysisModule.
};
//! Smart pointer to manage a TrajectoryAnalysisModule.
-typedef gmx_unique_ptr<TrajectoryAnalysisModule>::type
+typedef boost::shared_ptr<TrajectoryAnalysisModule>
TrajectoryAnalysisModulePointer;
} // namespace gmx
TrajectoryAnalysisModulePointer;
} // namespace gmx