Motr  M0
graph.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 
25 #ifndef __MOTR_GRAPH_GRAPH_H__
26 #define __MOTR_GRAPH_GRAPH_H__
27 
28 #include "fid/fid.h"
29 #include "fid/fid_xc.h"
30 #include "lib/cookie.h"
31 #include "lib/cookie_xc.h"
32 #include "xcode/xcode_attr.h"
33 
40 struct m0_graph;
41 struct m0_garc;
42 struct m0_gvertice;
43 
44 struct m0_gvertice_type;
45 struct m0_garc_type;
46 
47 struct m0_gvertice_header;
48 struct m0_garc_src;
49 struct m0_garc_dst;
50 
51 struct m0_garc {
52  struct m0_fid as_fid;
55 } M0_XCA_RECORD;
56 
57 struct m0_gvertice {
58  uint64_t vh_typeid;
59  struct m0_fid vh_fid;
60  uint64_t vh_gen;
62  struct m0_garc vh_next;
63  struct m0_garc vh_prev;
64 } M0_XCA_RECORD;
65 
66 struct m0_graph {
68 } M0_XCA_RECORD;
69 
71 
73  uint64_t vt_id;
74  const char *vt_name;
75  const struct m0_xcode_type *vt_xt;
76  uint32_t vt_arc_nr;
78 };
79 
80 struct m0_garc_type {
81  const char *at_name;
82  size_t at_field;
83  const struct m0_garc_type *at_reverse;
84 };
85 
86 bool m0_gvertice_invariant(const struct m0_gvertice *vertice);
87 bool m0_graph_invariant(const struct m0_graph *graph);
88 bool m0_gvertice_type_invariant(const struct m0_gvertice_type *vt);
89 bool m0_garc_type_invariant(const struct m0_gvertice_type *vt,
90  const struct m0_garc_type *atype);
91 
92 void m0_gvertice_link(struct m0_gvertice *src, struct m0_gvertice *dst,
93  const struct m0_garc_type *atype);
94 void m0_gvertice_unlink(struct m0_gvertice *src, struct m0_gvertice *dst,
95  const struct m0_garc_type *atype);
96 bool m0_gvertice_linked(const struct m0_gvertice *src,
97  const struct m0_gvertice *dst,
98  const struct m0_garc_type *atype);
99 bool m0_gvertice_is_set(const struct m0_gvertice *vertice,
100  const struct m0_garc_type *atype);
101 
102 void m0_gvertice_init(struct m0_graph *g, struct m0_gvertice *vertice,
103  const struct m0_gvertice_type *vt,
104  const struct m0_fid *fid);
105 void m0_gvertice_fini(struct m0_graph *g, struct m0_gvertice *vertice);
106 
107 struct m0_gvertice *m0_garc_try(const struct m0_gvertice *vertice,
108  const struct m0_garc_type *atype);
109 
110 int m0_garc_follow(const struct m0_gvertice *vertice,
111  const struct m0_garc_type *atype, ...);
112 
114 void m0_garc_type_register(const struct m0_garc_type *atype);
115 void m0_garc_type_pair_register(struct m0_garc_type *direct,
116  struct m0_garc_type *reverse);
117 
118 void m0_garc_type_add(struct m0_gvertice_type *vt,
119  const struct m0_garc_type *atype);
120 M0_INTERNAL int m0_graph_mod_init(void);
121 M0_INTERNAL void m0_graph_mod_fini(void);
122 
124 #endif /* __MOTR_GRAPH_GRAPH_H__ */
125 
126 /*
127  * Local variables:
128  * c-indentation-style: "K&R"
129  * c-basic-offset: 8
130  * tab-width: 8
131  * fill-column: 80
132  * scroll-step: 1
133  * End:
134  */
135 /*
136  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
137  */
const char * vt_name
Definition: graph.h:74
static struct m0_bufvec dst
Definition: xform.c:61
uint64_t vh_gen
Definition: graph.h:60
void m0_gvertice_fini(struct m0_graph *g, struct m0_gvertice *vertice)
Definition: graph.c:143
Definition: graph.h:51
M0_INTERNAL void m0_graph_mod_fini(void)
Definition: graph.c:316
void m0_gvertice_type_register(struct m0_gvertice_type *vt)
Definition: graph.c:193
size_t at_field
Definition: graph.h:82
const struct m0_garc_type * vt_arc[M0_GRAPH_ARC_PER_NODE_MAX]
Definition: graph.h:77
struct m0_fid fid
Definition: di.c:46
bool m0_gvertice_is_set(const struct m0_gvertice *vertice, const struct m0_garc_type *atype)
Definition: graph.c:125
bool m0_gvertice_type_invariant(const struct m0_gvertice_type *vt)
Definition: graph.c:161
uint64_t vt_id
Definition: graph.h:73
struct m0_garc vh_next
Definition: graph.h:62
M0_INTERNAL int m0_graph_mod_init(void)
Definition: graph.c:308
struct m0_gvertice g_anchor
Definition: graph.h:67
uint64_t vh_typeid
Definition: graph.h:58
void m0_gvertice_init(struct m0_graph *g, struct m0_gvertice *vertice, const struct m0_gvertice_type *vt, const struct m0_fid *fid)
Definition: graph.c:134
uint32_t vt_arc_nr
Definition: graph.h:76
bool m0_garc_type_invariant(const struct m0_gvertice_type *vt, const struct m0_garc_type *atype)
Definition: graph.c:171
struct m0_fid as_fid
Definition: graph.h:52
const struct m0_xcode_type * vt_xt
Definition: graph.h:75
void m0_gvertice_unlink(struct m0_gvertice *src, struct m0_gvertice *dst, const struct m0_garc_type *atype)
Definition: graph.c:90
bool m0_gvertice_linked(const struct m0_gvertice *src, const struct m0_gvertice *dst, const struct m0_garc_type *atype)
Definition: graph.c:113
struct m0_cookie vh_cookie
Definition: graph.h:61
void m0_garc_type_register(const struct m0_garc_type *atype)
Definition: graph.c:206
struct m0_fid vh_fid
Definition: graph.h:59
struct m0_gvertice * m0_garc_try(const struct m0_gvertice *vertice, const struct m0_garc_type *atype)
Definition: graph.c:186
struct m0_cookie as_local
Definition: graph.h:53
void m0_gvertice_link(struct m0_gvertice *src, struct m0_gvertice *dst, const struct m0_garc_type *atype)
Definition: graph.c:60
struct m0_garc vh_prev
Definition: graph.h:63
struct m0_cookie as_remote
Definition: graph.h:54
const char * at_name
Definition: graph.h:81
Definition: fid.h:38
void m0_garc_type_pair_register(struct m0_garc_type *direct, struct m0_garc_type *reverse)
Definition: graph.c:210
const struct m0_garc_type * at_reverse
Definition: graph.h:83
void m0_garc_type_add(struct m0_gvertice_type *vt, const struct m0_garc_type *atype)
Definition: graph.c:217
bool m0_gvertice_invariant(const struct m0_gvertice *vertice)
Definition: graph.c:152
static struct gen g[MAX_GEN]
Definition: beck.c:521
struct m0_pdclust_src_addr src
Definition: fd.c:108
bool m0_graph_invariant(const struct m0_graph *graph)
Definition: graph.c:181
int m0_garc_follow(const struct m0_gvertice *vertice, const struct m0_garc_type *atype,...)
Definition: graph.c:232
Definition: graph.h:66