}
+PartCache::PartCache():
+ rebuilding(false)
+{ }
+
void PartCache::begin_rebuild()
{
+ if(rebuilding)
+ throw logic_error("nested rebuild");
+ rebuilding = true;
+
next = parts.begin();
current = parts.end();
}
{
if(part.get_name().empty())
throw invalid_argument("PartCache::insert_special");
+ if(!rebuilding)
+ throw logic_error("!rebuilding");
for(current=next; current!=parts.end(); ++current)
if(current->part==&part)
GL::Mesh &PartCache::create_mesh(const Part &part, const GL::Texture2D &tex)
{
+ if(!rebuilding)
+ throw logic_error("!rebuilding");
+
if(current!=parts.end() && current->texture==&tex)
return *current->mesh;
void PartCache::end_rebuild()
{
+ rebuilding = false;
parts.erase(next, parts.end());
}
typedef std::list<CachedPart> PartList;
private:
+ bool rebuilding;
PartList parts;
PartList::iterator next;
PartList::iterator current;
public:
+ PartCache();
+
void begin_rebuild();
void insert_special(const Part &);
GL::Mesh &create_mesh(const Part &, const GL::Texture2D &);