Debian Codegraph @

docs/source/overview_software_architecture.rst

raw
1 .. _software-architecture:
2
3 Software Architecture
4 =====================
5
6 The main goal of HDMF is to enable users and developers to efficiently interact with the
7 hierarchical object data. The following figures provide an overview of the high-level architecture of
8 HDMF and functionality of the various components.
9
10 .. _fig-software-architecture:
11
12 .. figure:: figures/software_architecture.*
13 :width: 100%
14 :alt: HDMF Software Architecture
15
16 Overview of the high-level software architecture of HDMF (click to enlarge).
17
18
19 .. _fig-software-architecture-purpose:
20
21 .. figure:: figures/software_architecture_design_choices.*
22 :width: 100%
23 :alt: HDMF Software Architecture Functions
24
25 We choose a modular design for HDMF to enable flexibility and separate the
26 various levels of standardizing hierarchical data (click to enlarge).
27
28 .. raw:: latex
29
30 \clearpage \newpage
31
32
33 Main Concepts
34 -------------
35
36
37 .. _fig-software-architecture-concepts:
38
39 .. figure:: figures/software_architecture_concepts.*
40 :width: 100%
41 :alt: HDMF Software Architecture Concepts
42
43 Overview of the main concepts/classes in HDMF and their location in the overall software architecture (click to enlarge).
44
45 Container
46 ^^^^^^^^^
47
48 * In memory objects
49 * Interface for (most) applications
50 * Similar to a table row
51 * HDMF does not provide these. They are left for standards developers to define
52 how users interact with data.
53 * There are two Container base classes:
54
55 * :py:class:`~hdmf.container.Container` - represents a collection of objects
56 * :py:class:`~hdmf.container.Data` - represents data
57
58 * **Main Module:** :py:class:`hdmf.container`
59
60 Builder
61 ^^^^^^^
62
63 * Intermediary objects for I/O
64 * Interface for I/O
65 * Backend readers and writers must return and accept these
66 * There are different kinds of builders for different base types:
67
68 * :py:class:`~hdmf.build.builders.GroupBuilder` - represents a collection of objects
69 * :py:class:`~hdmf.build.builders.DatasetBuilder` - represents data
70 * :py:class:`~hdmf.build.builders.LinkBuilder` - represents soft-links
71 * :py:class:`~hdmf.build.builders.RegionBuilder` - represents a slice into data (Subclass of :py:class:`~hdmf.build.builders.DatasetBuilder`)
72
73 * **Main Module:** :py:class:`hdmf.build.builders`
74
75 Spec
76 ^^^^
77
78 * Interact with format specifications
79 * Data structures to specify data types and what said types consist of
80 * Python representation for YAML specifications
81 * Interface for writing extensions or custom specification
82 * There are several main specification classes:
83
84 * :py:class:`~hdmf.spec.spec.AttributeSpec` - specification for metadata
85 * :py:class:`~hdmf.spec.spec.GroupSpec` - specification for a collection of
86 objects (i.e. subgroups, datasets, link)
87 * :py:class:`~hdmf.spec.spec.DatasetSpec` - specification for dataset (like
88 and n-dimensional array). Specifies data type, dimensions, etc.
89 * :py:class:`~hdmf.spec.spec.LinkSpec` - specification for link (like a POSIX
90 soft link)
91 * :py:class:`~hdmf.spec.spec.RefSpec` - specification for references
92 (References are like links, but stored as data)
93 * :py:class:`~hdmf.spec.spec.DtypeSpec` - specification for compound data
94 types. Used to build complex data type specification, e.g., to define
95 tables (used only in :py:class:`~hdmf.spec.spec.DatasetSpec` and
96 correspondingly :py:class:`~hdmf.spec.spec.DatasetSpec`)
97
98 * **Main Modules:** :py:class:`hdmf.spec`
99
100 .. note::
101
102 A ``data_type`` defines a reusable type in a format specification that can be
103 referenced and used elsewhere in other specifications. The specification of
104 the standard is basically a collection of ``data_types``,
105
106 * ``data_type_inc`` is used to include an existing type and
107 * ``data_type_def`` is used to define a new type
108
109 i.e, if both keys are defined then we create a new type that uses/inherits
110 an existing type as a base.
111
112 ObjectMapper
113 ^^^^^^^^^^^^
114
115 * Maintains the mapping between `Container`_ attributes and `Spec`_ components
116 * Provides a way of converting between `Container`_ and `Builder`_, while
117 leaving standards developers with the flexibility of presenting data
118 to users in a user-friendly manner, while storing data in an efficient manner
119 * ObjectMappers are constructed using a `Spec`_
120 * Ideally, one ObjectMapper for each data type
121 * Things an ObjectMapper should do:
122
123 * Given a `Builder`_, return a Container representation
124 * Given a `Container`_, return a Builder representation
125
126 * **Main Module:** :py:class:`hdmf.build.objectmapper`
127
128 .. _fig-software-architecture-mainconcepts:
129
130 .. figure:: figures/software_architecture_mainconcepts.*
131 :width: 100%
132 :alt: HDMF Software Architecture Main Concepts
133
134 Relationship between `Container`_, `Builder`_, `ObjectMapper`_, and `Spec`_
135
136
137 Additional Concepts
138 -------------------
139
140 Namespace, NamespaceCatalog, NamespaceBuilder
141 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
142
143 * **Namespace**
144
145 * A namespace for specifications
146 * Necessary for making standards extensions and standard core specification
147 * Contains basic info about who created extensions
148
149 * :py:class:`~hdmf.spec.namespace.NamespaceCatalog` -- A class for managing namespaces
150 * :py:class:`~hdmf.spec.write.NamespaceBuilder` -- A utility for building extensions
151
152
153 TypeMap
154 ^^^^^^^
155
156 * Map between data types, Container classes (i.e. a Python class object) and corresponding ObjectMapper classes
157 * Constructed from a NamespaceCatalog
158 * Things a TypeMap does:
159
160 * Given a data_type, return the associated Container class
161 * Given a Container class, return the associated ObjectMapper
162
163 * HDMF has one of these classes:
164
165 * the base class (i.e. :py:class:`~hdmf.build.manager.TypeMap`)
166
167 * TypeMaps can be merged, which is useful when combining extensions
168
169
170 BuildManager
171 ^^^^^^^^^^^^
172
173 * Responsible for `memoizing <https://en.wikipedia.org/wiki/Memoization>`_ `Builder`_ and `Container`_
174 * Constructed from a `TypeMap`_
175 * HDMF only has one of these: :py:class:`hdmf.build.manager.BuildManager`
176
177 .. _fig-software-architecture-buildmanager:
178
179 .. figure:: figures/software_architecture_buildmanager.*
180 :width: 100%
181 :alt: HDMF Software Architecture BuildManager and TypeMap
182
183 Overview of `BuildManager`_ (and `TypeMap`_) (click to enlarge).
184
185
186 HDMFIO
187 ^^^^^^
188
189 * Abstract base class for I/O
190 * :py:class:`HDMFIO <hdmf.backends.io.HDMFIO>` has two key abstract methods:
191
192 * :py:meth:`~hdmf.backends.io.HDMFIO.write_builder` – given a builder, write data to storage format
193 * :py:meth:`~hdmf.backends.io.HDMFIO.read_builder` – given a handle to storage format, return builder representation
194 * Others: :py:meth:`~hdmf.backends.io.HDMFIO.open` and :py:meth:`~hdmf.backends.io.HDMFIO.close`
195
196 * Constructed with a `BuildManager`_
197 * Extend this for creating a new I/O backend
198 * HDMF has one concrete form of this:
199
200 * :py:class:`~hdmf.backends.hdf5.h5tools.HDF5IO` - reading and writing HDF5
201
202
203 .. _fig-software-architecture-hdmfio:
204
205 .. figure:: figures/software_architecture_hdmfio.*
206 :width: 100%
207 :alt: HDMF Software Architecture FormIO
208
209 Overview of `HDMFIO`_ (click to enlarge).