5 #ifndef UPB_MSGFACTORY_H_
6 #define UPB_MSGFACTORY_H_
8 /** upb_msgfactory ************************************************************/
10 struct upb_msgfactory;
11 typedef struct upb_msgfactory upb_msgfactory;
17 /* A upb_msgfactory contains a cache of upb_msglayout, upb_handlers, and
18 * upb_visitorplan objects. These are the objects necessary to represent,
19 * populate, and and visit upb_msg objects.
21 * These caches are all populated by upb_msgdef, and lazily created on demand.
24 /* Creates and destroys a msgfactory, respectively. The messages for this
25 * msgfactory must come from |symtab| (which should outlive the msgfactory). */
26 upb_msgfactory *upb_msgfactory_new(const upb_symtab *symtab);
27 void upb_msgfactory_free(upb_msgfactory *f);
29 const upb_symtab *upb_msgfactory_symtab(const upb_msgfactory *f);
31 /* The functions to get cached objects, lazily creating them on demand. These
34 * - m is in upb_msgfactory_symtab(f)
35 * - upb_msgdef_mapentry(m) == false (since map messages can't have layouts).
37 * The returned objects will live for as long as the msgfactory does.
39 * TODO(haberman): consider making this thread-safe and take a const
41 const upb_msglayout *upb_msgfactory_getlayout(upb_msgfactory *f,
48 #endif /* UPB_MSGFACTORY_H_ */