From bdcd43904a577be981e1559e607a233c10631401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 26 Oct 2011 09:18:50 +0000 Subject: [PATCH] Document backup creation in type plugins git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@12688 383ad7c9-94d9-4d36-a494-682f7c89f535 --- OpenFlipper/BasePlugin/TypeInterface.hh | 42 +++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/OpenFlipper/BasePlugin/TypeInterface.hh b/OpenFlipper/BasePlugin/TypeInterface.hh index 58b0deae6..0e0fcb0f1 100644 --- a/OpenFlipper/BasePlugin/TypeInterface.hh +++ b/OpenFlipper/BasePlugin/TypeInterface.hh @@ -170,6 +170,48 @@ of the new type. The type itself has to be defined in the ObjectTypes subdirecto Now, each time a plugin emits addEmptyObject(DATA_MY_DATA), the addEmpty() function will add the object to the scenegraph and return the newly created object's id. + \section Backups + Backups are very specific to the underlying data structures of certain types. Therefore the type + plugins also manage backups. Backups itself are managed by perObjectData objects based on + the BackupData class. + When the slot gets called, we first have to check, if an BackupData is already available. If not, + we create one. Than the backup is generated and passed to the backup data attached to the object. + + You have to derive your backups from the BaseBackup class, where you only need to implement the + apply function and your constructor. In the following example, this class is named TriMeshBackup. + + \code + void TypeTriangleMeshPlugin::generateBackup( int _id, QString _name, UpdateType _type ){ + + // Get the object corresponding to the id + BaseObjectData* object = 0; + PluginFunctions::getObject(_id, object); + TriMeshObject* meshObj = PluginFunctions::triMeshObject(object); + + // Safety check + if ( meshObj != 0 ){ + + //get backup object data + BackupData* backupData = 0; + + // If a backup data has already been attached, get it, otherwise create it. + if ( object->hasObjectData( OBJECT_BACKUPS ) ) + backupData = dynamic_cast< BackupData* >(object->objectData(OBJECT_BACKUPS)); + else{ + //add backup data + backupData = new BackupData(object); + object->setObjectData(OBJECT_BACKUPS, backupData); + } + + // Create a new backup + TriMeshBackup* backup = new TriMeshBackup(meshObj, _name, _type); + + // Store it in the backup data + backupData->storeBackup( backup ); + } + } + \endcode + To use the TypeInterface: