|
solarpowerlog trunk
|
00001 /* ---------------------------------------------------------------------------- 00002 solarpowerlog 00003 Copyright (C) 2009 Tobias Frost 00004 00005 This file is part of solarpowerlog. 00006 00007 Solarpowerlog is free software; However, it is dual-licenced 00008 as described in the file "COPYING". 00009 00010 For this file (ICapaIterator.cpp), the license terms are: 00011 00012 You can redistribute it and/or modify it under the terms of the GNU 00013 General Public License as published by the Free Software Foundation; either 00014 version 3 of the License, or (at your option) any later version. 00015 00016 This program is distributed in the hope that it will be useful, but 00017 WITHOUT ANY WARRANTY; without even the implied warranty of 00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 Lesser General Public License for more details. 00020 00021 You should have received a copy of the GNU Library General Public 00022 License along with this proramm; if not, see 00023 <http://www.gnu.org/licenses/>. 00024 ---------------------------------------------------------------------------- 00025 */ 00026 00033 #ifdef HAVE_CONFIG_H 00034 #include "config.h" 00035 #endif 00036 00037 #include "ICapaIterator.h" 00038 #include "configuration/Registry.h" 00039 00040 ICapaIterator::ICapaIterator( IInverterBase *b, IInverterBase *p ) 00041 { 00042 // TODO Cleanup Debug code cerr << " DEBUG: new ICapaInverter b=" << b->GetName(); 00043 //if (p) 00044 // cerr << " p=" << p->GetName(); 00045 // cerr << endl; 00046 00047 SetBase(b); 00048 parent = p; 00049 } 00050 00051 void ICapaIterator::SetBase( IInverterBase *b ) 00052 { 00053 base = b; 00054 it = base-> GetCapabilityIterator(); 00055 } 00056 00057 bool ICapaIterator::HasNext() 00058 { 00059 if (it != base->GetCapabilityLastIterator()) { 00060 //cerr << "DEBUG: Has Next on " << base->GetName() << " " 00061 // << (*it).first << endl; 00062 return true; 00063 } else { 00064 return false; 00065 } 00066 } 00067 00068 IInverterBase *ICapaIterator::GetBase() 00069 { 00070 return base; 00071 } 00072 00073 pair<string, CCapability*> ICapaIterator::GetNext() 00074 { 00075 00076 if (it != base->GetCapabilityLastIterator()) { 00077 return *(it++); 00078 } 00079 00080 LOGDEBUG(Registry::GetMainLogger(), 00081 "BUG: NOTHING TO RETURN: USE HasNext() PRIOR GETNEXT()"); 00082 assert(false); 00083 return *it; 00084 } 00085 00086 ICapaIterator::~ICapaIterator() 00087 00088 { 00089 // TODO Auto-generated destructor stub 00090 } 00091 00092 pair<string, CCapability*> ICapaIterator::GetElement() 00093 { 00094 // cerr << "DEBUG: Get Element: Returning Element " << (*it).first << endl; 00095 return *it; 00096 } 00097