Computer Assisted Medical Intervention Tool Kit version 6.0
 
Loading...
Searching...
No Matches
CamiTKExtensionModel Class Reference

This class manages a CamiTK Extension model (stored as a VariantDataModel). More...

#include <CamiTKExtensionModel.h>

+ Collaboration diagram for CamiTKExtensionModel:

Public Member Functions

 CamiTKExtensionModel (const QString &filePath=QString())
 constructor
 
void clear ()
 reset the model from scratch (the model will then be empty)
 
VariantDataModelgetModel ()
 get access to the VariantDataModel
 
bool isModified ()
 was the data model modified since last read
 
bool load (const QString &filePath)
 read the given file and creates the corresponding configuration
 
void resetModel (QString name)
 reset the model with empty extension arrays.
 
bool save (const QString &filePath=QString())
 save the current config to the current filePath or given filePath and update camitkFile if needed Warning it does overwrite the previous content of filePath
 
void setModel (VariantDataModel &)
 modify the model
 
QString toJSON ()
 the camitk extension data model as a JSON string
 

Detailed Description

This class manages a CamiTK Extension model (stored as a VariantDataModel).

It can load/save the model to CamiTK extension file (JSON)

Role:

  • Reads the given CamiTK file (.json)
  • Provides the corresponding VariantDataModel (as a reference)
  • Saves the current state of the model to a given file
  • The managed model can be set using setModel(..)
Note
the static newExtension(..) method create a QVariantMap that can be used to add an new extension of the given type to a model.

The expected JSON file must follow the following format:

{
"camitk": {
"extensions": {
"actions": [ ... ],
"name":"..."
},
"timestamp": "2024-05-17T16:27:05",
"version": "camitk-6.0"
}
}

Instead the actions array (or as well as, at the same level), you may add a components, viewers, libraries and applications arrays.

Constructor & Destructor Documentation

◆ CamiTKExtensionModel()

CamiTKExtensionModel::CamiTKExtensionModel ( const QString &  filePath = QString())

constructor

References load().

+ Here is the call graph for this function:

Member Function Documentation

◆ clear()

void CamiTKExtensionModel::clear ( )

reset the model from scratch (the model will then be empty)

Referenced by CamiTKExtensionModelPresenter::CamiTKExtensionModelPresenter(), and load().

+ Here is the caller graph for this function:

◆ getModel()

◆ isModified()

bool CamiTKExtensionModel::isModified ( )

was the data model modified since last read

References VariantDataModel::isModified().

Referenced by CamiTKExtensionModelPresenter::isModified().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load()

bool CamiTKExtensionModel::load ( const QString &  filePath)

read the given file and creates the corresponding configuration

References clear(), and VariantDataModel::contains().

Referenced by CamiTKExtensionModel(), CamiTKExtensionModelPresenter::CamiTKExtensionModelPresenter(), ExtensionBuilder::ExtensionBuilder(), ExtensionGenerator::ExtensionGenerator(), and camitk::HotPlugActionExtension::newHotPlugActionExtension().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetModel()

void CamiTKExtensionModel::resetModel ( QString  name)

reset the model with empty extension arrays.

After calling this method, all the extension type arrays are empty and the licence is set to LGPL-3 CamiTK:

{
"name": "...",
"license": "LGPL-3 CamiTK",
"actions": [],
"components": [],
"viewers": [],
"libraries": [],
"applications": []
}

References VariantDataModel::insert().

Referenced by CamiTKExtensionModelPresenter::CamiTKExtensionModelPresenter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

bool CamiTKExtensionModel::save ( const QString &  filePath = QString())

save the current config to the current filePath or given filePath and update camitkFile if needed Warning it does overwrite the previous content of filePath

Returns
false if the file could not be reopened for writing

References VariantDataModel::reset(), and toJSON().

Referenced by CamiTKExtensionModelPresenter::saveExtensionFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setModel()

void CamiTKExtensionModel::setModel ( VariantDataModel newModel)

modify the model

◆ toJSON()

QString CamiTKExtensionModel::toJSON ( )

the camitk extension data model as a JSON string

References VariantDataModel::getValue().

Referenced by CamiTKExtensionModelPresenter::CamiTKExtensionModelPresenter(), CamiTKExtensionModelPresenter::modelUpdated(), and save().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: