ThingMOList.cpp

Go to the documentation of this file.
00001 /*
00002 SagaEngine library
00003 Copyright (c) 2002-2006 Skalden Studio AS
00004 
00005 This software is provided 'as-is', without any express or implied 
00006 warranty. In no event will the authors be held liable for any 
00007 damages arising from the use of this software.
00008 
00009 Permission is granted to distribute the library under the terms of the 
00010 Q Public License version 1.0. Be sure to read and understand the license
00011 before using the library. It should be included here, or you may read it
00012 at http://www.trolltech.com/products/qt/licenses/licensing/qpl
00013 
00014 The original version of this library can be located at:
00015 http://www.sagaengine.com/
00016 
00017 Rune Myrland
00018 rune@skalden.com
00019 */
00020 
00021 
00022 #include "ThingMOList.hpp"
00023 #include "ThingMO.hpp"
00024 #include "comp/schema/CompSchema.hpp"
00025 #include "util/error/Log.hpp"
00026 #include <cstdio>
00027 
00028 using namespace se_core;
00029 
00030 namespace se_ogre {
00031 
00032     ThingMOList
00033     ::ThingMOList()
00034         : firstNode_(CompSchema::VoidList::end()) {
00035     }
00036 
00037 
00038     ThingMOList
00039     ::~ThingMOList() {
00040         CompSchema::voidList.removeChain(firstNode_);
00041         firstNode_ = CompSchema::VoidList::end();
00042     }
00043 
00044 
00045     void ThingMOList
00046     ::add(ThingMO& value) {
00047         Assert(&value);
00048         //LogWarning(value.name() << " added.");
00049         CompSchema::voidList.add(&const_cast<ThingMO&>(value), firstNode_);
00050     }
00051 
00052 
00053     void ThingMOList
00054     ::remove(ThingMO& value) {
00055         //LogWarning(value.name() << " removed.");
00056         CompSchema::voidList.remove(&const_cast<ThingMO&>(value), firstNode_);
00057     }
00058 
00059 
00060     ThingMO& ThingMOList
00061     ::pop() {
00062         Assert(firstNode_ != -1);
00063         ThingMO& value = *static_cast<ThingMO*>(CompSchema::voidList.pop(firstNode_));
00064         //LogWarning(value.name() << " popped.");
00065         return value;
00066     }
00067 
00068 
00069     bool ThingMOList
00070     ::contains(const ThingMO& value) const {
00071         CompSchema::VoidList::iterator_type it = iterator();
00072         while(it != CompSchema::VoidList::end()) {
00073             if(CompSchema::voidList.next(it) == &value)
00074                 return true;
00075         }
00076         return false;
00077     }
00078 
00079 
00080     bool ThingMOList
00081     ::contains(ThingMOList& msc) const {
00082         CompSchema::VoidList::iterator_type it = msc.iterator();
00083         while(it != CompSchema::VoidList::end()) {
00084             if(!contains(*static_cast<ThingMO*>(CompSchema::voidList.next(it))))
00085                 return false;
00086         }
00087         return true;
00088     }
00089 
00090 
00091     bool ThingMOList
00092     ::sharesAny(ThingMOList& msc) const {
00093         CompSchema::VoidList::iterator_type it = msc.iterator();
00094         while(it != CompSchema::VoidList::end()) {
00095             if(contains(*static_cast<ThingMO*>(CompSchema::voidList.next(it)))) {
00096                 return true;
00097             }
00098         }
00099         return false;
00100     }
00101 
00102 
00103     void ThingMOList
00104     ::add(ThingMOList& msc) {
00105         Assert(&msc);
00106         CompSchema::VoidList::iterator_type it = msc.iterator();
00107         while(it != CompSchema::VoidList::end()) {
00108             add(*static_cast<ThingMO*>(CompSchema::voidList.next(it)));
00109         }
00110     }
00111 
00112 
00113     void ThingMOList
00114     ::initIterator(CompSchema::VoidList::iterator_type& iterator) const {
00115         iterator = firstNode_;
00116     }
00117 
00118 
00119     bool ThingMOList
00120     ::isEmpty() const {
00121         return (firstNode_ == CompSchema::VoidList::end());
00122     }
00123 
00124 
00125     void ThingMOList
00126     ::clear() {
00127         CompSchema::voidList.removeChain(firstNode_);
00128     }
00129 
00130 
00131     int ThingMOList
00132     ::size() const {
00133         return CompSchema::voidList.size(firstNode_);
00134     }
00135 
00136 
00137 
00138     ThingMOList::Iterator
00139     ::Iterator()
00140         : it_(CompSchema::VoidList::end()) {
00141     }
00142 
00143 
00144     ThingMOList::Iterator
00145     ::Iterator(const ThingMOList& msc) {
00146         (*this).init(msc);
00147     }
00148 
00149 
00150     void ThingMOList::Iterator
00151 	::init(const ThingMOList& msc) {
00152         msc.initIterator(it_);
00153     }
00154 
00155 
00156     void ThingMOList::Iterator
00157 	::init(short firstNode) {
00158         it_ = firstNode;
00159     }
00160 
00161 
00162 }

Home Page | SagaEngine trunk (updated nightly) reference generated Sun Dec 2 20:06:09 2007 by Doxygen version 1.3.9.1.

SourceForge.net Logo