* ========== Copyright Header Begin ==========================================
* OpenSPARC T2 Processor File: SS_ConfigObject.h
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
* The above named program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License version 2 as published by the Free Software Foundation.
* The above named program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public
* License along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
* ========== Copyright Header End ============================================
#ifndef __SS_ConfigObject_h__
#define __SS_ConfigObject_h__
class SS_ConfigValueList
;
class SS_ConfigValue
/*{{{*/
enum Type
{ CFG_VAR
, CFG_STR
, CFG_NUM
, CFG_LST
};
SS_ConfigValue( Type _type
) : type(_type
) {}
virtual ~SS_ConfigValue() {}
bool is_var() { return type
== CFG_VAR
; }
bool is_str() { return type
== CFG_STR
; }
bool is_num() { return type
== CFG_NUM
; }
bool is_lst() { return type
== CFG_LST
; }
SS_ConfigVariable
* var() { assert(type
== CFG_VAR
); return (SS_ConfigVariable
*)this; }
SS_ConfigString
* str() { assert(type
== CFG_STR
); return (SS_ConfigString
*)this; }
SS_ConfigNumber
* num() { assert(type
== CFG_NUM
); return (SS_ConfigNumber
*)this; }
SS_ConfigValueList
* lst() { assert(type
== CFG_LST
); return (SS_ConfigValueList
*)this; }
virtual void reflect() = 0;
class SS_ConfigVariable
: public SS_ConfigValue
/*{{{*/
SS_ConfigVariable( const char* _value
);
class SS_ConfigString
: public SS_ConfigValue
/*{{{*/
SS_ConfigString( const char* _value
);
class SS_ConfigNumber
: public SS_ConfigValue
/*{{{*/
SS_ConfigNumber( uint64_t _value
);
class SS_ConfigValueList
: public SS_ConfigValue
/*{{{*/
SS_ConfigValueList() : SS_ConfigValue(CFG_LST
) {}
std::list
<SS_ConfigValue
*> value
;
class SS_ConfigFieldList
/*{{{*/
std::map
<std::string
,SS_ConfigValue
*> field
;
class SS_ConfigObject
/*{{{*/
SS_ConfigObject( const std::string
& _name
, const std::string
& _type
, SS_ConfigFieldList
* _prop
);
SS_ConfigFieldList
* prop
;
class SS_ConfigObjectList
/*{{{*/
std::map
<std::string
,SS_ConfigObject
*> object
;
class SS_ConfigReader
/*{{{*/
SS_ConfigReader( const char* filename
);
SS_ConfigValue
* value( const char* object
, const char* field
);
SS_ConfigObjectList
* config
;