vector<AHF_Device*> AHF_Controller_devices;
int8_t AHF_Controller_GetDeviceByID(string& _id, AHF_Device* _dev);
void jakas_funkcja(parametry)
{
AHF_Device* dev;
int8_t dev_no;
uint8_t test;
dev_no = AHF_Controller_GetDeviceByID(_id, dev);
test = dev->GetAddress();
/* Niestety, dev i test to jakieś śmieci... */
}
/* poniższa funkcja działa pięknie, tylko po wyjściu z niej _dev nie jest tym, czym był wewnątrz niej... */
int8_t AHF_Controller_GetDeviceByID(string& _id, AHF_Device* _dev)
{
int no, i;
bool found = false;
no = AHF_Controller_devices.size();
i = 0;
while(i<no && !found)
{
_dev = AHF_Controller_devices.at(i);
if(_id == _dev->GetID())
{
found = true;
}
else
{
i++;
}
}
if(found)
{
return i; // podaję dobry _id, więc zawsze ląduję w tym miejscu
}
else
{
_dev = NULL;
return -1;
}
}