Defining it in protocol.h may cause multiple definitions to appear across
the program and there are cases where they don't get collapsed to one.
DLLs on Windows are one such case. The _impl header is to be included in
files that add packet definitions to a protocol and nowhere else.
#include <cstring>
#include "communicator.h"
+#include "protocol_impl.h"
#include "streamsocket.h"
using namespace std;
#include <msp/strings/format.h>
#include <msp/strings/lexicalcast.h>
#include "protocol.h"
+#include "protocol_impl.h"
using namespace std;
}
-template<typename P>
-unsigned Protocol::PacketTypeDef<P>::class_id = 0;
-
template<typename P>
Protocol::PacketTypeDef<P>::PacketTypeDef(unsigned i):
PacketDefBase(i),
--- /dev/null
+#ifndef MSP_NET_PROTOCOL_IMPL_H_
+#define MSP_NET_PROTOCOL_IMPL_H_
+
+#include "protocol.h"
+
+namespace Msp {
+namespace Net {
+
+template<typename P>
+unsigned Protocol::PacketTypeDef<P>::class_id = 0;
+
+} // namespace Net
+} // namespace Msp
+
+#endif