1 ////////////////////////////////////////////////////////////////////////////////
3 // Copyright (c) 2005 Peter Kümmel
4 // Permission to use, copy, modify, distribute and sell this software for any
5 // purpose is hereby granted without fee, provided that the above copyright
6 // notice appear in all copies and that both that copyright notice and this
7 // permission notice appear in supporting documentation.
8 // The author makes no representations about the
9 // suitability of this software for any purpose. It is provided "as is"
10 // without express or implied warranty.
11 ////////////////////////////////////////////////////////////////////////////////
13 // $Id: OrderedStatic.cpp 756 2006-10-17 20:05:42Z syntheticpp $
16 #include <loki/OrderedStatic.h>
32 OrderedStaticCreatorFunc::OrderedStaticCreatorFunc()
36 OrderedStaticCreatorFunc::~OrderedStaticCreatorFunc()
41 OrderedStaticManagerClass::OrderedStaticManagerClass() :
43 max_longevity_(std::numeric_limits<unsigned int>::min()),
44 min_longevity_(std::numeric_limits<unsigned int>::max())
48 OrderedStaticManagerClass::~OrderedStaticManagerClass()
52 void OrderedStaticManagerClass::createObjects()
54 for(unsigned int longevity=max_longevity_; longevity>=min_longevity_; longevity--)
56 for(unsigned int i=0; i<staticObjects_.size(); i++)
58 Data cur = staticObjects_.at(i);
59 if(cur.longevity==longevity)
60 ( (*cur.object).*cur.creator )();
65 void OrderedStaticManagerClass::registerObject(unsigned int l, OrderedStaticCreatorFunc *o,Creator f)
67 staticObjects_.push_back(Data(l,o,f));
69 if(l>max_longevity_) max_longevity_=l;
70 if(l<min_longevity_) min_longevity_=l;
73 OrderedStaticManagerClass::Data::Data(unsigned int l, OrderedStaticCreatorFunc *o, Creator f)
74 : longevity(l), object(o), creator(f)
80 } // end namespace Loki