36 auto* mem =
dynamic_cast<Memory*
>(resource);
40 return ( (freeSpace >= mem->getFreeSpace()) &&
41 (totalSpace >= mem->getTotalSpace()) );
46 auto* resource =
new Memory(*
this);
78 auto* mem =
dynamic_cast<Storage*
>(resource);
82 return ( (freeSpace >= mem->getFreeSpace()) &&
83 (totalSpace >= mem->getTotalSpace()) );
88 auto* resource =
new Storage(*
this);
116 auto* net =
dynamic_cast<Network*
>(resource);
120 bool ret = (!strlen(net->getIP4()))?
true : (strIP4 == std::string(net->getIP4()));
121 ret &= (!strlen(net->getIP6()))?
true : (strIP6 == std::string(net->getIP6()));
122 ret &= (!strlen(net->getMAC()))?
true : (strMAC == std::string(net->getMAC()));
128 auto* resource =
new Network(*
this);
143 frequency = (double)0.0;
156 frequency = (double)0.0;
170 auto* proc =
dynamic_cast<Processor*
>(resource);
175 bool ret = (!strlen(proc->getArchitecture()))?
true : (strArchitecure == std::string(proc->getArchitecture()));
176 ret &= (!strlen(proc->getModel()))?
true : (strModel == std::string(proc->getModel()));
177 ret &= (cores >= proc->getCores());
178 ret &= (siblings >= proc->getSiblings());
179 ret &= (frequency >= proc->getFrequency());
213 Computer::swap(resource);
219 GenericResource::operator=(rhs);
228 peripheralResources.push_back(newres);
242 if (!mres->resourceCount()) {
245 for(
int i=0; i<mres->resourceCount(); i++)
247 auto* comp =
dynamic_cast<Computer*
>(&mres->getResourceAt(i));
248 if (comp && satisfyComputer(comp)) {
250 }
else if (satisfyComputerResource(&mres->getResourceAt(i))) {
257 auto* comp =
dynamic_cast<Computer*
>(resource);
259 return satisfyComputer(comp);
262 return satisfyComputerResource(resource);
266bool Computer::satisfyComputer(
Computer* comp)
282 if (memory.
satisfy(resource)) {
285 if (storage.
satisfy(resource)) {
288 if (network.
satisfy(resource)) {
291 if (processor.
satisfy(resource)) {
294 if (platform.
satisfy(resource)) {
299 for (itr = peripheralResources.begin(); itr != peripheralResources.end(); itr++) {
300 if ((*itr)->satisfy(resource)) {
309 auto* resource =
new Computer(*
this);
313void Computer::swap(
const Computer &comp)
316 memory = comp.memory;
317 storage = comp.storage;
318 processor = comp.processor;
319 network = comp.network;
320 platform = comp.platform;
321 processes = comp.processes;
330 for(
auto& peripheralResource : peripheralResources)
332 delete peripheralResource;
333 peripheralResource =
nullptr;
335 peripheralResources.clear();
bool satisfy(GenericResource *resource) override
Computer()
Class Computer.
int peripheralCount() const
bool addPeripheral(GenericResource &res)
GenericResource & getPeripheralAt(int index) const
Processor & getProcessor()
Computer & operator=(const Computer &rhs)
void setName(const char *szName)
bool satisfy(GenericResource *resource) override
bool satisfy(GenericResource *resource) override
bool satisfy(GenericResource *resource) override
Processor()
Class Processor.
bool satisfy(GenericResource *resource) override
std::vector< GenericResource * >::iterator ResourcePIterator
double loadAverageInstant