Jeff Thompson | 47eecfc | 2013-07-07 22:56:46 -0700 | [diff] [blame] | 1 | /** |
| 2 | * @author: Jeff Thompson |
| 3 | * See COPYING for copyright and distribution information. |
Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <stdexcept> |
Jeff Thompson | 5341219 | 2013-08-06 13:35:50 -0700 | [diff] [blame^] | 7 | #include "wire-format.hpp" |
Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 8 | |
| 9 | using namespace std; |
| 10 | |
| 11 | namespace ndn { |
Jeff Thompson | fa181ac | 2013-08-02 19:00:51 -0700 | [diff] [blame] | 12 | |
Jeff Thompson | 1a1312d | 2013-08-05 19:08:35 -0700 | [diff] [blame] | 13 | static bool gotInitialDefaultWireFormat = false; |
Jeff Thompson | fa181ac | 2013-08-02 19:00:51 -0700 | [diff] [blame] | 14 | |
Jeff Thompson | 535f21a | 2013-08-05 18:25:46 -0700 | [diff] [blame] | 15 | WireFormat *WireFormat::defaultWireFormat_ = 0; |
| 16 | |
| 17 | WireFormat *WireFormat::getDefaultWireFormat() |
| 18 | { |
Jeff Thompson | 1a1312d | 2013-08-05 19:08:35 -0700 | [diff] [blame] | 19 | if (!defaultWireFormat_ && !gotInitialDefaultWireFormat) { |
Jeff Thompson | 535f21a | 2013-08-05 18:25:46 -0700 | [diff] [blame] | 20 | // There is no defaultWireFormat_ and we have not yet initialized initialDefaultWireFormat_, so initialize and use it. |
Jeff Thompson | 1a1312d | 2013-08-05 19:08:35 -0700 | [diff] [blame] | 21 | gotInitialDefaultWireFormat = true; |
| 22 | // NOTE: This allocates one object which we never free for the life of the application. |
| 23 | defaultWireFormat_ = newInitialDefaultWireFormat(); |
Jeff Thompson | 535f21a | 2013-08-05 18:25:46 -0700 | [diff] [blame] | 24 | } |
| 25 | |
| 26 | return defaultWireFormat_; |
| 27 | } |
Jeff Thompson | fa181ac | 2013-08-02 19:00:51 -0700 | [diff] [blame] | 28 | |
Jeff Thompson | b0979fd | 2013-07-30 15:48:21 -0700 | [diff] [blame] | 29 | ptr_lib::shared_ptr<vector<unsigned char> > WireFormat::encodeInterest(const Interest &interest) |
Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 30 | { |
| 31 | throw logic_error("unimplemented"); |
| 32 | } |
Jeff Thompson | 4238071 | 2013-06-28 10:59:33 -0700 | [diff] [blame] | 33 | void WireFormat::decodeInterest(Interest &interest, const unsigned char *input, unsigned int inputLength) |
Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 34 | { |
| 35 | throw logic_error("unimplemented"); |
| 36 | } |
| 37 | |
Jeff Thompson | 56ec9e2 | 2013-08-02 11:34:07 -0700 | [diff] [blame] | 38 | ptr_lib::shared_ptr<vector<unsigned char> > WireFormat::encodeData(const Data &data) |
Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 39 | { |
| 40 | throw logic_error("unimplemented"); |
| 41 | } |
Jeff Thompson | 56ec9e2 | 2013-08-02 11:34:07 -0700 | [diff] [blame] | 42 | void WireFormat::decodeData(Data &data, const unsigned char *input, unsigned int inputLength) |
Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 43 | { |
| 44 | throw logic_error("unimplemented"); |
| 45 | } |
| 46 | |
Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 47 | } |