Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / api / pli / src / SS_ConfigObject.h
/*
* ========== 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__
#include <assert.h>
#include <string>
#include <list>
#include <map>
#include "SS_Types.h"
class SS_ConfigVariable;
class SS_ConfigString;
class SS_ConfigNumber;
class SS_ConfigValueList;
class SS_ConfigValue/*{{{*/
{
public:
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;
private:
const Type type;
};
/*}}}*/
class SS_ConfigVariable : public SS_ConfigValue/*{{{*/
{
public:
SS_ConfigVariable( const char* _value );
void reflect();
std::string value;
};
/*}}}*/
class SS_ConfigString : public SS_ConfigValue/*{{{*/
{
public:
SS_ConfigString( const char* _value );
void reflect();
std::string value;
};
/*}}}*/
class SS_ConfigNumber : public SS_ConfigValue/*{{{*/
{
public:
SS_ConfigNumber( uint64_t _value );
void reflect();
uint64_t value;
};
/*}}}*/
class SS_ConfigValueList : public SS_ConfigValue/*{{{*/
{
public:
SS_ConfigValueList() : SS_ConfigValue(CFG_LST) {}
~SS_ConfigValueList();
void reflect();
std::list<SS_ConfigValue*> value;
};
/*}}}*/
class SS_ConfigFieldList/*{{{*/
{
public:
SS_ConfigFieldList() {}
~SS_ConfigFieldList();
void reflect();
std::map<std::string,SS_ConfigValue*> field;
};
/*}}}*/
class SS_ConfigObject/*{{{*/
{
public:
SS_ConfigObject( const std::string& _name, const std::string& _type, SS_ConfigFieldList* _prop );
~SS_ConfigObject();
void reflect();
std::string name;
std::string type;
SS_ConfigFieldList* prop;
};
/*}}}*/
class SS_ConfigObjectList/*{{{*/
{
public:
SS_ConfigObjectList() {}
~SS_ConfigObjectList();
void reflect();
std::map<std::string,SS_ConfigObject*> object;
};
/*}}}*/
class SS_ConfigReader/*{{{*/
{
public:
SS_ConfigReader( const char* filename );
~SS_ConfigReader();
SS_ConfigValue* value( const char* object, const char* field );
void reflect();
private:
SS_ConfigObjectList* config;
};
/*}}}*/
#endif