1
0
mirror of https://github.com/TREX-CoE/trexio.git synced 2024-11-03 20:54:07 +01:00

Move the polymorphism description

This commit is contained in:
q-posev 2022-05-18 14:56:46 +02:00
parent c6b628e583
commit bc89fdebb0
2 changed files with 7 additions and 16 deletions

View File

@ -137,7 +137,7 @@ __trexio_path__ = None
#+begin_src c :tangle trexio_private.h #+begin_src c :tangle trexio_private.h
#define MALLOC(T) (T*) malloc (sizeof(T)) #define MALLOC(T) (T*) malloc (sizeof(T))
#define CALLOC(N,T) (T*) calloc ( (N)+1 , sizeof(T) ) #define CALLOC(N,T) (T*) calloc ( (N)+1 , sizeof(T) )
#+end_src #+end_src
When a pointer is freed, it should be set to ~NULL~. When a pointer is freed, it should be set to ~NULL~.
@ -600,7 +600,7 @@ def string_of_error(return_code: int) -> str:
Then the corresponding back-end ~has/read/write~ functions has to be implemented. For example, see the commented Then the corresponding back-end ~has/read/write~ functions has to be implemented. For example, see the commented
lines that correspond to the ~TREXIO_JSON~ back end (not implemented yet). lines that correspond to the ~TREXIO_JSON~ back end (not implemented yet).
_Note_: It is important to increment the value of ~TREXIO_INVALID_BACK_END~ when a new back end is added. Otherwise, it will not be available. _Note_: It is important to increment the value of ~TREXIO_INVALID_BACK_END~ when a new back end is implemented. Otherwise, it will not be available.
*** C *** C
@ -852,20 +852,6 @@ class File:
pass pass
#+end_src #+end_src
** TODO (Remove) : Polymorphism of the file handle
Polymorphism of the ~trexio_t~ type is handled by ensuring that the
corresponding types for all back ends can be safely casted to
~trexio_t~. This is done by making the back-end structs start with
~struct trexio_s~:
#+begin_src c
struct trexio_back_end_s {
trexio_t parent ;
/* add below specific back-end data */
}
#+end_src
** File opening ** File opening
~trexio_open~ creates a new TREXIO file or opens the existing one. ~trexio_open~ creates a new TREXIO file or opens the existing one.

View File

@ -60,6 +60,11 @@
* Template for HDF5 structures * Template for HDF5 structures
Polymorphism of the ~trexio_t~ type is handled by ensuring that the
corresponding types for all back ends can be safely casted to
~trexio_t~. This is done by making the back-end structs start with
~trexio_t parent~ attribute:
#+begin_src c :tangle struct_hdf5.h #+begin_src c :tangle struct_hdf5.h
typedef struct trexio_hdf5_s { typedef struct trexio_hdf5_s {
trexio_t parent ; trexio_t parent ;