lms-org / lms

Lightweight Modular System
Apache License 2.0
10 stars 4 forks source link

Serialization - LMStype #100

Open Phibedy opened 8 years ago

Phibedy commented 8 years ago

Check if the dataChannel has a method called

LMSType getLMSType()
LMSType has an id, name,...

We could create a macrp LMSTYPE(ClassName,namespace) which sets the classname as the name and the hash(classname,namespace) as id.

Furthermore we could introduce an init() function to libraries. This init function would provide all classes with it's LMSTypes. It would be needed for deserialization (LMS GUI) + it would enable us to have polymorphic datachannels

Phibedy commented 8 years ago

We could add

extern "C" getLMSTypes(){
vector vec;
vec.add(LMSTYPE(<Type>));
return vec;

to each library. (LMSTYPE(<Type>) creates a struct with a ID and a function to get the DataChannel object. Therefore we can use the DataChannel functions to check if it is serializable/castable too, etc. LMS could offer a feature to map the LMSTYPE-structs to their keys. As the id might be namespace1_namespace2_classname, we could set the id in the datachannel for each module and the datachannel would match the current one even if the type is polymorphic.

If one LMS instance wants data from another, we could send the ID, therefore we could create and use an instance of the object "without knowing" the type. The libraries have to be still available and loaded so the LMSTYPES are set. An service could do it easily. The libraries could be copied in the config-directory.

If the user now uses protobuffers #106, version checking would be enabled automatically, but as our datachannels should still be able to contain functions, protobuffers aren't the solution. As most of the time, the proto buffer sould be used as a container inside a class and the class still has to be available for the receiver.