cxx_config_ini.hh revision 10458:64809024b924
16166Ssteve.reinhardt@amd.com/*
26166Ssteve.reinhardt@amd.com * Copyright (c) 2014 ARM Limited
36166Ssteve.reinhardt@amd.com * All rights reserved
46166Ssteve.reinhardt@amd.com *
56166Ssteve.reinhardt@amd.com * The license below extends only to copyright in the software and shall
66166Ssteve.reinhardt@amd.com * not be construed as granting a license to any other intellectual
76166Ssteve.reinhardt@amd.com * property including but not limited to intellectual property relating
86166Ssteve.reinhardt@amd.com * to a hardware implementation of the functionality of the software
96166Ssteve.reinhardt@amd.com * licensed hereunder.  You may use the software subject to the license
106166Ssteve.reinhardt@amd.com * terms below provided that you ensure that this notice is replicated
116166Ssteve.reinhardt@amd.com * unmodified and in its entirety in all distributions of the software,
126166Ssteve.reinhardt@amd.com * modified or unmodified, in source code or in binary form.
136166Ssteve.reinhardt@amd.com *
146166Ssteve.reinhardt@amd.com * Redistribution and use in source and binary forms, with or without
156166Ssteve.reinhardt@amd.com * modification, are permitted provided that the following conditions are
166166Ssteve.reinhardt@amd.com * met: redistributions of source code must retain the above copyright
176166Ssteve.reinhardt@amd.com * notice, this list of conditions and the following disclaimer;
186166Ssteve.reinhardt@amd.com * redistributions in binary form must reproduce the above copyright
196166Ssteve.reinhardt@amd.com * notice, this list of conditions and the following disclaimer in the
206166Ssteve.reinhardt@amd.com * documentation and/or other materials provided with the distribution;
216166Ssteve.reinhardt@amd.com * neither the name of the copyright holders nor the names of its
226166Ssteve.reinhardt@amd.com * contributors may be used to endorse or promote products derived from
236166Ssteve.reinhardt@amd.com * this software without specific prior written permission.
246166Ssteve.reinhardt@amd.com *
256166Ssteve.reinhardt@amd.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
266166Ssteve.reinhardt@amd.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
276166Ssteve.reinhardt@amd.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
286166Ssteve.reinhardt@amd.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
296166Ssteve.reinhardt@amd.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
306166Ssteve.reinhardt@amd.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
316166Ssteve.reinhardt@amd.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
326166Ssteve.reinhardt@amd.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
336166Ssteve.reinhardt@amd.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
346166Ssteve.reinhardt@amd.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
356166Ssteve.reinhardt@amd.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
366166Ssteve.reinhardt@amd.com *
376166Ssteve.reinhardt@amd.com * Authors: Andrew Bardsley
386166Ssteve.reinhardt@amd.com */
396166Ssteve.reinhardt@amd.com
406166Ssteve.reinhardt@amd.com/**
41 * @file
42 *
43 *  .ini file reading wrapper for use with CxxConfigManager
44 */
45
46#ifndef __SIM_CXX_CONFIG_INI_HH__
47#define __SIM_CXX_CONFIG_INI_HH__
48
49#include "base/inifile.hh"
50#include "base/str.hh"
51#include "sim/cxx_config.hh"
52
53/** CxxConfigManager interface for using .ini files */
54class CxxIniFile : public CxxConfigFileBase
55{
56  protected:
57    IniFile iniFile;
58
59  public:
60    CxxIniFile() { }
61
62    /* Most of these functions work by mapping 'object' onto 'section' */
63
64    bool getParam(const std::string &object_name,
65        const std::string &param_name,
66        std::string &value) const;
67
68    bool getParamVector(const std::string &object_name,
69        const std::string &param_name,
70        std::vector<std::string> &values) const;
71
72    bool getPortPeers(const std::string &object_name,
73        const std::string &port_name,
74        std::vector<std::string> &peers) const;
75
76    bool objectExists(const std::string &object_name) const;
77
78    void getAllObjectNames(std::vector<std::string> &list) const;
79
80    void getObjectChildren(const std::string &object_name,
81        std::vector<std::string> &children,
82        bool return_paths = false) const;
83
84    bool load(const std::string &filename);
85};
86
87#endif // __SIM_CXX_CONFIG_INI_HH__
88