User Tools

Site Tools


dev-guide:embedded-file-object

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
dev-guide:embedded-file-object [2025/01/08 16:34] – created gaetandev-guide:embedded-file-object [2025/01/08 19:11] (current) gaetan
Line 1: Line 1:
-====== ESO ARE THE BEST ======+====== Custom object persistence ====== 
 + 
 +GroIMP require Nodes, Node's attributes, and SCOs to be manageable by the persistence manager, to process the save/ load/ query operations. 
 + 
 +GroIMP define its own [[:groimp-platform:persistence|persistence management]]. To be managed by the GroIMP persistence management, an object need to implements either [[https://javadoc.grogra.de/graph/de/grogra/persistence/PersistenceCapable.html|PersistenceCapable]] (GroIMP interface), or [[https://docs.oracle.com/javase/8/docs/api/java/io/Serializable.html|Serializable]] (java interface). 
 +  
 +Usually the persistence is handled in memory (except when the project is saved), but GroIMP provides a way to integrate it with file persistence (the object is written/loaded from the file). This rely on EmbeddedSharedObject and EmbeddedFileObject. 
 + 
 +===== Embedded objects =====  
 + 
 +In GroIMP embedded objects are objects whose persistence is pushed in a file.  
 + 
 +EmbeddedSharedObject (ESO) is a class, thus the object needs to extends it.  
 +The ESO create on the fly and manage an EmbeddedFileObject (EFO).  
 + 
 +The object that extends ESO need to implements the following methods: 
 +  * ''public MimeType getMimeType()'': to provide the mimetype to use when writing and loading the object (see GroIMP [[:groimp-platform:input-and-output-in-groimp:mimetype|mimetype]]). 
 +  * ''public String getExtension()'': to provide the file extension (can be an empty string. File extensions are used to make it easier read files but are usually not required). 
 +  * ''public String getResourceDirectoryName()'': Name of the directory in which the file will be stored when the project is saved. 
 +  * ''public String getObjectType()'': java name of the object type (e.g. MyObject.class.getName()). 
 +  * ''public boolean hasContent()'': custom way to check if the object actually needs to be disposed. Can be set to true if it is always the case. 
 + 
 + 
 +Check [[:tutorials:create-parameternode-eso|this tutorial]] for an example. 
 + 
dev-guide/embedded-file-object.1736350457.txt.gz · Last modified: 2025/01/08 16:34 by gaetan