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.
Fork of Smoothie by
ConfigCache.h
00001 /* 00002 This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 00003 Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 00004 Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 00005 You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>. 00006 */ 00007 00008 #ifndef CONFIGCACHE_H 00009 #define CONFIGCACHE_H 00010 00011 using namespace std; 00012 #include <vector> 00013 00014 #include "ConfigValue.h" 00015 00016 class ConfigCache : public std::vector<ConfigValue*> { 00017 public: 00018 ConfigCache(){} 00019 00020 // If we find an existing value, replace it, otherwise, push it at the back of the list 00021 void replace_or_push_back(ConfigValue* new_value){ 00022 00023 bool value_exists = false; 00024 // For each already existing element 00025 for( unsigned int i=1; i<this->size(); i++){ 00026 // If this configvalue matches the checksum 00027 bool match = true; 00028 unsigned int counter = 0; 00029 while( counter < 3 && new_value->check_sums[counter] != 0x0000 ){ 00030 if(this->at(i)->check_sums[counter] != new_value->check_sums[counter] ){ 00031 match = false; 00032 break; 00033 } 00034 counter++; 00035 } 00036 if( match == false ){ continue; } 00037 value_exists = true; 00038 00039 // Replace with the provided value 00040 delete this->at(i); 00041 this->at(i) = new_value; 00042 break; 00043 } 00044 00045 // Value does not already exists, add to the list 00046 if( value_exists == false ){ 00047 this->push_back(new_value); 00048 } 00049 00050 } 00051 00052 }; 00053 00054 00055 00056 #endif
Generated on Tue Jul 12 2022 20:09:00 by
1.7.2
