Code Search for Developers
 
 
  

gs_configurable.h from GreenSocs at Krugle


Show gs_configurable.h syntax highlighted

#ifndef __gsconfigurable_h__
#define __gsconfigurable_h__

#include <systemc>

#include <string>
#include <ostream>
#include <map>

#include "gs_param_root.h"

namespace tlm {

//-----------------------------------------------------------------------------
// gs_configurable
//-----------------------------------------------------------------------------

typedef std::map<std::string, gs_param_root*> param_map;
typedef std::map<std::string, gs_param_root*>::iterator param_iterator;

/**
 * SC_MODULEs may inherit this class to provide a configuration interface
 * to the outside world.
 */
class gs_configurable {
public:

  gs_configurable() {}
  virtual ~gs_configurable() {} // force to be polymorphic

  void addParam(const std::string name, gs_param_root *param) {
    params.insert(param_map::value_type(name, param));
    //std::cout << "GS_CONFIGURABLE: Added param [" << name << "] to param map of [" << (dynamic_cast<sc_core::sc_object*>(this))->name() << "] (map size now " << params.size() << ")" << std::endl;
  }

  bool setParam(const std::string name, const std::string value) {
    param_iterator pos;
    pos = params.find(name);
    if (pos == params.end()) {
      char ch[256];
      sprintf(ch, "Set param [%s] of [%s] to value=[%s] failed! Param doesn't exist.", name.c_str(), (dynamic_cast<sc_core::sc_object*>(this))->name(), value.c_str());
      SC_REPORT_WARNING((dynamic_cast<sc_core::sc_object*>(this))->name(), ch);
      return false;
    }
    //std::cout << "GS_CONFIGURABLE: Set param [" << name << "] of [" << (dynamic_cast<sc_core::sc_object*>(this))->name() << "] to value=[" << value.c_str() << "]" << std::endl;

    gs_param_root *r = pos->second;
    r->set(value);
    return true;
  }

  std::string getParam(std::string name) {
    param_iterator pos;
    pos = params.find(name);
    if (pos == params.end())
      return NULL;
    std::cout << "GS_CONFIGURABLE: Get param [" << name << "] of [" << (dynamic_cast<sc_core::sc_object*>(this))->name() << "] called (value=[" << pos->second->get().c_str() << "]" << std::endl;
    return pos->second->get();
  }

protected:  
  param_map params;
};


} // end of namespace tlm


// have to include gs_param.h here to avoid circular dependencies which cannot be resolved by the compiler
#include "gs_param.h"


#endif




See more files for this project here

GreenSocs

To develop SystemC infrustructure, basic IP, patches and add on library code for eventual standerdization.\r\nThe GreenSocs project is made up of a number of contributions (sub projects). Please visit www.greensocs.com for more information.

Project homepage: http://sourceforge.net/projects/greensocs
Programming language(s): C,C++,Java,Perl,XML
License: other

  class_wrapper.h
  description.h
  dust.h
  dust_model.h
  dust_model_and_introspection.h
  dust_model_and_transactions.h
  gs_config.h
  gs_config_parser.h
  gs_configurable.h
  gs_datatypes.h
  gs_dust_port.h
  gs_param.h
  gs_param_root.h
  gs_trace.h
  memoryutils.h
  payload_event_queue-new_buggy.h
  payload_event_queue.h
  phase_trace.h
  ref_count.h
  router_fabric.h