39 auto* mem =
dynamic_cast<Memory*
>(resource);
42 return ( (freeSpace >= mem->getFreeSpace()) &&
43 (totalSpace >= mem->getTotalSpace()) );
48 auto* resource =
new Memory(*
this);
79 auto* mem =
dynamic_cast<Storage*
>(resource);
82 return ( (freeSpace >= mem->getFreeSpace()) &&
83 (totalSpace >= mem->getTotalSpace()) );
88 auto* resource =
new Storage(*
this);
115 auto* net =
dynamic_cast<Network*
>(resource);
118 bool ret = (!strlen(net->getIP4()))?
true : (strIP4 ==
string(net->getIP4()));
119 ret &= (!strlen(net->getIP6()))?
true : (strIP6 ==
string(net->getIP6()));
120 ret &= (!strlen(net->getMAC()))?
true : (strMAC ==
string(net->getMAC()));
126 auto* resource =
new Network(*
this);
141 frequency = (double)0.0;
142 siblings = (size_t)0;
154 frequency = (double)0.0;
155 siblings = (size_t)0;
167 auto* proc =
dynamic_cast<Processor*
>(resource);
171 bool ret = (!strlen(proc->getArchitecture()))?
true : (strArchitecure ==
string(proc->getArchitecture()));
172 ret &= (!strlen(proc->getModel()))?
true : (strModel ==
string(proc->getModel()));
173 ret &= (cores >= proc->getCores());
174 ret &= (siblings >= proc->getSiblings());
175 ret &= (frequency >= proc->getFrequency());
209 Computer::swap(resource);
215 GenericResource::operator=(rhs);
224 peripheralResources.push_back(newres);
237 if(!mres->resourceCount())
239 for(
int i=0; i<mres->resourceCount(); i++)
241 auto* comp =
dynamic_cast<Computer*
>(&mres->getResourceAt(i));
242 if(comp &&satisfyComputer(comp))
244 else if(satisfyComputerResource(&mres->getResourceAt(i)))
250 auto* comp =
dynamic_cast<Computer*
>(resource);
252 return satisfyComputer(comp);
254 return satisfyComputerResource(resource);
258 bool Computer::satisfyComputer(
Computer* comp)
279 if(processor.
satisfy(resource))
285 for(itr=peripheralResources.begin(); itr!=peripheralResources.end(); itr++)
286 if((*itr)->satisfy(resource))
293 auto* resource =
new Computer(*
this);
297 void Computer::swap(
const Computer &comp)
300 memory = comp.memory;
301 storage = comp.storage;
302 processor = comp.processor;
303 network = comp.network;
304 platform = comp.platform;
305 processes = comp.processes;
313 for(
auto& peripheralResource : peripheralResources)
315 delete peripheralResource;
316 peripheralResource =
nullptr;
318 peripheralResources.clear();