GOFIGURE2  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | List of all members
QGoDBNameDescEntityManager Class Referenceabstract

Abstract class : the QGoDBNameDescEntityManager manages the interactions between the user and the database (add a new one, delete)for a DBTable containing a name and a description.Has some Qt widgets and manages queries for this particular DBTable (i.e get list of existing ones). More...

#include <Code/GUI/lib/DBManager/QGoDBNameDescEntityManager.h>

Inheritance diagram for QGoDBNameDescEntityManager:
Inheritance graph
[legend]
Collaboration diagram for QGoDBNameDescEntityManager:
Collaboration graph
[legend]

Public Types

typedef std::vector< std::pair
< std::string, std::string > > 
NamesDescrContainerType
 

Public Member Functions

std::string AddAnEntity (vtkMySQLDatabase *iDatabaseConnector)
 execute the dialog asking the user to enter a name and a description, validates the name, set the m_DatabaseConnector, save the entity in the DB and return the name of the new entity More...
 
virtual bool DeleteEntity (vtkMySQLDatabase *iDatabaseConnector)
 show the list of the existing entities so the user can choose the ones he wants to delete, then delete them from the database More...
 
NamesDescrContainerType GetListExistingEntities (vtkMySQLDatabase *iDatabaseConnector)
 return the list of all the existing entities stored in the database More...
 
std::string GetNameNewEntity ()
 return the name of the new entity added More...
 
int GetTheEntityID (std::string iName, vtkMySQLDatabase *iDatabaseConnector)
 get the ID of the entity based on the name More...
 
 QGoDBNameDescEntityManager (QWidget *iParent=0, std::string iEntityName="", int iImgSessionID=0)
 
 ~QGoDBNameDescEntityManager ()
 

Protected Slots

void DeleteEntitiesFromList (std::vector< std::string > iVectorNamesEntitiesToDelete)
 Delete in the database the entities with the names contained in the vector. More...
 
virtual void ValidateName (std::string iName, std::string iDescription)=0
 Pure Virtual method : check that the name doesn't already exists in the database, if so, make the m_NameDescDialog asks the user to choose another one, if no, close the m_NameDescDialog and call SaveNewEntityInDB() More...
 

Protected Member Functions

template<typename T >
bool CheckEntityAlreadyExists (T iNewEntity)
 check if the entity already exists in the database, if yes, give the name of the existing entity to the user, if no, record the name iName as the name of the new entity More...
 
std::vector< std::string > GetNameExistingEntities (vtkMySQLDatabase *iDatabaseConnector)
 return the names of all the entities stored in the database More...
 
virtual void SaveNewEntityInDB ()=0
 Pure Virtual method : save the new entity in the database, the m_DatabaseConnectorForNewEntity needs to be set before calling this method. Check that the entity doesn't already exists in the database, if so, give the user the name of the existing entity. More...
 
template<typename T >
void ValidateNameTemplate (T &ioNewEntity, std::string iName, std::string iDescription)
 check if the name already exists for this entity in the database, if yes, let the user know, if not, call SaveNewEntityInDB More...
 

Protected Attributes

vtkMySQLDatabase * m_DatabaseConnector
 
std::string m_EntityName
 
int m_ImgSessionID
 
QGoNameDescriptionInputDialogm_NameDescDialog
 
std::string m_NameNewEntity
 

Detailed Description

Abstract class : the QGoDBNameDescEntityManager manages the interactions between the user and the database (add a new one, delete)for a DBTable containing a name and a description.Has some Qt widgets and manages queries for this particular DBTable (i.e get list of existing ones).

Definition at line 51 of file QGoDBNameDescEntityManager.h.

Member Typedef Documentation

typedef std::vector< std::pair< std::string, std::string > > QGoDBNameDescEntityManager::NamesDescrContainerType

Definition at line 67 of file QGoDBNameDescEntityManager.h.

Constructor & Destructor Documentation

QGoDBNameDescEntityManager::QGoDBNameDescEntityManager ( QWidget *  iParent = 0,
std::string  iEntityName = "",
int  iImgSessionID = 0 
)
explicit
Parameters
[in]iParentQWidget parent
[in]iEntityNameName of the DBTable
[in]iImgSessionIDID of the current imagingsession

Definition at line 41 of file QGoDBNameDescEntityManager.cxx.

QGoDBNameDescEntityManager::~QGoDBNameDescEntityManager ( )

Definition at line 56 of file QGoDBNameDescEntityManager.cxx.

Member Function Documentation

std::string QGoDBNameDescEntityManager::AddAnEntity ( vtkMySQLDatabase *  iDatabaseConnector)

execute the dialog asking the user to enter a name and a description, validates the name, set the m_DatabaseConnector, save the entity in the DB and return the name of the new entity

Parameters
[in]iDatabaseConnectorconnection to the database
Returns
Name of the new entity, empty if the user canceled the adding

Definition at line 63 of file QGoDBNameDescEntityManager.cxx.

template<typename T >
bool QGoDBNameDescEntityManager::CheckEntityAlreadyExists ( iNewEntity)
inlineprotected

check if the entity already exists in the database, if yes, give the name of the existing entity to the user, if no, record the name iName as the name of the new entity

Parameters
[in]iNewEntitycontains data to check if it already exists
Returns
bool return true if it already exists, false if not
Template Parameters
Tthis method takes only children of GoDBNameDescRow as type

Definition at line 165 of file QGoDBNameDescEntityManager.h.

void QGoDBNameDescEntityManager::DeleteEntitiesFromList ( std::vector< std::string >  iVectorNamesEntitiesToDelete)
protectedslot

Delete in the database the entities with the names contained in the vector.

Parameters
[in]iVectorNamesEntitiesToDeletevector of the names for the entities to be deleted in the database

Definition at line 123 of file QGoDBNameDescEntityManager.cxx.

bool QGoDBNameDescEntityManager::DeleteEntity ( vtkMySQLDatabase *  iDatabaseConnector)
virtual

show the list of the existing entities so the user can choose the ones he wants to delete, then delete them from the database

Parameters
[in]iDatabaseConnectorconnection to the database
Returns
true if the user chooses to delete an entity, false if he canceled the deleting

Reimplemented in QGoDBColorManager.

Definition at line 103 of file QGoDBNameDescEntityManager.cxx.

QGoDBNameDescEntityManager::NamesDescrContainerType QGoDBNameDescEntityManager::GetListExistingEntities ( vtkMySQLDatabase *  iDatabaseConnector)

return the list of all the existing entities stored in the database

Parameters
[in]iDatabaseConnectorconnection to the database
Returns
a vector of all the names associated with their description

Definition at line 85 of file QGoDBNameDescEntityManager.cxx.

std::vector< std::string > QGoDBNameDescEntityManager::GetNameExistingEntities ( vtkMySQLDatabase *  iDatabaseConnector)
protected

return the names of all the entities stored in the database

Parameters
[in]iDatabaseConnectorconnection to the database
Returns
a vector of the names

Definition at line 144 of file QGoDBNameDescEntityManager.cxx.

std::string QGoDBNameDescEntityManager::GetNameNewEntity ( )

return the name of the new entity added

Returns
name of the new entity

Definition at line 136 of file QGoDBNameDescEntityManager.cxx.

int QGoDBNameDescEntityManager::GetTheEntityID ( std::string  iName,
vtkMySQLDatabase *  iDatabaseConnector 
)

get the ID of the entity based on the name

Parameters
[in]iDatabaseConnectorconnection to the database
[in]iNamename of the entity
Returns
ID of the entity

Definition at line 169 of file QGoDBNameDescEntityManager.cxx.

virtual void QGoDBNameDescEntityManager::SaveNewEntityInDB ( )
protectedpure virtual

Pure Virtual method : save the new entity in the database, the m_DatabaseConnectorForNewEntity needs to be set before calling this method. Check that the entity doesn't already exists in the database, if so, give the user the name of the existing entity.

Implemented in QGoDBColorManager, QGoDBSubCellTypeManager, and QGoDBCellTypeManager.

virtual void QGoDBNameDescEntityManager::ValidateName ( std::string  iName,
std::string  iDescription 
)
protectedpure virtualslot

Pure Virtual method : check that the name doesn't already exists in the database, if so, make the m_NameDescDialog asks the user to choose another one, if no, close the m_NameDescDialog and call SaveNewEntityInDB()

Parameters
[in]iNamename entered by the user
[in]iDescriptiondescription entered by the user
template<typename T >
void QGoDBNameDescEntityManager::ValidateNameTemplate ( T &  ioNewEntity,
std::string  iName,
std::string  iDescription 
)
inlineprotected

check if the name already exists for this entity in the database, if yes, let the user know, if not, call SaveNewEntityInDB

Template Parameters
Tthis method takes only children of GoDBNameDescRow as type
Parameters
[in]iNamename for the new entity entered by the user
[in]iDescriptiondescription for the new entity entered by the user
[in,out]ioNewEntityfields name and description modified by the method

Definition at line 196 of file QGoDBNameDescEntityManager.h.

Member Data Documentation

vtkMySQLDatabase* QGoDBNameDescEntityManager::m_DatabaseConnector
protected

Definition at line 137 of file QGoDBNameDescEntityManager.h.

std::string QGoDBNameDescEntityManager::m_EntityName
protected

Definition at line 135 of file QGoDBNameDescEntityManager.h.

int QGoDBNameDescEntityManager::m_ImgSessionID
protected

Definition at line 134 of file QGoDBNameDescEntityManager.h.

QGoNameDescriptionInputDialog* QGoDBNameDescEntityManager::m_NameDescDialog
protected

Definition at line 136 of file QGoDBNameDescEntityManager.h.

std::string QGoDBNameDescEntityManager::m_NameNewEntity
protected

Definition at line 138 of file QGoDBNameDescEntityManager.h.


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