类似于模板类,还有模板结构体
template<typename T>
struct SharedSARepo
{
private:
typedef std::list< osg::observer_ptr<T> > SAUniqueSet;
SAUniqueSet _set;
Threading::Mutex _mx;
bool _enabled;
public:
SharedSARepo() : _enabled(true) { }
~SharedSARepo()
{
clear();
}
void setEnabled(bool value)
{
_enabled = value;
if ( !_enabled )
{
clear();
}
}
bool isEnabled() const
{
return _enabled;
}
bool share(osg::ref_ptr<T>& out)
{
if ( !_enabled )
return false;
_mx.lock();
bool found = false;
for (typename SAUniqueSet::iterator i = _set.begin(); !found && i != _set.end(); )
{