update NOTICE
[nit.git] / lib / serialization.nit
index 1ed25a8..8a1d1ee 100644 (file)
@@ -15,7 +15,9 @@
 # limitations under the License.
 
 # Offers services to serialize a Nit objects to different persistent formats
-module serialization
+module serialization is
+       new_annotation auto_serializable
+end
 
 # Abstract serialization service to be sub-classed by specialized services.
 interface Serializer
@@ -49,6 +51,28 @@ interface Serializer
        fun warn(msg: String) do print "Serialization warning: {msg}"
 end
 
+# Abstract deserialization service
+#
+# After initialization of one of its sub-classes, call `deserialize`
+interface Deserializer
+       # Main method of this class, returns a Nit object
+       fun deserialize: nullable Object is abstract
+
+       # Internal method to be implemented by sub-classes
+       fun deserialize_attribute(name: String): nullable Object is abstract
+
+       # Internal method called by objects in creation,
+       # to be implemented by sub-classes
+       fun notify_of_creation(new_object: Object) is abstract
+
+       # Mainly generated method to return the next instance of the givent
+       # class by name
+       fun deserialize_class(class_name: String): Object do
+               print "Error: doesn't know how to deserialize class \"{class_name}\""
+               abort
+       end
+end
+
 # Instances of this class can be passed to `Serializer::serialize`
 interface Serializable
        # Full or true serialization