Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef TPERSISTSET_H
Toshihiro Shimizu 890ddd
#define TPERSISTSET_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzCore includes
Toshihiro Shimizu 890ddd
#include "tpersist.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//STD includes
Toshihiro Shimizu 890ddd
#include <vector></vector>
Toshihiro Shimizu 890ddd
Campbell Barton 40cabe
#include <memory></memory>
Campbell Barton 40cabe
Toshihiro Shimizu 890ddd
//**************************************************************************************
Toshihiro Shimizu 890ddd
//    TPersistSet  declaration
Toshihiro Shimizu 890ddd
//**************************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
  Container of TPersist instances that are  unique per concrete type .
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
  This class acts as a container of TPersist instances where only a single
Toshihiro Shimizu 890ddd
  instance of a given most-derived type can be stored.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
  This is typically useful to \a overwrite objects of a given type, typically
Toshihiro Shimizu 890ddd
  configuration options, without discarding the other objects.
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class DVAPI TPersistSet : public TPersist
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	PERSIST_DECLARATION(TPersistSet)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	std::vector<tpersist *=""> m_objects; //!< #owned# Stored objects.</tpersist>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	~TPersistSet(); //!< Destroys the stored objects.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	const std::vector<tpersist *=""> &objects() const</tpersist>
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		return m_objects;
Toshihiro Shimizu 890ddd
	} //!< Returns the stored objects list
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void insert(std::auto_ptr<tpersist> object); //!< Overwrites an object type instance with</tpersist>
Toshihiro Shimizu 890ddd
												 //!  the supplied one.
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	void saveData(TOStream &os); //!< Saves data to stream
Toshihiro Shimizu 890ddd
	void loadData(TIStream &is); //!< Loads data from stream
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif // TPERSISTSET_H