#pragma once #include "presents/Streamer.h" #include "presents/Streamable.h" template class StreamableStreamer : public Streamer { public: Shared createObject (ObjectInputStream& in) { Shared streamable(new T()); streamable->readObject(in); return streamable; } void writeObject (const Shared& object, ObjectOutputStream& out) { ((Shared&)object)->writeObject(out); } }; #define DECLARE_STREAMABLE() \ static const utf8& javaName (); \ static void registerWithPresents () { javaName(); } \ virtual const utf8& getJavaClassName () const { return javaName(); } #define DEFINE_STREAMABLE(nameString, StreamableClass) \ static const utf8& gStreamableClassRegistration = StreamableClass::javaName(); \ const utf8& StreamableClass::javaName () {\ static const utf8 JAVA_NAME = nameString; \ static bool gRegistered = false; \ if (!gRegistered) { registerStreamer(JAVA_NAME, new StreamableStreamer()); gRegistered = true; } \ return JAVA_NAME; }