Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

QtXMLController Class Reference

#include <QtXMLController.h>

Inheritance diagram for QtXMLController:

Inheritance graph
[legend]
Collaboration diagram for QtXMLController:

Collaboration graph
[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 36 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 curent 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 eturns 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 selcection copy.
int getId (const void *address)
 Returns the unique integer identifier for given address.
PlotterBasegetPlotter (int ref)
 Returns a pointer to the PlotterBase object from the XML referend 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.
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 XmlController::Status [inherited]
 

Return codes of opening file.

Enumerator:
Success 
OpenError 
ParseError 
NTupleError 

Definition at line 58 of file XmlController.h.


Constructor & Destructor Documentation

QtXMLController::QtXMLController const QtXMLController  )  [private]
 

A private copy constructor in order to avoid copying.

QtXMLController::QtXMLController  )  [protected]
 

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

Definition at line 21 of file QtXMLController.cxx.

Referenced by instance().


Member Function Documentation

XmlElement * XmlController::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 282 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 XmlController::addViews const std::vector< const ViewBase * > &  views  )  [inherited]
 

Adds ViewBase elements to the root of the document.

Definition at line 255 of file XmlController.cxx.

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

Referenced by XmlController::serializeViews().

bool XmlController::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 180 of file XmlController.cxx.

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

Referenced by CanvasWindow::areDataSourcesSaved().

PlotterBase* XmlController::createDisplay  )  [inherited]
 

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

void XmlController::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 60 of file XmlController.cxx.

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

Referenced by XmlController::serializeViews().

FontBase * XmlController::createFont  )  const [inherited]
 

Creates a empty QtFont object.

Definition at line 277 of file XmlController.cxx.

References XmlController::m_view_factory.

ViewBase * XmlController::createView PlotterBase  )  [inherited]
 

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

Definition at line 267 of file XmlController.cxx.

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

Referenced by ViewBaseXML::getObjects().

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

Returns true if the specified file exists.

Implements XmlController.

Definition at line 35 of file QtXMLController.cxx.

References QFile::exists().

DataRep * XmlController::getDataRep int  ref  )  [inherited]
 

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

Definition at line 327 of file XmlController.cxx.

References XmlController::m_datarep_map.

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

const DataSource * XmlController::getDataSource int  ref_id  )  [inherited]
 

Returns pointer to data source from the xml reference ID.

Definition at line 299 of file XmlController.cxx.

References XmlController::m_tuple_map.

Referenced by DataRepXML::createDataRep().

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

Creates and eturns 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 133 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 * > & XmlController::getFromSelectionCopy ViewFactory factory,
const std::vector< const ViewBase * > &  views
[inherited]
 

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

See also:
getFromPasteboard.

Definition at line 143 of file XmlController.cxx.

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

Referenced by CanvasView::restoreFromSelectCopy().

int XmlController::getId const void *  address  )  [inherited]
 

Returns the unique integer identifier for given address.

Definition at line 467 of file XmlController.cxx.

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

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

PlotterBase * XmlController::getPlotter int  ref  )  [inherited]
 

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

Definition at line 339 of file XmlController.cxx.

References XmlController::m_plotter_map.

const TupleCut * XmlController::getTupleCut int  ref_id  )  [inherited]
 

Returns pointer to the TupleCut from the xml reference Id.

Definition at line 310 of file XmlController.cxx.

References XmlController::m_tuple_cut_map.

Referenced by NTupleProjectorXML::addCuts(), and PlotterBaseXML::handleCutPlotter().

const list< ViewBase * > & XmlController::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 169 of file XmlController.cxx.

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

QtXMLController * QtXMLController::instance  )  [static]
 

Returns the pointer to the singleton instance.

Definition at line 25 of file QtXMLController.cxx.

References QtXMLController(), and s_instance.

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

bool XmlController::isPasteboardEmpty  )  [inherited]
 

Returns true if global pasteboard is empty.

Definition at line 126 of file XmlController.cxx.

References XmlController::m_pasteboard.

void QtXMLController::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 44 of file QtXMLController.cxx.

References XmlController::m_xml_doc.

XmlController::Status XmlController::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 83 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().

void XmlController::registerPlotter int  id,
PlotterBase plotter
[inherited]
 

Registers the plotter with id.

Definition at line 351 of file XmlController.cxx.

References XmlController::m_plotter_map.

XmlController::Status XmlController::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 240 of file XmlController.cxx.

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

Referenced by CanvasView::saveAs().

void XmlController::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 220 of file XmlController.cxx.

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

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

void XmlController::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 230 of file XmlController.cxx.

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

Referenced by CanvasView::contentsMousePressEvent().

bool XmlController::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 198 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 * XmlController::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 39 of file XmlController.cxx.

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(), newDocument(), XmlController::openDocument(), XmlController::openNTuples(), XmlController::saveToFile(), XmlController::saveToPasteboard(), XmlController::saveToSelectionCopy(), and XmlController::serializeViews().

QtXMLController * QtXMLController::s_instance = 0 [static, private]
 

The pointer to the singleton object.

Definition at line 19 of file QtXMLController.cxx.

Referenced by instance().


The documentation for this class was generated from the following files:
Generated for HippoDraw-1.14.8.5 by doxygen 1.4.3