#include <XmlController.h>
Inheritance diagram for XmlController:
It implements the application logic which should not be in the GUI. Following the template pattern, several pure virtual member functions must be implemented in a derived class to provide a concrete implementation. The derived class will probably use an extern XML C++ tool kit, while this class is independent of any XML implementation.
Definition at line 52 of file XmlController.h.
Public Types | |
enum | Status { Success, OpenError, ParseError, NTupleError } |
Return codes of opening file. More... | |
Public Member Functions | |
virtual XmlElement * | addDataSource (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. | |
PlotterBase * | createDisplay () |
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. | |
FontBase * | createFont () const |
Creates a empty QtFont object. | |
ViewBase * | createView (PlotterBase *) |
Creates a new view for the current PlotterBase object and adds it to the list of views. | |
virtual bool | fileExists (const std::string &filename) const =0 |
Returns true if the specified file exists. | |
DataRep * | getDataRep (int ref) |
Returns a pointer to the DataRep from the xml reference Id. | |
const DataSource * | getDataSource (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. | |
PlotterBase * | getPlotter (int ref) |
Returns a pointer to the PlotterBase object from the XML referend Id. | |
const TupleCut * | getTupleCut (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. | |
virtual | ~XmlController () |
The destructor. | |
Static Public Attributes | |
static XmlDocument * | m_xml_doc = 0 |
The current document being generated or read. | |
Protected Member Functions | |
XmlController () | |
A default constructor for avoiding creation except by itself or with derived classes. | |
Private Types | |
typedef std::map< const void *, int >::iterator | AddrMapIterator_t |
The iterator for memory address to unique integer identifier. | |
Private Member Functions | |
void | fillNTupleMap () |
Fills the NTuple map with NTuple objects currently in memory. | |
void | fillTupleCutMap (const std::vector< const ViewBase * > &views) |
Fills the TupleCut map with TupleCut objecs contained in one in the list of views. | |
void | getDataReps () |
Creates all the DataRep objects and fills the reference map. | |
const std::list< ViewBase * > & | getFromDocument (ViewFactory *facotry, const std::vector< const ViewBase * > &views) |
Restores the views in the current document. | |
void | getTupleCuts () |
Creates all the TupleCut objects and fills the reference map. | |
void | getViews (const XmlElement *root) |
Creates the ViewBase objects described in the root XML element. | |
virtual void | getViews () |
Deserializes the ViewBase objects. | |
virtual void | newDocument (const std::string &name)=0 |
Creates a new document. | |
virtual Status | openDocument (const std::string &filename) |
Opens an existing DOM Document file filename. | |
virtual Status | openNTuples () |
Attempts to open ntuple files in the current document and put them into the map. | |
void | saveToDocument (const std::vector< const ViewBase * > &selviews) |
Save the ViewBase objects in selview to a XML in memory document. | |
XmlController (const XmlController &) | |
A private copy constructor in order to avoid copying. | |
Private Attributes | |
std::map< const void *, int > | m_addr_map |
The map of memory address to unique integer identifier. | |
std::map< const DataSource *, XmlElement * > | m_data |
The map of ntuples to XmlElements for the current document. | |
std::map< int, DataRep * > | m_datarep_map |
A mapping from DataRep Id to created DataRep. | |
DataRepXML * | m_datarep_xml |
The singleton instance of the DataRepXML object. | |
XmlElement * | m_element |
The XmlElement object used to parse the DOM tree. | |
int | m_id |
The next integer identifier to be generated. | |
std::list< std::string > | m_missing_tuples |
HiNTupleXML * | m_ntuple |
The singleton instance of the XML handler for data source. | |
XmlDocument * | m_pasteboard |
The pasteboard object. | |
std::map< int, PlotterBase * > | m_plotter_map |
The mapping from PlotterBase Id to created PlotterBase. | |
XmlDocument * | m_selectboard |
A copy of a selection. | |
std::map< int, const TupleCut * > | m_tuple_cut_map |
A mapping from XML id to created TupleCut. | |
TupleCutXML * | m_tuple_cut_xml |
The singleton instance of the XML handler for TupleCut objects. | |
std::map< int, const DataSource * > | m_tuple_map |
A mapping from XML id to created ntuple. | |
ViewBaseXML * | m_view |
The singleton instance of a ViewBaseXML object. | |
ViewFactory * | m_view_factory |
The factory to be used for creating views. | |
std::list< ViewBase * > | m_views |
A list of reconstructoed views. |
|
The iterator for memory address to unique integer identifier.
Definition at line 104 of file XmlController.h. |
|
Return codes of opening file.
Definition at line 58 of file XmlController.h. |
|
A private copy constructor in order to avoid copying.
|
|
A default constructor for avoiding creation except by itself or with derived classes.
Definition at line 41 of file XmlController.cxx. References m_datarep_xml, m_ntuple, m_tuple_cut_xml, and m_view. |
|
The destructor.
Definition at line 52 of file XmlController.cxx. References m_pasteboard, and m_view. |
|
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(), m_data, m_ntuple, and m_xml_doc. Referenced by NTupleProjectorXML::createElement(). |
|
Adds ViewBase elements to the root of the document.
Definition at line 255 of file XmlController.cxx. References XmlNode::appendChild(), ViewBaseXML::createElement(), XmlDocument::documentElement(), m_view, and m_xml_doc. Referenced by serializeViews(). |
|
Returns
Definition at line 180 of file XmlController.cxx. References ViewBaseXML::areDataSourcesSaved(), and m_view. Referenced by CanvasWindow::areDataSourcesSaved(). |
|
Creates a new empty display and makes it the curent one.
|
|
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(), m_xml_doc, and newDocument(). Referenced by serializeViews(). |
|
Creates a empty QtFont object.
Definition at line 277 of file XmlController.cxx. References m_view_factory. |
|
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(), m_view_factory, and m_views. Referenced by ViewBaseXML::getObjects(). |
|
Returns
Implemented in QtXMLController. |
|
Fills the NTuple map with NTuple objects currently in memory.
Definition at line 358 of file XmlController.cxx. References DataSourceController::getDataSources(), getId(), DataSourceController::instance(), and m_tuple_map. Referenced by getFromDocument(). |
|
Fills the TupleCut map with TupleCut objecs contained in one in the list of views.
Definition at line 375 of file XmlController.cxx. References CutController::fillTupleCutList(), getId(), CutController::instance(), and m_tuple_cut_map. Referenced by getFromDocument(). |
|
Returns a pointer to the DataRep from the xml reference Id.
Definition at line 327 of file XmlController.cxx. References m_datarep_map. Referenced by DataRepXML::createObject(), PlotterBaseXML::getCutTargets(), PlotterBaseXML::getObject(), PlotterBaseXML::handleFunction(), and PlotterBaseXML::handleTextPlotter(). |
|
Creates all the DataRep objects and fills the reference map.
Definition at line 392 of file XmlController.cxx. References DataRepXML::createObject(), XmlDocument::documentElement(), BaseXML::fillNodeList(), XmlElement::getID(), m_datarep_map, m_datarep_xml, and m_xml_doc. Referenced by getViews(). |
|
Returns pointer to data source from the xml reference ID.
Definition at line 299 of file XmlController.cxx. References m_tuple_map. Referenced by DataRepXML::createDataRep(). |
|
Restores the views in the current document.
Definition at line 153 of file XmlController.cxx. References CutController::connectDataRep(), fillNTupleMap(), fillTupleCutMap(), getViews(), CutController::instance(), m_view_factory, and m_views. Referenced by getFromPasteboard(), and getFromSelectionCopy(). |
|
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 getFromDocument(), m_pasteboard, and m_xml_doc. Referenced by CanvasView::addFromPasteboard(), and CanvasView::copyFromPasteboard(). |
|
Creates and returns objects that were copied to the selcection copy.
Definition at line 143 of file XmlController.cxx. References getFromDocument(), m_selectboard, and m_xml_doc. Referenced by CanvasView::restoreFromSelectCopy(). |
|
Returns the unique integer identifier for given address.
Definition at line 467 of file XmlController.cxx. References m_addr_map, and m_id. Referenced by fillNTupleMap(), and fillTupleCutMap(). |
|
Returns a pointer to the PlotterBase object from the XML referend Id.
Definition at line 339 of file XmlController.cxx. References m_plotter_map. |
|
Returns pointer to the TupleCut from the xml reference Id.
Definition at line 310 of file XmlController.cxx. References m_tuple_cut_map. Referenced by NTupleProjectorXML::addCuts(), and PlotterBaseXML::handleCutPlotter(). |
|
Creates all the TupleCut objects and fills the reference map.
Definition at line 414 of file XmlController.cxx. References XmlDocument::documentElement(), BaseXML::fillNodeList(), TupleCutXML::getObject(), m_tuple_cut_map, m_tuple_cut_xml, and m_xml_doc. Referenced by getViews(). |
|
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 getViews(), m_view_factory, m_views, and m_xml_doc. |
|
Creates the ViewBase objects described in the root XML element.
|
|
Deserializes the ViewBase objects.
Definition at line 442 of file XmlController.cxx. References XmlDocument::documentElement(), BaseXML::fillNodeList(), getDataReps(), ViewBaseXML::getObjects(), getTupleCuts(), m_view, m_views, and m_xml_doc. Referenced by getFromDocument(), getViews(), and CanvasView::initFromFile(). |
|
Returns
Definition at line 126 of file XmlController.cxx. References m_pasteboard. |
|
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. Implemented in QtXMLController. Referenced by createDocument(), and openDocument(). |
|
Opens an existing DOM Document file filename. The application's current directory will be set to the path to the file.
Definition at line 70 of file XmlController.cxx. References m_xml_doc, newDocument(), OpenError, XmlDocument::OpenError, ParseError, XmlDocument::ParseError, XmlDocument::setContent(), and Success. Referenced by openFile(). |
|
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 m_tuple_cut_map, m_tuple_map, m_views, openDocument(), openNTuples(), and Success. Referenced by CanvasView::initFromFile(). |
|
Attempts to open ntuple files in the current document and put them into the map. Returns Success if successful, otherwise returns NTupleError. Definition at line 97 of file XmlController.cxx. References XmlDocument::documentElement(), BaseXML::fillNodeList(), XmlElement::getID(), HiNTupleXML::getName(), HiNTupleXML::getObject(), m_missing_tuples, m_ntuple, m_tuple_map, m_xml_doc, NTupleError, and Success. Referenced by openFile(). |
|
Registers the plotter with id.
Definition at line 351 of file XmlController.cxx. References m_plotter_map. |
|
Save the ViewBase objects in selview to a XML in memory document. If an ViewBase objects in allviews is an Observer of of one in selviews, then save it as well. Definition at line 211 of file XmlController.cxx. References m_data, and serializeViews(). Referenced by saveToPasteboard(), and saveToSelectionCopy(). |
|
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 m_data, m_xml_doc, OpenError, XmlDocument::saveToFile(), serializeViews(), Success, and XmlDocument::Success. Referenced by CanvasView::saveAs(). |
|
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 m_pasteboard, m_xml_doc, and saveToDocument(). Referenced by CanvasView::copySelectedToPasteboard(), and CanvasView::deleteSelected(). |
|
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 m_selectboard, m_xml_doc, and saveToDocument(). Referenced by CanvasView::contentsMousePressEvent(). |
|
Serializes the ViewBase objects in views and their appropriate subcomponents.
Returns Definition at line 198 of file XmlController.cxx. References addViews(), createDocument(), and m_xml_doc. Referenced by saveToDocument(), and saveToFile(). |
|
The map of memory address to unique integer identifier.
Definition at line 100 of file XmlController.h. Referenced by getId(). |
|
The map of ntuples to XmlElements for the current document.
Definition at line 96 of file XmlController.h. Referenced by addDataSource(), saveToDocument(), and saveToFile(). |
|
A mapping from DataRep Id to created DataRep.
Definition at line 117 of file XmlController.h. Referenced by getDataRep(), and getDataReps(). |
|
The singleton instance of the DataRepXML object.
Definition at line 126 of file XmlController.h. Referenced by getDataReps(), and XmlController(). |
|
The XmlElement object used to parse the DOM tree.
Definition at line 135 of file XmlController.h. |
|
The next integer identifier to be generated.
Definition at line 108 of file XmlController.h. Referenced by getId(). |
|
Definition at line 67 of file XmlController.h. Referenced by openNTuples(). |
|
The singleton instance of the XML handler for data source.
Definition at line 129 of file XmlController.h. Referenced by addDataSource(), openNTuples(), and XmlController(). |
|
The pasteboard object.
Definition at line 87 of file XmlController.h. Referenced by getFromPasteboard(), isPasteboardEmpty(), saveToPasteboard(), and ~XmlController(). |
|
The mapping from PlotterBase Id to created PlotterBase.
Definition at line 120 of file XmlController.h. Referenced by getPlotter(), and registerPlotter(). |
|
A copy of a selection.
Definition at line 90 of file XmlController.h. Referenced by getFromSelectionCopy(), and saveToSelectionCopy(). |
|
A mapping from XML id to created TupleCut.
Definition at line 114 of file XmlController.h. Referenced by fillTupleCutMap(), getTupleCut(), getTupleCuts(), and openFile(). |
|
The singleton instance of the XML handler for TupleCut objects.
Definition at line 132 of file XmlController.h. Referenced by getTupleCuts(), and XmlController(). |
|
A mapping from XML id to created ntuple.
Definition at line 111 of file XmlController.h. Referenced by fillNTupleMap(), getDataSource(), openFile(), and openNTuples(). |
|
The singleton instance of a ViewBaseXML object.
Definition at line 123 of file XmlController.h. Referenced by addViews(), areDataSourcesSaved(), getViews(), XmlController(), and ~XmlController(). |
|
The factory to be used for creating views.
Definition at line 63 of file XmlController.h. Referenced by createFont(), createView(), getFromDocument(), and getViews(). |
|
A list of reconstructoed views.
Definition at line 93 of file XmlController.h. Referenced by createView(), getFromDocument(), getViews(), and openFile(). |
|
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 addDataSource(), addViews(), NTupleProjectorXML::createChildren(), NTupleXML::createChildren2D(), NTupleXML::createChildren3D(), PlotterBaseXML::createCutChildren(), createDocument(), TupleCutXML::createElement(), BinToColorXML::createElement(), BaseXML::createElement(), DataRepXML::createFunctionTargetChild(), PlotterBaseXML::createTextChildren(), getDataReps(), getFromPasteboard(), getFromSelectionCopy(), getTupleCuts(), getViews(), QtXMLController::newDocument(), openDocument(), openNTuples(), saveToFile(), saveToPasteboard(), saveToSelectionCopy(), and serializeViews(). |