[136] | 1 | /*
|
---|
| 2 | ###############################################################################
|
---|
| 3 | #
|
---|
| 4 | # Temboo Arduino library
|
---|
| 5 | #
|
---|
| 6 | # Copyright 2014, Temboo Inc.
|
---|
| 7 | #
|
---|
| 8 | # Licensed under the Apache License, Version 2.0 (the "License");
|
---|
| 9 | # you may not use this file except in compliance with the License.
|
---|
| 10 | # You may obtain a copy of the License at
|
---|
| 11 | #
|
---|
| 12 | # http://www.apache.org/licenses/LICENSE-2.0
|
---|
| 13 | #
|
---|
| 14 | # Unless required by applicable law or agreed to in writing,
|
---|
| 15 | # software distributed under the License is distributed on an
|
---|
| 16 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
---|
| 17 | # either express or implied. See the License for the specific
|
---|
| 18 | # language governing permissions and limitations under the License.
|
---|
| 19 | #
|
---|
| 20 | ###############################################################################
|
---|
| 21 | */
|
---|
| 22 |
|
---|
| 23 | #include <stddef.h>
|
---|
| 24 | #include <string.h>
|
---|
| 25 | #include "ChoreoOutputSet.h"
|
---|
| 26 |
|
---|
| 27 |
|
---|
| 28 | ChoreoOutputSet::ChoreoOutputSet() {
|
---|
| 29 | m_first = NULL;
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | ChoreoOutputSet::~ChoreoOutputSet() {
|
---|
| 33 | ChoreoOutput* i = m_first;
|
---|
| 34 | ChoreoOutput* next = NULL;
|
---|
| 35 | while(i != NULL) {
|
---|
| 36 | next = i->getNext();
|
---|
| 37 | delete i;
|
---|
| 38 | i = next;
|
---|
| 39 | }
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | void ChoreoOutputSet::put(const char* name, const char* path, const char* variable) {
|
---|
| 43 | if (m_first == NULL) {
|
---|
| 44 | m_first = new ChoreoOutput(NULL, name, path, variable);
|
---|
| 45 | } else {
|
---|
| 46 | ChoreoOutput* last = NULL;
|
---|
| 47 | ChoreoOutput* i = m_first;
|
---|
| 48 | while(i != NULL) {
|
---|
| 49 | if (strcmp(i->getName(), name) == 0) {
|
---|
| 50 | i->setPath(path);
|
---|
| 51 | i->setVariable(variable);
|
---|
| 52 | break;
|
---|
| 53 | }
|
---|
| 54 | last = i;
|
---|
| 55 | i = i->getNext();
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | if (i == NULL) {
|
---|
| 59 | new ChoreoOutput(last, name, path, variable);
|
---|
| 60 | }
|
---|
| 61 | }
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | const ChoreoOutput* ChoreoOutputSet::get(const char* name) const {
|
---|
| 65 | ChoreoOutput* i = m_first;
|
---|
| 66 | while(i != NULL) {
|
---|
| 67 | if (strcmp(i->getName(), name) == 0) {
|
---|
| 68 | return i;
|
---|
| 69 | }
|
---|
| 70 | i = i->getNext();
|
---|
| 71 | }
|
---|
| 72 | return NULL;
|
---|
| 73 | }
|
---|