src: Removing unnecessary use of cref() in concert with make_shared
This commit also replaces all usages of shared_ptr<T>(new T) with
make_shared<T> in Face class implementation.
Change-Id: I44971c44eb7f2c25ecfe00e185309973c9cbd246
Refs: #1592
diff --git a/src/encoding/block.cpp b/src/encoding/block.cpp
index 38fb85b..e3730c3 100644
--- a/src/encoding/block.cpp
+++ b/src/encoding/block.cpp
@@ -148,7 +148,7 @@
throw Tlv::Error("Not enough data in the buffer to fully parse TLV");
}
- m_buffer = ptr_lib::make_shared<Buffer>(buffer, (tmp_begin - buffer) + length);
+ m_buffer = make_shared<Buffer>(buffer, (tmp_begin - buffer) + length);
m_begin = m_buffer->begin();
m_end = m_buffer->end();
@@ -173,7 +173,7 @@
throw Tlv::Error("Not enough data in the buffer to fully parse TLV");
}
- m_buffer = ptr_lib::make_shared<Buffer>(buffer, (tmp_begin - buffer) + length);
+ m_buffer = make_shared<Buffer>(buffer, (tmp_begin - buffer) + length);
m_begin = m_buffer->begin();
m_end = m_buffer->end();
diff --git a/src/encoding/buffer.hpp b/src/encoding/buffer.hpp
index 3130a73..d4b14c0 100644
--- a/src/encoding/buffer.hpp
+++ b/src/encoding/buffer.hpp
@@ -175,7 +175,7 @@
* OBufferStream obuf;
* obuf.put(0);
* obuf.write(another_buffer, another_buffer_size);
- * ptr_lib::shared_ptr<Buffer> buf = obuf.get();
+ * shared_ptr<Buffer> buf = obuf.get();
* @endcode
*/
struct OBufferStream : public boost::iostreams::stream<iostreams::buffer_append_device>
@@ -184,7 +184,7 @@
* Default constructor
*/
OBufferStream()
- : m_buffer(ptr_lib::make_shared<Buffer>())
+ : m_buffer(make_shared<Buffer>())
, m_device(*m_buffer)
{
open(m_device);
@@ -193,7 +193,7 @@
/**
* Flush written data to the stream and return shared pointer to the underlying buffer
*/
- ptr_lib::shared_ptr<Buffer>
+ shared_ptr<Buffer>
buf()
{
flush();
diff --git a/src/face.cpp b/src/face.cpp
index ee35f28..6432acf 100644
--- a/src/face.cpp
+++ b/src/face.cpp
@@ -32,7 +32,7 @@
, m_isDirectNfdFibManagementRequested(false)
{
const std::string socketName = UnixTransport::getDefaultSocketName(m_config);
- construct(shared_ptr<Transport>(new UnixTransport(socketName)),
+ construct(make_shared<UnixTransport>(socketName),
make_shared<boost::asio::io_service>());
}
@@ -41,7 +41,7 @@
, m_isDirectNfdFibManagementRequested(false)
{
const std::string socketName = UnixTransport::getDefaultSocketName(m_config);
- construct(shared_ptr<Transport>(new UnixTransport(socketName)),
+ construct(make_shared<UnixTransport>(socketName),
ioService);
}
@@ -59,14 +59,14 @@
, m_isDirectNfdFibManagementRequested(false)
{
const std::string socketName = UnixTransport::getDefaultSocketName(m_config);
- construct(shared_ptr<Transport>(new UnixTransport(socketName)),
+ construct(make_shared<UnixTransport>(socketName),
shared_ptr<boost::asio::io_service>(&ioService, NullIoDeleter()));
}
Face::Face(const std::string& host, const std::string& port/* = "6363"*/)
: m_nfdController(new nfd::Controller(*this))
{
- construct(shared_ptr<Transport>(new TcpTransport(host, port)),
+ construct(make_shared<TcpTransport>(host, port),
make_shared<boost::asio::io_service>());
}
@@ -139,7 +139,7 @@
m_transport->connect(*m_ioService,
bind(&Face::onReceiveElement, this, _1));
- shared_ptr<Interest> interestToExpress(new Interest(interest));
+ shared_ptr<Interest> interestToExpress = make_shared<Interest>(interest);
// If the same ioService thread, dispatch directly calls the method
m_ioService->dispatch(bind(&Face::asyncExpressInterest, this,
@@ -171,8 +171,7 @@
if (!m_transport->isExpectingData())
m_transport->resume();
- m_pendingInterestTable.push_back(shared_ptr<PendingInterest>(new PendingInterest
- (interest, onData, onTimeout)));
+ m_pendingInterestTable.push_back(make_shared<PendingInterest>(interest, onData, onTimeout));
if (!interest->getLocalControlHeader().empty(false, true))
{
@@ -574,7 +573,7 @@
if (block.type() == Tlv::Interest)
{
- shared_ptr<Interest> interest(new Interest());
+ shared_ptr<Interest> interest = make_shared<Interest>();
interest->wireDecode(block);
if (&block != &blockFromDaemon)
interest->getLocalControlHeader().wireDecode(blockFromDaemon);
@@ -583,7 +582,7 @@
}
else if (block.type() == Tlv::Data)
{
- shared_ptr<Data> data(new Data());
+ shared_ptr<Data> data = make_shared<Data>();
data->wireDecode(block);
if (&block != &blockFromDaemon)
data->getLocalControlHeader().wireDecode(blockFromDaemon);
diff --git a/src/name.hpp b/src/name.hpp
index 3817a66..1abffbc 100644
--- a/src/name.hpp
+++ b/src/name.hpp
@@ -30,7 +30,7 @@
/**
* A Name holds an array of Name::Component and represents an NDN name.
*/
-class Name : public ptr_lib::enable_shared_from_this<Name>
+class Name : public enable_shared_from_this<Name>
{
public:
/// @brief Error that can be thrown from Name
diff --git a/src/security/conf/checker.hpp b/src/security/conf/checker.hpp
index 05eb8c1..1ebcf0d 100644
--- a/src/security/conf/checker.hpp
+++ b/src/security/conf/checker.hpp
@@ -380,7 +380,7 @@
if (propertyIt != configSection.end())
throw Error("Expect the end of checker!");
- return make_shared<CustomizedChecker>(getSigType(sigType), cref(keyLocatorChecker));
+ return make_shared<CustomizedChecker>(getSigType(sigType), keyLocatorChecker);
}
static shared_ptr<Checker>
diff --git a/src/security/conf/filter.hpp b/src/security/conf/filter.hpp
index 8fa91b8..8caa5cc 100644
--- a/src/security/conf/filter.hpp
+++ b/src/security/conf/filter.hpp
@@ -199,8 +199,7 @@
if (propertyIt != configSection.end())
throw Error("Expect the end of filter!");
- return make_shared<RelationNameFilter>(cref(name),
- cref(relation));
+ return make_shared<RelationNameFilter>(name, relation);
}
else if (boost::iequals(propertyIt->first, "regex"))
{
diff --git a/src/security/sec-public-info-memory.cpp b/src/security/sec-public-info-memory.cpp
index c9efc2f..be0a1e7 100644
--- a/src/security/sec-public-info-memory.cpp
+++ b/src/security/sec-public-info-memory.cpp
@@ -61,7 +61,7 @@
addIdentity(identityName);
- m_keyStore[keyName.toUri()] = make_shared<KeyRecord>(keyType, cref(publicKey));
+ m_keyStore[keyName.toUri()] = make_shared<KeyRecord>(keyType, publicKey);
}
shared_ptr<PublicKey>
diff --git a/src/security/validator-config.hpp b/src/security/validator-config.hpp
index 9dc69e3..121d7e1 100644
--- a/src/security/validator-config.hpp
+++ b/src/security/validator-config.hpp
@@ -209,7 +209,7 @@
Interest certInterest(keyLocatorName);
shared_ptr<ValidationRequest> nextStep =
- make_shared<ValidationRequest>(cref(certInterest),
+ make_shared<ValidationRequest>(certInterest,
onCertValidated,
onCertValidationFailed,
1, nSteps + 1);
@@ -229,7 +229,7 @@
const OnFailed& onValidationFailed)
{
shared_ptr<IdentityCertificate> certificate =
- make_shared<IdentityCertificate>(cref(*signCertificate));
+ make_shared<IdentityCertificate>(*signCertificate);
if (!certificate->isTooLate() && !certificate->isTooEarly())
{
diff --git a/src/security/validator-regex.cpp b/src/security/validator-regex.cpp
index b4fd1b8..4c74e79 100644
--- a/src/security/validator-regex.cpp
+++ b/src/security/validator-regex.cpp
@@ -46,7 +46,7 @@
const OnDataValidationFailed& onValidationFailed)
{
shared_ptr<IdentityCertificate> certificate =
- make_shared<IdentityCertificate>(cref(*signCertificate));
+ make_shared<IdentityCertificate>(*signCertificate);
if (!certificate->isTooLate() && !certificate->isTooEarly())
{
@@ -137,7 +137,7 @@
Interest interest(sig.getKeyLocator().getName());
shared_ptr<ValidationRequest> nextStep =
- make_shared<ValidationRequest>(cref(interest),
+ make_shared<ValidationRequest>(interest,
onKeyValidated,
onKeyValidationFailed,
3,
diff --git a/src/transport/transport.hpp b/src/transport/transport.hpp
index 3ed386c..8291356 100644
--- a/src/transport/transport.hpp
+++ b/src/transport/transport.hpp
@@ -28,8 +28,8 @@
inline Error(const std::string& msg);
};
- typedef ptr_lib::function<void (const Block& wire)> ReceiveCallback;
- typedef ptr_lib::function<void ()> ErrorCallback;
+ typedef function<void (const Block& wire)> ReceiveCallback;
+ typedef function<void ()> ErrorCallback;
inline
Transport();
diff --git a/src/transport/unix-transport.hpp b/src/transport/unix-transport.hpp
index 6cff8dc..5fe14ee 100644
--- a/src/transport/unix-transport.hpp
+++ b/src/transport/unix-transport.hpp
@@ -74,7 +74,7 @@
typedef StreamTransportImpl<UnixTransport, boost::asio::local::stream_protocol> Impl;
friend class StreamTransportImpl<UnixTransport, boost::asio::local::stream_protocol>;
- ptr_lib::shared_ptr< Impl > m_impl;
+ shared_ptr< Impl > m_impl;
};
}
diff --git a/src/util/regex/regex-top-matcher.cpp b/src/util/regex/regex-top-matcher.cpp
index dd2ac03..e2317c7 100644
--- a/src/util/regex/regex-top-matcher.cpp
+++ b/src/util/regex/regex-top-matcher.cpp
@@ -48,14 +48,16 @@
if ('^' != expr[0]) {
m_secondaryMatcher = make_shared<RegexPatternListMatcher>(
"<.*>*" + expr,
- cref(m_secondaryBackrefManager));
+ m_secondaryBackrefManager);
}
else {
expr = expr.substr(1, expr.size() - 1);
}
- m_primaryMatcher = make_shared<RegexPatternListMatcher>(func_lib::cref(expr),
- func_lib::cref(m_primaryBackrefManager));
+ // On OSX 10.9, boost, and C++03 the following doesn't work without ndn::
+ // because the argument-dependent lookup prefers STL to boost
+ m_primaryMatcher = ndn::make_shared<RegexPatternListMatcher>(expr,
+ m_primaryBackrefManager);
}
bool
@@ -199,8 +201,9 @@
if (hasAnchor)
regexStr.append("$");
- // OSX 10.9 has problems with just cref
- return make_shared<RegexTopMatcher>(func_lib::cref(regexStr));
+ // On OSX 10.9, boost, and C++03 the following doesn't work without ndn::
+ // because the argument-dependent lookup prefers STL to boost
+ return ndn::make_shared<RegexTopMatcher>(regexStr);
}
std::string
diff --git a/src/util/scheduler.cpp b/src/util/scheduler.cpp
index 4e74d10..21106e0 100644
--- a/src/util/scheduler.cpp
+++ b/src/util/scheduler.cpp
@@ -102,7 +102,10 @@
const Event& event)
{
EventQueue::iterator i = m_events.insert(EventInfo(after, period, event));
- i->m_eventId = make_shared<EventIdImpl>(func_lib::cref(i));
+
+ // On OSX 10.9, boost, and C++03 the following doesn't work without ndn::
+ // because the argument-dependent lookup prefers STL to boost
+ i->m_eventId = ndn::make_shared<EventIdImpl>(i);
if (!m_isEventExecuting)
{
diff --git a/tools/ndnsec-sig-verify.hpp b/tools/ndnsec-sig-verify.hpp
index 446d8a4..055ea8c 100644
--- a/tools/ndnsec-sig-verify.hpp
+++ b/tools/ndnsec-sig-verify.hpp
@@ -30,7 +30,7 @@
// Data data;
// data.wireDecode(Block(make_shared<Buffer>(decoded.begin(), decoded.end())));
-// shared_ptr<IdentityCertificate> identityCertificate = make_shared<IdentityCertificate>(boost::cref(data));
+// shared_ptr<IdentityCertificate> identityCertificate = make_shared<IdentityCertificate>(data);
// return identityCertificate;
// }
@@ -46,14 +46,14 @@
// // new CryptoPP::Base64Decoder(new CryptoPP::StringSink(decoded)));
// // Data data;
-// // data.wireDecode(ptr_lib::make_shared<Buffer>(decoded.c_str(), decoded.size()));
+// // data.wireDecode(make_shared<Buffer>(decoded.c_str(), decoded.size()));
// // return PolicyManager::verifySignature(data, certificate->getPublicKeyInfo());
// // }
// // else
// // {
// // // The first two bytes indicates the boundary of the of the signed data and signature.
// // // for example, if the size of the signed data is 300, then the boundary should be 300, so the first two bytes should be: 0x01 0x2C
-// // ptr_lib::shared_ptr<Blob> input = ptr_lib::shared_ptr<Blob>(new Blob ((istreambuf_iterator<char>(cin)), istreambuf_iterator<char>()));
+// // shared_ptr<Blob> input = shared_ptr<Blob>(new Blob ((istreambuf_iterator<char>(cin)), istreambuf_iterator<char>()));
// // size_t size = input->at(0);
// // size = ((size << 8) + input->at(1));