ome-xml  5.6.0
OMEModelObject.h
1 /*
2  * #%L
3  * OME-XML C++ library for working with OME-XML metadata structures.
4  * %%
5  * Copyright © 2006 - 2016 Open Microscopy Environment:
6  * - Massachusetts Institute of Technology
7  * - National Institutes of Health
8  * - University of Dundee
9  * - Board of Regents of the University of Wisconsin-Madison
10  * - Glencoe Software, Inc.
11  * %%
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions are met:
14  *
15  * 1. Redistributions of source code must retain the above copyright notice,
16  * this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright notice,
18  * this list of conditions and the following disclaimer in the documentation
19  * and/or other materials provided with the distribution.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  *
33  * The views and conclusions contained in the software and documentation are
34  * those of the authors and should not be interpreted as representing official
35  * policies, either expressed or implied, of any organization.
36  * #L%
37  */
38 
39 #ifndef OME_XML_MODEL_OMEMODELOBJECT_H
40 #define OME_XML_MODEL_OMEMODELOBJECT_H
41 
42 #include <algorithm>
43 #include <map>
44 #include <memory>
45 #include <string>
46 #include <vector>
47 
48 #include <boost/multi_index_container.hpp>
49 #include <boost/multi_index/identity.hpp>
50 #include <boost/multi_index/indexed_by.hpp>
51 #include <boost/multi_index/ordered_index.hpp>
52 #include <boost/multi_index/random_access_index.hpp>
53 
54 #include <ome/common/xml/dom/Element.h>
55 #include <ome/common/xml/dom/Document.h>
56 
57 namespace ome
58 {
59  namespace xml
60  {
61  namespace model
62  {
63 
64  class OMEModel;
65  class Reference;
66 
76  class OMEModelObject : public std::enable_shared_from_this<OMEModelObject>
77  {
78  protected:
83  template<typename T, template <typename ElementType> class Ptr>
85  {
87  typedef boost::multi_index_container<
88  Ptr<T>, // value type
89  boost::multi_index::indexed_by<
90  boost::multi_index::random_access<>, // insertion order
91  boost::multi_index::ordered_unique<boost::multi_index::identity<Ptr<T>>, std::owner_less<Ptr<T>>> // sorted order
92  >
93  > type;
94  };
95 
98  {}
99 
100  public:
102  virtual
104  {}
105 
113  virtual const std::string&
114  elementName() const = 0;
115 
128  virtual bool
129  validElementName(const std::string& name) const = 0;
130 
132  OMEModelObject (const OMEModelObject&) = delete;
133 
135  operator= (const OMEModelObject&) = delete;
137 
146  asXMLElement (common::xml::dom::Document& document) const = 0;
147 
157  virtual void
159  common::xml::dom::Element& element) const = 0;
160 
175  virtual void
176  update (const common::xml::dom::Element& element,
177  OMEModel& model) = 0;
178 
200  virtual bool
201  link (std::shared_ptr<Reference>& reference,
202  std::shared_ptr<OMEModelObject>& object) = 0;
203 
209  virtual const std::string&
210  getXMLNamespace() const = 0;
211  };
212 
213  }
214  }
215 }
216 
217 #endif // OME_XML_MODEL_OMEMODELOBJECT_H
218 
219 /*
220  * Local Variables:
221  * mode:C++
222  * End:
223  */
OME model interface (abstract top-level container)
Definition: OMEModel.h:61
virtual ~OMEModelObject()
Destructor.
Definition: OMEModelObject.h:103
OMEModelObject()
Constructor.
Definition: OMEModelObject.h:97
boost::multi_index_container< Ptr< T >, boost::multi_index::indexed_by< boost::multi_index::random_access<>, boost::multi_index::ordered_unique< boost::multi_index::identity< Ptr< T > >, std::owner_less< Ptr< T > > > > > type
Multi-index container type.
Definition: OMEModelObject.h:93
OME model object interface.
Definition: OMEModelObject.h:76
virtual void update(const common::xml::dom::Element &element, OMEModel &model)=0
Update the object hierarchy recursively from an XML DOM tree.
Multi-index container for efficient ordered insertion and deletion of model object references...
Definition: OMEModelObject.h:84
Open Microscopy Environment C++ implementation.
virtual const std::string & getXMLNamespace() const =0
Get the XML namespace for this model object.
virtual bool validElementName(const std::string &name) const =0
Check if a given element name is valid for processing by this model object.
virtual const std::string & elementName() const =0
Get the element name of this model object.
virtual bool link(std::shared_ptr< Reference > &reference, std::shared_ptr< OMEModelObject > &object)=0
Link a given OME model object to this model object.
virtual SKIP common::xml::dom::Element asXMLElement(common::xml::dom::Document &document) const =0
Transform the object hierarchy rooted at this element to XML.