Shinya Kitaoka 810553
#pragma once
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
Shinya Kitaoka 120a6e
// 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
Shinya Kitaoka d1f6c4
class DVAPI TPersistSet final : public TPersist {
Shinya Kitaoka 120a6e
  PERSIST_DECLARATION(TPersistSet)
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  std::vector<tpersist *=""> m_objects;  //!< #owned# Stored objects.</tpersist>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  ~TPersistSet();  //!< Destroys the stored objects.
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  const std::vector<tpersist *=""> &objects() const {</tpersist>
Shinya Kitaoka 120a6e
    return m_objects;
Shinya Kitaoka 120a6e
  }  //!< Returns the stored objects list
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void insert(std::auto_ptr<tpersist></tpersist>
Shinya Kitaoka 120a6e
                  object);  //!< Overwrites an object type instance with
Shinya Kitaoka 120a6e
                            //!  the supplied one.
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 473e70
  void saveData(TOStream &os) override;  //!< Saves data to stream
Shinya Kitaoka 473e70
  void loadData(TIStream &is) override;  //!< Loads data from stream
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // TPERSISTSET_H