GreenCloud Simulator
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Friends | List of all members
ResourceSpec Class Reference

#include <resourcespec.h>

Inheritance diagram for ResourceSpec:
Inheritance graph
[legend]
Collaboration diagram for ResourceSpec:
Collaboration graph
[legend]

Public Member Functions

 ResourceSpec ()
 
virtual ~ResourceSpec ()
 
virtual int command (int argc, const char *const *argv)
 
void print ()
 
int addCapacity (double cap)
 
int addPowerState (int ps)
 
int setName (const char *name)
 
int setArch (const char *name)
 
PowerModelgetPowerModel ()
 
- Public Member Functions inherited from Resource
 Resource (res_type t, double a, std::vector< Capacity > cap)
 
void print ()
 
virtual ~Resource ()
 
res_type getType ()
 
double getArch ()
 

Public Attributes

std::string name_
 
std::vector< int > power_states
 
- Public Attributes inherited from Resource
std::vector< Capacitycapacity
 

Private Member Functions

void setPowerModel (PowerModel *model)
 

Private Attributes

PowerModelres_model_
 

Friends

class DcResource
 

Additional Inherited Members

- Static Public Member Functions inherited from Resource
static res_type translateType (const char *t)
 
- Protected Member Functions inherited from Resource
 Resource ()
 
Resourceoperator= (const Resource &r)
 
int setType (const char *t)
 
int setCapacity (std::vector< Capacity > cap)
 
void sortCapacity ()
 
- Protected Attributes inherited from Resource
res_type type
 
double arch
 

Detailed Description

Definition at line 24 of file resourcespec.h.

Constructor & Destructor Documentation

ResourceSpec::ResourceSpec ( )

Definition at line 19 of file resourcespec.cc.

19  : name_("NA"), res_model_(NULL){
20  // std::cerr << ("Resource Spec Constructor.\n");
21  capacity.clear();
22  power_states.clear();
23 }
std::vector< Capacity > capacity
Definition: resource.h:87
std::string name_
Definition: resourcespec.h:34
std::vector< int > power_states
Definition: resourcespec.h:36
PowerModel * res_model_
Definition: resourcespec.h:47
ResourceSpec::~ResourceSpec ( )
virtual

Definition at line 25 of file resourcespec.cc.

25  {
26  name_.clear();
27 }
std::string name_
Definition: resourcespec.h:34

Member Function Documentation

int ResourceSpec::addCapacity ( double  cap)

Definition at line 29 of file resourcespec.cc.

29  {
30  capacity.push_back(cap);
31  return 0;
32 }
std::vector< Capacity > capacity
Definition: resource.h:87
int ResourceSpec::addPowerState ( int  ps)

Definition at line 33 of file resourcespec.cc.

33  {
34  power_states.push_back(ps);
35  return 0;
36 }
std::vector< int > power_states
Definition: resourcespec.h:36
int ResourceSpec::command ( int  argc,
const char *const *  argv 
)
virtual

Definition at line 74 of file resourcespec.cc.

74  {
75 
76 
77  if (argc == 2) {
78  if (strcmp(argv[1], "print") == 0) {
79  print();
80  return (TCL_OK);
81  }
82  } else if (argc == 3) {
83  if (strcmp(argv[1], "add-capacity") == 0) {
84  addCapacity(atof(argv[2]));
85  return (TCL_OK);
86  } else if(strcmp(argv[1], "add-power-state") == 0){
87  addPowerState(atoi(argv[2]));
88  return (TCL_OK);
89  } else if(strcmp(argv[1], "set-type") == 0){
90  if(Resource::setType(argv[2])==0){
91  return (TCL_OK);
92  } else {
93  return (TCL_ERROR);
94  }
95  } else if(strcmp(argv[1], "set-name") == 0){
96  setName(argv[2]);
97  return (TCL_OK);
98  } else if(strcmp(argv[1], "set-arch") == 0){
99  setArch(argv[2]);
100  return (TCL_OK);
101  } else if (strcmp(argv[1], "set-power-model") == 0) {
102  PowerModel* pm = (PowerModel*) TclObject::lookup(argv[2]);
103  this->setPowerModel(pm);
104  return (TCL_OK);
105  }
106  }
107  return (ResourceSpec::command(argc, argv));
108 }
virtual int command(int argc, const char *const *argv)
Definition: resourcespec.cc:74
int setType(const char *t)
Definition: resource.cc:103
int setArch(const char *name)
Definition: resourcespec.cc:44
int addCapacity(double cap)
Definition: resourcespec.cc:29
int setName(const char *name)
Definition: resourcespec.cc:39
void setPowerModel(PowerModel *model)
Definition: resourcespec.cc:49
int addPowerState(int ps)
Definition: resourcespec.cc:33
PowerModel * ResourceSpec::getPowerModel ( )

Definition at line 53 of file resourcespec.cc.

53  {
54  return res_model_;
55 }
PowerModel * res_model_
Definition: resourcespec.h:47
void ResourceSpec::print ( )

Definition at line 57 of file resourcespec.cc.

57  {
58  std::cerr << "ResourceSpec:\t";
59  std::cerr << name_;
60  std::cerr << "\n";
62  std::vector <int>::iterator iter;
63  std::cerr << "Power states:\t";
64  for (iter = power_states.begin(); iter!=power_states.end(); iter++)
65  {
66  std::cerr << (*iter) << ",";
67  }
68  std::cerr << "\n";
69 
70 }
std::string name_
Definition: resourcespec.h:34
void print()
Definition: resource.cc:129
std::vector< int > power_states
Definition: resourcespec.h:36
int ResourceSpec::setArch ( const char *  name)

Definition at line 44 of file resourcespec.cc.

44  {
45  arch = atof(name);
46  return 0;
47 }
double arch
Definition: resource.h:99
int ResourceSpec::setName ( const char *  name)

Definition at line 39 of file resourcespec.cc.

39  {
40  name_=name;
41  return 0;
42 }
std::string name_
Definition: resourcespec.h:34
void ResourceSpec::setPowerModel ( PowerModel model)
private

Definition at line 49 of file resourcespec.cc.

49  {
50  res_model_ = model;
51 }
PowerModel * res_model_
Definition: resourcespec.h:47

Friends And Related Function Documentation

friend class DcResource
friend

Definition at line 26 of file resourcespec.h.

Member Data Documentation

std::string ResourceSpec::name_

Definition at line 34 of file resourcespec.h.

std::vector<int> ResourceSpec::power_states

Definition at line 36 of file resourcespec.h.

PowerModel* ResourceSpec::res_model_
private

Definition at line 47 of file resourcespec.h.


The documentation for this class was generated from the following files: