diff --git a/README.md b/README.md index 79663fff42878b5a2bdad48c0354292544da2dfe..ab4413f231918641cffb7c6859872b7b994bcdd1 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,53 @@ -# Config Policy +# Configuration Policy Component ## Introduction -The config policy, namely, cust, provides APIs for each service module to obtain the configuration directories at different levels or the configuration file paths. +The configuration policy component, namely, customization_config_policy, provides APIs for each service module to obtain the configuration directories at different levels or the configuration file paths. + +## System Architecture + +**Figure 1** Architecture of the configuration policy component + +![](figures/config_policy_en.png) + +The architecture is described as follows: + +- **interfaces** provides the path of the file with the highest priority and all-level paths of the specified file. +- **frameworks** initializes the configuration directory and queries the file path. ## Directory Structure -The directory structure for the config policy is as follows: +The code directory structure of the configuration policy component is as follows: ``` /base/customization/ -├── config_policy # Code repository for the config policy -│ ├── frameworks # Core code of the config policy -│ │ ├── config_policy # config policy -│ │ │ └── src # Implementation code -│ ├── interfaces # APIs of the config policy -│ │ ├── inner_api # APIs of the config policy for internal subsystems -│ │ └── kits # JavaScript APIs -│ └── test # Test code +├── config_policy # Code repository for the configuration policy component +│ ├── frameworks # Core code of the configuration policy component +│ │ ├── config_policy # Configuration policy module +│ │ │ └── src # Implementation code +│ ├── interfaces # APIs of the configuration policy component +│ │ ├── inner_api # APIs for internal subsystems +│ │ └── kits # JavaScript APIs of the configurationpolicy component +│ └── test # Test code ``` ## Usage -Call the APIs of the config policy to obtain the configuration directories at different levels or the configuration file paths. +Call the APIs of the configuration policy component to obtain the configuration directories at different levels or the configuration file paths. ``` #include "config_policy_utils.h" -const char *testPathSuffix = "user.xml"; // Set the name of the configuration file. +CfgDir *cfgDir = GetCfgDirList(); // Obtain the configuration directory list. +FreeCfgDirList(cfgDir); // Release the memory after the list is obtained. + +const char *cfgPath = "etc/xml/cfg.xml"; // Set the relative path and name of the configuration file. +CfgFiles *cfgFiles = GetCfgFiles(cfgPath); // Obtain the configuration file paths of all configuration levels. +FreeCfgFiles(cfgFiles); // Release the memory after the information is obtained. + +const char *userPath = "etc/xml/user.xml"; // Set the relative path and name of the configuration file. char buf[MAX_PATH_LEN] = {0}; -char *filePath = GetOneCfgFile(testPathSuffix, buf, MAX_PATH_LEN); // Obtain the path of the configuration file with the highest priority. +char *filePath = GetOneCfgFile(userPath, buf, MAX_PATH_LEN); // Obtain the path of the configuration file with the highest priority. ``` ## Constraints @@ -39,4 +57,3 @@ char *filePath = GetOneCfgFile(testPathSuffix, buf, MAX_PATH_LEN); // Obtain the ## Repositories Involved **customization\_config\_policy** - diff --git a/figures/config_policy_en.png b/figures/config_policy_en.png new file mode 100644 index 0000000000000000000000000000000000000000..6758c8df989844ccffcb4da06a7c5b96deae5e0f Binary files /dev/null and b/figures/config_policy_en.png differ