Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: CANBuffer KS0108_fork mbed-rtos mbed CAN Addresses
Fork of REVO_Updated_Steering by
variables.h
- Committer:
- palimar
- Date:
- 2014-11-22
- Revision:
- 35:b42afc973902
File content as of revision 35:b42afc973902:
#include "node.h"
class variables{
public:
variables();
~variables();
void add(int i, int s);
int get_screen(int i);
char get_value(int i);
int set_value(int i, char v);
node * get_node(int i);
int size;
node * head;
node * tail;
};
variables::variables(){
size = 0;
head = NULL;
tail = NULL;
}
variables::~variables(){
node * curr = head;
node * next = head;
while(curr != NULL){
next = curr->next;
delete(curr);
curr = next;
}
head = NULL;
tail = NULL;
size = 0;
}
void variables::add(int i, int s){
if(head == NULL){
head = new node(i, s);
tail = head;
}
else{
tail->next = new node(i,s);
tail = tail->next;
}
size++;
}
node * variables::get_node(int i){
node * curr = head;
while(curr != NULL){
if(curr->id == i){
return curr;
}
else{
curr = curr->next;
}
}
return NULL;
}
int variables::get_screen(int i){
node * curr = head;
while(curr != NULL){
if(curr->id == i){
return curr->screen;
}
else{
curr = curr->next;
}
}
return -1;
}
int variables::set_value(int i, char v){
node * curr = head;
while(curr != NULL){
if(curr->id == i){
curr->set_val(v);
return 0;
}
else{
curr = curr->next;
}
}
return -1;
}
char variables::get_value(int i){
node * curr = head;
while(curr != NULL){
if(curr->id == i){
return curr->value;
}
else{
curr = curr->next;
}
}
return 0;
}
