QtXMLController Class Reference

#include <QtXMLController.h>

Inheritance diagram for QtXMLController:

Inheritance graph
XmlController
[legend]
Collaboration diagram for QtXMLController:

Collaboration graph
XmlControllerBaseXMLXmlElementXmlNodeViewBaseXMLPlotterBaseXMLFontXMLAxisModelXMLAxisTickXMLPointRepXMLBinToColorXMLColorXMLDataRepXMLMapMatrixProjectorXMLNTupleProjectorXMLBinningProjectorXMLBinsBaseXMLBinnerAxisXMLNTupleXMLFunctionProjectorXMLTransformXMLTupleCutXMLHiNTupleXMLXmlDocumentViewFactory
[legend]
List of all members.

Detailed Description

A singleton class that is does XML serialization and deserialization with Qt XML module.

Author:
Paul F. Kunz <Paul_Kunz@slac.stanford.edu>

Definition at line 38 of file QtXMLController.h.

Public Types

enum  Status { Success, OpenError, ParseError, NTupleError }
 Return codes of opening file. More...

Public Member Functions

virtual XmlElementaddDataSource (const DataSource *ntuple)
 Adds the DataSource to the document if it doesn't already exist.
void addViews (const std::vector< const ViewBase * > &views)
 Adds ViewBase elements to the root of the document.
bool areDataSourcesSaved (const std::vector< const ViewBase * > &views)
 Returns true if all the NTuple objects used by the views have been saved to or read from a file.
PlotterBasecreateDisplay ()
 Creates a new empty display and makes it the current one.
virtual void createDocument (const std::string &doc_name)
 Creates an DOM Document with name doc_name.
FontBasecreateFont () const
 Creates a empty QtFont object.
ViewBasecreateView (PlotterBase *)
 Creates a new view for the current PlotterBase object and adds it to the list of views.
DataRepgetDataRep (int ref)
 Returns a pointer to the DataRep from the xml reference Id.
const DataSourcegetDataSource (int ref_id)
 Returns pointer to data source from the xml reference ID.
const std::list< ViewBase * > & getFromPasteboard (ViewFactory *factory, const std::vector< const ViewBase * > &views)
 Creates and returns a list of objects that was copied to the pasteboard.
const std::list< ViewBase * > & getFromSelectionCopy (ViewFactory *factory, const std::vector< const ViewBase * > &views)
 Creates and returns objects that were copied to the selection copy.
int getId (const void *address)
 Returns the unique integer identifier for given address.
std::list< std::string > & getMissingTuples ()
 Return a list of missing tuples.
PlotterBasegetPlotter (int ref)
 Returns a pointer to the PlotterBase object from the XML refereed Id.
const TupleCutgetTupleCut (int ref_id)
 Returns pointer to the TupleCut from the xml reference Id.
virtual const std::list< ViewBase * > & getViews (ViewFactory *)
 Returns the list of views in the current document.
bool isPasteboardEmpty ()
 Returns true if global pasteboard is empty.
Status openFile (const std::string &filename)
 Attempts to open and parse the specified HippoDraw document.
virtual Status openUpdatedNTuples ()
 Open the missing tuples updated by GUI.
void registerPlotter (int id, PlotterBase *plotter)
 Registers the plotter with id.
Status saveToFile (const std::vector< const ViewBase * > &views, const std::string &filename)
 Saves the document represented by list of ViewBase objects to file with name filename.
void saveToPasteboard (const std::vector< const ViewBase * > &)
 Saves the document represented by the list of ViewBase objects to the pasteboard.
void saveToSelectionCopy (const std::vector< const ViewBase * > &views)
 Saves the document represented by the list of ViewBase objects to the selection copy.
virtual bool serializeViews (const std::vector< const ViewBase * > &views)
 Serializes the ViewBase objects in views and their appropriate subcomponents.

Static Public Member Functions

static QtXMLControllerinstance ()
 Returns the pointer to the singleton instance.

Static Public Attributes

static XmlDocumentm_xml_doc = 0
 The current document being generated or read.

Protected Member Functions

virtual bool fileExists (const std::string &filename) const
 Returns true if the specified file exists.
virtual void newDocument (const std::string &name)
 Creates a new document.
 QtXMLController ()
 A default constructor for avoiding creation except by itself or with derived classes.

Private Member Functions

 QtXMLController (const QtXMLController &)
 A private copy constructor in order to avoid copying.

Static Private Attributes

static QtXMLControllers_instance = 0
 The pointer to the singleton object.


Member Enumeration Documentation

enum Status [inherited]

Return codes of opening file.

Enumerator:
Success 
OpenError 
ParseError 
NTupleError 

Definition at line 59 of file XmlController.h.


Constructor & Destructor Documentation

QtXMLController ( const QtXMLController  )  [private]

A private copy constructor in order to avoid copying.

QtXMLController (  )  [protected]

A default constructor for avoiding creation except by itself or with derived classes.

Definition at line 23 of file QtXMLController.cxx.

Referenced by QtXMLController::instance().


Member Function Documentation

XmlElement * addDataSource ( const DataSource ntuple  )  [virtual, inherited]

Adds the DataSource to the document if it doesn't already exist.

Returns the Dom element corresponding to the DataSource.

Definition at line 331 of file XmlController.cxx.

References XmlNode::appendChild(), HiNTupleXML::createElement(), XmlDocument::documentElement(), XmlController::m_data, XmlController::m_ntuple, and XmlController::m_xml_doc.

Referenced by NTupleProjectorXML::createElement().

void addViews ( const std::vector< const ViewBase * > &  views  )  [inherited]

Adds ViewBase elements to the root of the document.

Definition at line 302 of file XmlController.cxx.

References XmlNode::appendChild(), ViewBaseXML::createElement(), XmlDocument::documentElement(), XmlController::m_view, and XmlController::m_xml_doc.

Referenced by XmlController::serializeViews().

bool areDataSourcesSaved ( const std::vector< const ViewBase * > &  views  )  [inherited]

Returns true if all the NTuple objects used by the views have been saved to or read from a file.

Definition at line 213 of file XmlController.cxx.

References ViewBaseXML::areDataSourcesSaved(), and XmlController::m_view.

Referenced by CanvasWindow::areDataSourcesSaved().

PlotterBase* createDisplay (  )  [inherited]

Creates a new empty display and makes it the current one.

void createDocument ( const std::string &  doc_name  )  [virtual, inherited]

Creates an DOM Document with name doc_name.

The document becomes the current document.

Definition at line 66 of file XmlController.cxx.

References XmlDocument::appendChild(), XmlDocument::createElement(), XmlController::m_xml_doc, and XmlController::newDocument().

Referenced by XmlController::serializeViews().

FontBase * createFont (  )  const [inherited]

Creates a empty QtFont object.

Definition at line 326 of file XmlController.cxx.

References XmlController::m_view_factory.

ViewBase * createView ( PlotterBase  )  [inherited]

Creates a new view for the current PlotterBase object and adds it to the list of views.

Definition at line 316 of file XmlController.cxx.

References ViewFactory::createView(), XmlController::m_view_factory, and XmlController::m_views.

Referenced by ViewBaseXML::getObjects().

bool fileExists ( const std::string &  filename  )  const [protected, virtual]

Returns true if the specified file exists.

Implements XmlController.

Definition at line 37 of file QtXMLController.cxx.

DataRep * getDataRep ( int  ref  )  [inherited]

Returns a pointer to the DataRep from the xml reference Id.

Definition at line 376 of file XmlController.cxx.

References XmlController::m_datarep_map.

Referenced by DataRepXML::createObject(), PlotterBaseXML::getCutTargets(), PlotterBaseXML::getObject(), PlotterBaseXML::handleFunction(), and PlotterBaseXML::handleTextPlotter().

const DataSource * getDataSource ( int  ref_id  )  [inherited]

Returns pointer to data source from the xml reference ID.

Definition at line 348 of file XmlController.cxx.

References XmlController::m_tuple_map.

Referenced by DataRepXML::createDataRep().

const list< ViewBase * > & getFromPasteboard ( ViewFactory factory,
const std::vector< const ViewBase * > &  views 
) [inherited]

Creates and returns a list of objects that was copied to the pasteboard.

The parameter views is used when the an object makes a reference to object already on the canvas. For example, if an object was a DataRep with a TupleCut applied, then newly created object needs to have a reference to that TupleCut.

Definition at line 166 of file XmlController.cxx.

References XmlController::getFromDocument(), XmlController::m_pasteboard, and XmlController::m_xml_doc.

Referenced by CanvasView::addFromPasteboard(), and CanvasView::copyFromPasteboard().

const list< ViewBase * > & getFromSelectionCopy ( ViewFactory factory,
const std::vector< const ViewBase * > &  views 
) [inherited]

Creates and returns objects that were copied to the selection copy.

See also:
getFromPasteboard.

Definition at line 176 of file XmlController.cxx.

References XmlController::getFromDocument(), XmlController::m_selectboard, and XmlController::m_xml_doc.

Referenced by CanvasView::restoreFromSelectCopy().

int getId ( const void *  address  )  [inherited]

Returns the unique integer identifier for given address.

Definition at line 515 of file XmlController.cxx.

References XmlController::m_addr_map, and XmlController::m_id.

Referenced by XmlController::fillNTupleMap(), and XmlController::fillTupleCutMap().

std::list< std::string > & getMissingTuples (  )  [inherited]

Return a list of missing tuples.

Will be updated by the GUI and try to open them again.

Definition at line 532 of file XmlController.cxx.

References XmlController::m_missing_tuples.

PlotterBase * getPlotter ( int  ref  )  [inherited]

Returns a pointer to the PlotterBase object from the XML refereed Id.

Definition at line 388 of file XmlController.cxx.

References XmlController::m_plotter_map.

const TupleCut * getTupleCut ( int  ref_id  )  [inherited]

Returns pointer to the TupleCut from the xml reference Id.

Definition at line 359 of file XmlController.cxx.

References XmlController::m_tuple_cut_map.

Referenced by PlotterBaseXML::handleCutPlotter().

const list< ViewBase * > & getViews ( ViewFactory  )  [virtual, inherited]

Returns the list of views in the current document.

The views are created using the specified view factory.

Definition at line 202 of file XmlController.cxx.

References XmlController::getViews(), XmlController::m_view_factory, XmlController::m_views, and XmlController::m_xml_doc.

QtXMLController * instance (  )  [static]

Returns the pointer to the singleton instance.

Definition at line 27 of file QtXMLController.cxx.

References QtXMLController::QtXMLController(), and QtXMLController::s_instance.

Referenced by CanvasWindow::CanvasWindow(), CanvasView::saveAs(), and CanvasWindow::updateActions().

bool isPasteboardEmpty (  )  [inherited]

Returns true if global pasteboard is empty.

Definition at line 159 of file XmlController.cxx.

References XmlController::m_pasteboard.

void newDocument ( const std::string &  name  )  [protected, virtual]

Creates a new document.

A derived class should set the member m_xml_doc to point to a concrete class derived from the abstract class XmlDocument.

Implements XmlController.

Definition at line 46 of file QtXMLController.cxx.

References XmlController::m_xml_doc.

XmlController::Status openFile ( const std::string &  filename  )  [inherited]

Attempts to open and parse the specified HippoDraw document.

Returns Success if successful, otherwise returns another member of the OpenStatus enumeration.

Definition at line 90 of file XmlController.cxx.

References XmlController::m_tuple_cut_map, XmlController::m_tuple_map, XmlController::m_views, XmlController::openDocument(), XmlController::openNTuples(), and XmlController::Success.

Referenced by CanvasView::initFromFile().

XmlController::Status openUpdatedNTuples (  )  [virtual, inherited]

Open the missing tuples updated by GUI.

Definition at line 135 of file XmlController.cxx.

References HiNTupleXML::getObject(), XmlController::m_missing_ids, XmlController::m_missing_tuples, XmlController::m_ntuple, XmlController::m_tuple_map, XmlController::NTupleError, and XmlController::Success.

Referenced by CanvasView::initFromFile().

void registerPlotter ( int  id,
PlotterBase plotter 
) [inherited]

Registers the plotter with id.

Definition at line 400 of file XmlController.cxx.

References XmlController::m_plotter_map.

XmlController::Status saveToFile ( const std::vector< const ViewBase * > &  views,
const std::string &  filename 
) [inherited]

Saves the document represented by list of ViewBase objects to file with name filename.

Returns 0 if successful.

Definition at line 286 of file XmlController.cxx.

References XmlController::clearDataSourceMap(), XmlController::m_addr_map, XmlController::m_xml_doc, XmlController::OpenError, XmlDocument::saveToFile(), XmlController::serializeViews(), XmlController::Success, and XmlDocument::Success.

Referenced by CanvasView::saveAs().

void saveToPasteboard ( const std::vector< const ViewBase * > &   )  [inherited]

Saves the document represented by the list of ViewBase objects to the pasteboard.

If any ViewBase objects in allviews is an Observer of selviews, then save it as well. Returns the list of ViewBase objects actually saved to pasteboard.

Definition at line 266 of file XmlController.cxx.

References XmlController::m_pasteboard, XmlController::m_xml_doc, and XmlController::saveToDocument().

Referenced by CanvasView::copySelectedToPasteboard(), and CanvasView::deleteSelected().

void saveToSelectionCopy ( const std::vector< const ViewBase * > &  views  )  [inherited]

Saves the document represented by the list of ViewBase objects to the selection copy.

If any ViewBase objects in allviews is an Observer of selviews, then save it as well. Returns the list of ViewBase objects actually saved to pasteboard.

Definition at line 276 of file XmlController.cxx.

References XmlController::m_selectboard, XmlController::m_xml_doc, and XmlController::saveToDocument().

Referenced by CanvasView::contentsMousePressEvent().

bool serializeViews ( const std::vector< const ViewBase * > &  views  )  [virtual, inherited]

Serializes the ViewBase objects in views and their appropriate subcomponents.

Returns true if successful, otherwise returns false.

Definition at line 231 of file XmlController.cxx.

References XmlController::addViews(), XmlController::createDocument(), and XmlController::m_xml_doc.

Referenced by XmlController::saveToDocument(), and XmlController::saveToFile().


Member Data Documentation

XmlDocument * m_xml_doc = 0 [static, inherited]

The current document being generated or read.

This member is made public so that element creator that need it do not need to have it passed as argument.

Definition at line 194 of file XmlController.h.

Referenced by XmlController::addDataSource(), XmlController::addViews(), NTupleProjectorXML::createChildren(), NTupleXML::createChildren2D(), NTupleXML::createChildren3D(), PlotterBaseXML::createCutChildren(), XmlController::createDocument(), TupleCutXML::createElement(), BinToColorXML::createElement(), BaseXML::createElement(), DataRepXML::createFunctionTargetChild(), PlotterBaseXML::createTextChildren(), XmlController::getDataReps(), XmlController::getFromPasteboard(), XmlController::getFromSelectionCopy(), XmlController::getTupleCuts(), XmlController::getViews(), QtXMLController::newDocument(), XmlController::openDocument(), XmlController::openNTuples(), XmlController::saveToFile(), XmlController::saveToPasteboard(), XmlController::saveToSelectionCopy(), and XmlController::serializeViews().

QtXMLController * s_instance = 0 [static, private]

The pointer to the singleton object.

Definition at line 44 of file QtXMLController.h.

Referenced by QtXMLController::instance().


The documentation for this class was generated from the following files:
Generated for HippoDraw Class Library by doxygen