Free Electron
CatalogReaderYaml.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __yaml_CatalogReaderYaml_h__
8 #define __yaml_CatalogReaderYaml_h__
9 
10 namespace fe
11 {
12 namespace ext
13 {
14 
15 /**************************************************************************//**
16  @brief load catalog from yaml file
17 
18  @ingroup yaml
19 
20 @code
21 # Examples
22 
23 # simple import (one liner)
24 - import: model/biplane.yaml
25 
26 # simple import list
27 - import:
28  - model/biplane.yaml
29  - model/triplane.yaml
30 
31 # conditional import of files, forcing variable values in imported files
32 - import:
33  files:
34  - model/high_wing.yaml
35  - model/low_wing.yaml
36  only:
37  variables:
38  - $ADD_MONOPLANES != 0
39  variables:
40  ENGINE_COUNT: 2
41 
42 # import variable values (child values will replace local values)
43 - import:
44  adopt_variables: true
45  files:
46  - override.yaml
47 
48 # conditional replacement of local variables
49 - variables:
50  only:
51  variables:
52  - $PLANE_INDEX == 2
53  PLANE_INDEX: 7
54 
55 # catalog entries
56 - state:
57  planes.${PLANE_INDEX}.width: 10.0
58  planes.${PLANE_INDEX}.engine_count: ${ENGINE_COUNT}
59 @endcode
60 *//***************************************************************************/
61 class FE_DL_EXPORT CatalogReaderYaml:
62  public CatalogReaderBase
63 {
64  public:
65 
66 virtual BWORD load(String a_filename,sp<Catalog> a_spCatalog);
67 
68  private:
69 
70  BWORD loadWithVariables(String a_pathname,String a_filename,
71  sp<Catalog> a_spCatalog,
72  std::map<String,String>& a_variableMapIn,
73  std::map<String,String>& a_variableMapOut);
74 
75  void addEntry(sp<Catalog> a_spCatalog,String a_keyName,
76  String a_propertyName,const YAML::Node a_keyNode);
77 
78  void addState(sp<Catalog> a_spCatalog,const YAML::Node a_yamlNode);
79 
80  void addImport(sp<Catalog> a_spCatalog,
81  const YAML::Node a_yamlNode,String a_pathname,
82  BWORD a_adoptVariables,
83  std::map<String,String>& a_variableMapIn,
84  std::map<String,String>& a_variableMapOut);
85 
86  BWORD checkOnly(const YAML::Node a_yamlNode,
87  std::map<String,String>& a_variableMap);
88 
89  String m_rootPath;
90 };
91 
92 } /* namespace ext */
93 } /* namespace fe */
94 
95 #endif /* __yaml_CatalogReaderYaml_h__ */
kernel
Definition: namespace.dox:3
load catalog from yaml file
Definition: CatalogReaderYaml.h:61
Automatically reference-counted string container.
Definition: String.h:128
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53