face+util: Add protected Face::getTransport method and simplify DummyClientFace implementation
Change-Id: I42e7e5705f27b6823ed18107b374c9841d2a7500
Refs: #3146
diff --git a/src/util/dummy-client-face.hpp b/src/util/dummy-client-face.hpp
index 8d47a75..b5ec7d7 100644
--- a/src/util/dummy-client-face.hpp
+++ b/src/util/dummy-client-face.hpp
@@ -26,6 +26,8 @@
#include "signal.hpp"
#include "../lp/packet.hpp"
+#define NDN_UTIL_DUMMY_FACE_KEEP_DEPRECATED
+
namespace ndn {
namespace util {
@@ -48,6 +50,16 @@
bool enableRegistrationReply;
};
+ /**
+ * @brief Create a dummy face with internal IO service
+ */
+ DummyClientFace(const Options& options = DummyClientFace::DEFAULT_OPTIONS);
+
+ /**
+ * @brief Create a dummy face with the provided IO service
+ */
+ DummyClientFace(boost::asio::io_service& ioService, const Options& options = DummyClientFace::DEFAULT_OPTIONS);
+
/** \brief cause the Face to receive a packet
* \tparam Packet either Interest or Data
*/
@@ -58,22 +70,9 @@
private: // constructors
class Transport;
- // constructors are private; use makeDummyClientFace to create DummyClientFace
-
- DummyClientFace(const Options& options, shared_ptr<Transport> transport);
-
- DummyClientFace(const Options& options, shared_ptr<Transport> transport,
- boost::asio::io_service& ioService);
-
void
construct(const Options& options);
- friend shared_ptr<DummyClientFace>
- makeDummyClientFace(const DummyClientFace::Options& options);
-
- friend shared_ptr<DummyClientFace>
- makeDummyClientFace(boost::asio::io_service& ioService, const DummyClientFace::Options& options);
-
private:
void
enablePacketLogging();
@@ -103,7 +102,11 @@
* User of this class is responsible for cleaning up the container, if necessary.
* After .put, .processEvents must be called before the Data would show up here.
*/
- std::vector<Data> sentDatas;
+ std::vector<Data> sentData;
+
+#ifdef NDN_UTIL_DUMMY_FACE_KEEP_DEPRECATED
+ std::vector<Data>& sentDatas; ///< deprecated alias to sentData
+#endif // NDN_UTIL_DUMMY_FACE_KEEP_DEPRECATED
/** \brief NACKs sent out of this DummyClientFace
*
@@ -130,21 +133,28 @@
* After .put, .processEvents must be called before this signal would be emitted.
*/
Signal<DummyClientFace, lp::Nack> onSendNack;
-
-private:
- shared_ptr<Transport> m_transport;
};
template<>
void
DummyClientFace::receive(const lp::Nack& nack);
+#ifdef NDN_UTIL_DUMMY_FACE_KEEP_DEPRECATED
+/**
+ * @brief Create a dummy face with internal IO service
+ * @deprecated Use the DummyFace constructor directly
+ */
shared_ptr<DummyClientFace>
makeDummyClientFace(const DummyClientFace::Options& options = DummyClientFace::DEFAULT_OPTIONS);
+/**
+ * @brief Create a dummy face with the provided IO service
+ * @deprecated Use the DummyFace constructor directly
+ */
shared_ptr<DummyClientFace>
makeDummyClientFace(boost::asio::io_service& ioService,
const DummyClientFace::Options& options = DummyClientFace::DEFAULT_OPTIONS);
+#endif // NDN_UTIL_DUMMY_FACE_KEEP_DEPRECATED
} // namespace util
} // namespace ndn