00001 00002 /*========================================================================== 00003 * 00004 * Original source copyright (c) 2003, Carnegie Mellon University. 00005 * See copyright.cmu for details. 00006 * 00007 *========================================================================== 00008 */ 00009 00010 #ifndef _LINKEDPROPERTYLIST_HPP 00011 #define _LINKEDPROPERTYLIST_HPP 00012 00013 #include "PropertyList.hpp" 00014 00015 #include <list> 00016 00017 using namespace std; 00018 00019 namespace lemur 00020 { 00021 namespace parse 00022 { 00023 00036 typedef list<Property *> plist; 00037 00038 class LinkedPropertyList : public PropertyList { 00039 00040 public: 00041 LinkedPropertyList(); 00042 virtual ~LinkedPropertyList(); 00043 00047 virtual const Property * getProperty(const string name) const; 00048 00050 virtual void startIteration() const; 00053 virtual const Property * nextEntry() const; 00055 virtual bool hasMore() const; 00056 00057 00063 virtual void setProperty(const Property * property); 00064 00068 virtual void removeProperty(const string name); 00070 virtual void clear(); 00071 00072 protected: 00073 00074 // checks the cache for a property that 00075 // can be reused, otherwise creates a new 00076 // property 00077 virtual Property * getAProperty(); 00078 // finds the property with the given name 00079 virtual Property * getPropertyInternal(const string name) const; 00080 00081 // need this mutable for iteration 00082 mutable plist::iterator iterator; 00083 mutable plist properties; 00084 00085 plist cache; 00086 00087 // We copy values into this property when returning 00088 // property objects. This allows control to 00089 // the linked property list only. 00090 mutable Property returnProp; 00091 }; 00092 } 00093 } 00094 00095 #endif //_LINKEDPROPERTYLIST_HPP