ConfigMgr.h 1.2 KB
Newer Older
G
groot 已提交
1 2 3 4 5 6 7 8 9 10 11
/*******************************************************************************
 * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
 * Unauthorized copying of this file, via any medium is strictly prohibited.
 * Proprietary and confidential.
 ******************************************************************************/
#pragma once

#include "utils/Error.h"
#include "ConfigNode.h"

namespace zilliz {
J
jinhai 已提交
12
namespace milvus {
G
groot 已提交
13 14 15 16 17 18 19 20 21 22
namespace server {

// this class can parse nested config file and return config item
// config file example(yaml style)
//       AAA: 1
//       BBB:
//         CCC: hello
//         DDD: 23.5
//
// usage
S
starlord 已提交
23
//   const ConfigMgr* mgr = ConfigMgr::GetInstance();
G
groot 已提交
24 25 26 27 28
//   const ConfigNode& node = mgr->GetRootNode();
//   std::string val = node.GetValue("AAA"); // return '1'
//   const ConfigNode& child = node.GetChild("BBB");
//   val = child.GetValue("CCC"); //return 'hello'

S
starlord 已提交
29
class ConfigMgr {
G
groot 已提交
30
 public:
S
starlord 已提交
31
    static ConfigMgr* GetInstance();
G
groot 已提交
32 33 34 35 36 37 38 39 40 41 42 43

    virtual ServerError LoadConfigFile(const std::string &filename) = 0;
    virtual void Print() const = 0;//will be deleted
    virtual std::string DumpString() const = 0;

    virtual const ConfigNode& GetRootNode() const = 0;
    virtual ConfigNode& GetRootNode() = 0;
};

}
}
}