Motr  M0
module.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2014-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
23 #pragma once
24 #ifndef __MOTR_MODULE_MODULE_H__
25 #define __MOTR_MODULE_MODULE_H__
26 
27 struct m0_module;
28 
106 enum {
110 };
111 
113 struct m0_modlev {
114  const char *ml_name;
119  int (*ml_enter)(struct m0_module *module);
121  void (*ml_leave)(struct m0_module *module);
122 };
123 
131 struct m0_moddep {
133  int md_src;
134  int md_dst;
135 };
136 
137 #define M0_MODDEP_INIT(other, src, dst) \
138  { .md_other = (other), .md_src = (src), .md_dst = (dst) }
139 
151 struct m0_module {
152  const char *m_name;
153  struct m0 *m_m0;
160  int m_cur;
167  const struct m0_modlev *m_level;
177  unsigned m_dep_nr;
180  unsigned m_inv_nr;
181 };
182 
186  const char *mt_name;
199  struct m0_module *(*mt_create)(struct m0 *instance);
200 };
201 
208 M0_INTERNAL int m0_module_init(struct m0_module *module, int level);
209 
211 M0_INTERNAL void m0_module_fini(struct m0_module *module, int level);
212 
214 M0_INTERNAL void m0_module_dep_add(struct m0_module *m0, int l0,
215  struct m0_module *m1, int l1);
216 
218 M0_INTERNAL void m0_module_setup(struct m0_module *module, const char *name,
219  const struct m0_modlev *level, int level_nr,
220  struct m0 *instance);
221 
223 #endif /* __MOTR_MODULE_MODULE_H__ */
224 
225 /*
226  * Local variables:
227  * c-indentation-style: "K&R"
228  * c-basic-offset: 8
229  * tab-width: 8
230  * fill-column: 80
231  * scroll-step: 1
232  * End:
233  */
234 /*
235  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
236  */
enum m0_trace_level level
Definition: trace.c:111
unsigned m_dep_nr
Definition: module.h:177
const char * ml_name
Definition: module.h:114
void(* ml_leave)(struct m0_module *module)
Definition: module.h:121
struct m0_moddep m_inv[M0_MODDEP_MAX]
Definition: module.h:179
struct m0 * m_m0
Definition: module.h:153
const char * m_name
Definition: module.h:152
unsigned m_inv_nr
Definition: module.h:180
const char * name
Definition: trace.c:110
struct m0_module * md_other
Definition: module.h:132
int md_dst
Definition: module.h:134
unsigned m_level_nrefs[M0_MODLEV_MAX]
Definition: module.h:174
int(* ml_enter)(struct m0_module *module)
Definition: module.h:119
M0_INTERNAL void m0_module_setup(struct m0_module *module, const char *name, const struct m0_modlev *level, int level_nr, struct m0 *instance)
Definition: module.c:193
Definition: instance.h:80
int md_src
Definition: module.h:133
int m_level_nr
Definition: module.h:168
M0_INTERNAL void m0_module_dep_add(struct m0_module *m0, int l0, struct m0_module *m1, int l1)
Definition: module.c:168
int m_cur
Definition: module.h:160
const char * mt_name
Definition: module.h:186
static struct m0 instance
Definition: main.c:78
M0_INTERNAL void m0_module_fini(struct m0_module *module, int level)
Definition: module.c:142
const struct m0_modlev * m_level
Definition: module.h:167
struct m0_moddep m_dep[M0_MODDEP_MAX]
Definition: module.h:176
M0_INTERNAL int m0_module_init(struct m0_module *module, int level)
Definition: module.c:131