GreenCloud Simulator
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Resource Class Reference

#include <resource.h>

Inheritance diagram for Resource:
Inheritance graph
[legend]

Public Member Functions

 Resource (res_type t, double a, std::vector< Capacity > cap)
 
void print ()
 
virtual ~Resource ()
 
res_type getType ()
 
double getArch ()
 

Static Public Member Functions

static res_type translateType (const char *t)
 

Public Attributes

std::vector< Capacitycapacity
 

Protected Member Functions

 Resource ()
 
Resourceoperator= (const Resource &r)
 
int setType (const char *t)
 
int setCapacity (std::vector< Capacity > cap)
 
void sortCapacity ()
 

Protected Attributes

res_type type
 
double arch
 

Detailed Description

Definition at line 82 of file resource.h.

Constructor & Destructor Documentation

Resource::Resource ( res_type  t,
double  a,
std::vector< Capacity cap 
)

Definition at line 74 of file resource.cc.

74  {
75  type = t;
76  arch = a;
77  this->setCapacity(cap);
78 }
res_type type
Definition: resource.h:95
int setCapacity(std::vector< Capacity > cap)
Definition: resource.cc:110
double arch
Definition: resource.h:99
Resource::~Resource ( )
virtual

Definition at line 80 of file resource.cc.

80  {
81 
82 }
Resource::Resource ( )
protected

Definition at line 70 of file resource.cc.

70  {
71 
72 }

Member Function Documentation

double Resource::getArch ( )
inline

Definition at line 90 of file resource.h.

90 {return arch;};
double arch
Definition: resource.h:99
res_type Resource::getType ( )
inline

Definition at line 89 of file resource.h.

89 {return type;};
res_type type
Definition: resource.h:95
Resource & Resource::operator= ( const Resource r)
protected

Definition at line 119 of file resource.cc.

119  {
120  if (this != &r) { // make sure it is not the same object
121  capacity.clear();
122  capacity = r.capacity;
123  arch = r.arch;
124  type = r.type;
125  }
126  return *this; // Return ref for multiple assignment
127 }
std::vector< Capacity > capacity
Definition: resource.h:87
res_type type
Definition: resource.h:95
double arch
Definition: resource.h:99
void Resource::print ( )

Definition at line 129 of file resource.cc.

129  {
130  std::cerr << "Type:\t"<< type;
131  std::cerr << "\n";
132  std::cerr << "Architecture:\t"<< arch;
133  std::cerr << "\n";
134  std::cerr << "Capacities:\t";
135  std::vector <Capacity>::iterator iter;
136  for (iter = capacity.begin(); iter!=capacity.end(); iter++)
137  {
138  std::cerr << (*iter) << ",";
139  }
140 
141 }
std::vector< Capacity > capacity
Definition: resource.h:87
res_type type
Definition: resource.h:95
double arch
Definition: resource.h:99
int Resource::setCapacity ( std::vector< Capacity cap)
protected

Definition at line 110 of file resource.cc.

110  {
111  capacity = cap;
112  return 0;
113 }
std::vector< Capacity > capacity
Definition: resource.h:87
int Resource::setType ( const char *  t)
protected

Definition at line 103 of file resource.cc.

103  {
104  type = translateType(t);
105  return 0;
106 }
res_type type
Definition: resource.h:95
static res_type translateType(const char *t)
Definition: resource.cc:85
void Resource::sortCapacity ( )
protected

Definition at line 115 of file resource.cc.

115  {
116  std::sort(capacity.begin(),capacity.end());
117 }
std::vector< Capacity > capacity
Definition: resource.h:87
res_type Resource::translateType ( const char *  t)
static

Definition at line 85 of file resource.cc.

85  {
86  res_type type;
87  if(strcmp(t, "Computing") == 0){
88  type=Computing;
89  } else if(strcmp(t, "Memory") == 0){
90  type=Memory;
91  } else if(strcmp(t, "Storage") == 0){
92  type=Storage;
93  } else if(strcmp(t, "Networking") == 0){
94  type=Networking;
95  } else {
96  std::cerr << "Unknown resource type" << t;
97  abort();
98 
99  }
100  return type;
101 }
res_type type
Definition: resource.h:95
res_type
Definition: resource.h:19

Member Data Documentation

double Resource::arch
protected

Definition at line 99 of file resource.h.

std::vector<Capacity> Resource::capacity

Capacities of resources, e.g. MIPS for each core, B for each disk in an array

Definition at line 87 of file resource.h.

res_type Resource::type
protected

Type of resource, see enum ( e.g. CPU, Memory, Disk, Network Interface)

Definition at line 95 of file resource.h.


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