tahoma2d/toonz/sources/include/tpersistset.h

49 lines
1.4 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef TPERSISTSET_H
#define TPERSISTSET_H
// TnzCore includes
#include "tpersist.h"
2016-06-15 18:43:10 +12:00
// STD includes
2016-03-19 06:57:51 +13:00
#include <vector>
#include <memory>
2016-03-19 06:57:51 +13:00
//**************************************************************************************
// TPersistSet declaration
//**************************************************************************************
/*!
Container of TPersist instances that are <I> unique per concrete type </I>.
This class acts as a container of TPersist instances where only a single
instance of a given most-derived type can be stored.
This is typically useful to \a overwrite objects of a given type, typically
configuration options, without discarding the other objects.
*/
class DVAPI TPersistSet final : public TPersist {
2016-06-15 18:43:10 +12:00
PERSIST_DECLARATION(TPersistSet)
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
std::vector<TPersist *> m_objects; //!< #owned# Stored objects.
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
~TPersistSet(); //!< Destroys the stored objects.
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
const std::vector<TPersist *> &objects() const {
return m_objects;
} //!< Returns the stored objects list
2016-03-19 06:57:51 +13:00
void insert(std::unique_ptr<TPersist>
2016-06-15 18:43:10 +12:00
object); //!< Overwrites an object type instance with
//! the supplied one.
2016-03-19 06:57:51 +13:00
public:
2016-06-19 20:06:29 +12:00
void saveData(TOStream &os) override; //!< Saves data to stream
void loadData(TIStream &is) override; //!< Loads data from stream
2016-03-19 06:57:51 +13:00
};
2016-06-15 18:43:10 +12:00
#endif // TPERSISTSET_H