As it stands right now this object has some funkiness that makes there
tricky I think. It might be worth leaving it alone actually and deprecating
it for something different.
class MyUnmodifiedClass;
class MyUnmodifiedClassPdxSerializer : PdxSerializer<MyUnmodifiedClass> {
using PdxSerializer::PdxSerializer;
MyUnmodifiedClassPdxSerializer* createDeserializable() const override {
return MyUnmodifiedClass();
}
}
using MyPdxType = PdxWrapper<MyUnmodifiedClass,
MyUnmodifiedClassPdxSerializer>;
void func() {
...
serializationRegistry->addPdxType(MyPdxType::createDeserializable);
auto value = std::dynamic_pointer_cast<MyPdxType>(region.get("key"));
auto /*MyUnmodifiedClass*/ unwrappedValue = value->getValue();
...
}
Probably even something nicer than this even?
That said, is the wrapper serving anything, how about this?
class MyUnmodifiedClassPdxSerializer : PdxSerializer<MyUnmodifiedClass> {
using PdxSerializer::PdxSerializer;
const std::string& getClassName() const override {
constexp std::string("MyUnmodifiedClass");
}
std::shared_ptr<MyUnmodifiedClass> fromData(PdxReader& reader) const
override {
auto a = reader.readInt("a");
auto b = reader.readDouble("b");
return std::make_shared<MyUnmodifiedClass>(a, b); // Takes care of
deleter issues.
}
void toData(PdxWriter& writer, const MyUnmodifiedClass& obj) const
override {
writer.writeInt("a", obj.getA());
writer.writeDouble("b", obj.getB());
}
}
serializationRegistry->addPdxSerializer(MyUnmodifiedClassPdxSerializer());
-Jake
On Thu, Sep 21, 2017 at 12:06 PM David Kimura <[email protected]> wrote:
> I briefly scanned some docs, but I'm still not sure I follow why this needs
> to be in our domain. It says PdxWrapper is "for domain objects that you
> cannot or do not want to modify".
>
> Why can't the application create an opaque wrapper around the object that
> cannot be modified and register that wrapper with the serialization
> registry - just like other serializable classes without us being the wiser
> that it is a wrapper?
>
> Thanks,
> David
>
> On Thu, Sep 21, 2017 at 11:49 AM, Jacob Barrett <[email protected]>
> wrote:
>
> > It may be work looking into the documentation a little to understand the
> > purpose of the PdxWrapper.
> >
> > On Thu, Sep 21, 2017 at 11:37 AM David Kimura <[email protected]>
> wrote:
> >
> > > Is using PdxWrapper any different than if user added their type into
> the
> > > serialization registry? If not, then do we really want to provide 2
> ways
> > > to do the same thing?
> > >
> > > Thanks,
> > > David
> > >
> > > On Thu, Sep 21, 2017 at 10:24 AM, Michael William Dodge <
> > [email protected]
> > > >
> > > wrote:
> > >
> > > > +1 for type safety
> > > >
> > > > Sarge
> > > >
> > > > > On 21 Sep, 2017, at 10:21, Mark Hanson <[email protected]> wrote:
> > > > >
> > > > > Here is a link to my branch in my fork that has the changes on it.
> > > > >
> > > > >
> https://github.com/mhansonp/geode-native/tree/wip/templatePdxWrapper
> > > > >
> > > > > Thanks,
> > > > > Mark
> > > > >
> > > > > On Thu, Sep 21, 2017 at 10:19 AM, Mark Hanson <[email protected]>
> > > > wrote:
> > > > >
> > > > >> Hi All,
> > > > >>
> > > > >> In reviewing the PdxWrapper class it, it seemed like it would be a
> > > good
> > > > >> move to make this a template class. This will allow better type
> > > checking
> > > > >> anytime we use it.
> > > > >>
> > > > >> An example of what is being planned is to change from
> > > > >>
> > > > >> MyClass object;
> > > > >> PdxWrapper((void *) object,...)
> > > > >> to PdxWrapper<MyClass>(object, ....)
> > > > >>
> > > > >> I have a chunk of code moved over that seems to show it is
> possible,
> > > > >> though there are some bugs that need to be addressed, so it is
> not a
> > > > done
> > > > >> deal.
> > > > >>
> > > > >> What do people think?
> > > > >>
> > > > >> Thanks,
> > > > >> Mark
> > > > >>
> > > >
> > > >
> > >
> >
>