torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Scalar.hpp
Go to the documentation of this file.
1 // Torc - Copyright 2011-2013 University of Southern California. All Rights Reserved.
2 // $HeadURL$
3 // $Id$
4 
5 // This program is free software: you can redistribute it and/or modify it under the terms of the
6 // GNU General Public License as published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
11 // the GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License along with this program. If
14 // not, see <http://www.gnu.org/licenses/>.
15 
16 #ifndef TORC_GENERIC_SCALAR_HPP
17 #define TORC_GENERIC_SCALAR_HPP
18 
19 #include <vector>
20 
21 #ifdef GENOM_SERIALIZATION
22 #include <boost/serialization/access.hpp>
23 #endif //GENOM_SERIALIZATION
26 #include "torc/generic/Error.hpp"
27 
28 namespace torc {
29 namespace generic {
30 
31 /**
32  * @brief A single object with no child objects
33  */
34 template <typename _Type> class Scalar : virtual public Composite<_Type> {
35 #ifdef GENOM_SERIALIZATION
36  friend class boost::serialization::access;
37 #endif //GENOM_SERIALIZATION
38 public:
39  typedef typename Composite<_Type>::Type Type;
41  typedef typename Composite<_Type>::List List;
43 
44  virtual ~Scalar() throw ();
45 
46  /**
47  * Get composition type for this object
48  *
49  * @return The CompositionType inSource eCompositionTypeScalar is returned
50  */
51  virtual CompositionType
52  getCompositionType() const;
53 
54  /**
55  * Get the total number of bits of the composition
56  * @return Number of bits
57  */
58  virtual SizeType getSize() const;
59 
60  /**
61  * Get a specific member of this composition.
62  *
63  * @param[in] indices A list of indices to be accessed. The number of indices must be equal to
64  * the number of dimensions.
65  *
66  * @return An empty pointer is returned
67  */
68  virtual const Pointer get(const std::vector<SizeType>& indices) const throw (Error);
69 
70  /**
71  * Get children of this composition.
72  * @param[out] outChildren A list of all children for this composition
73  * @note This wil return empty list for scalar
74  */
75  virtual void getChildren(List& outChildren) const throw (Error);
76 
77 protected:
78  Scalar();
79 
80 private:
81 #ifdef GENOM_SERIALIZATION
82  template <class Archive> void serialize(Archive& ar, unsigned int);
83 #endif //GENOM_SERIALIZATION
84  Scalar(const Scalar<_Type>& source);
85  Scalar<_Type>& operator=(const Scalar<_Type>& source);
86 };
87 
88 template <typename _Type> Scalar<_Type>::~Scalar() throw () {}
89 
90 /**
91  * Get composition type for this object
92  *
93  * @return The CompositionType inSource eCompositionTypeScalar is returned
94  */
95 template <typename _Type> CompositionType Scalar<_Type>::getCompositionType() const {
97 }
98 
99 /**
100  * Get the total number of bits of the composition
101  * @return Number of bits
102  */
103 template <typename _Type> typename Scalar<_Type>::SizeType Scalar<_Type>::getSize() const {
104  return 1;
105 }
106 
107 /**
108  * Get a specific member of this composition.
109  *
110  * @param[in] indices A list of indices to be accessed. The number of indices must be equal to the
111  * number of dimensions.
112  *
113  * @return An empty pointer is returned
114  */
115 template <typename _Type> const typename Scalar<_Type>::Pointer Scalar<_Type>::get(
116  const std::vector<typename Scalar<_Type>::SizeType>& indices) const throw (Error) {
117  return Pointer();
118 }
119 
120 /**
121  * Get children of this composition.
122  *
123  * @param[out] outChildren A list of all children for this composition
124  */
125 template <typename _Type> void Scalar<_Type>::getChildren(
126  typename Scalar<_Type>::List& outChildren) const throw (Error) {
127  return;
128 }
129 
130 template <typename _Type> Scalar<_Type>::Scalar() : Composite<_Type>() {}
131 
132 #ifdef GENOM_SERIALIZATION
133 template <typename _Type> template <class Archive> void Scalar<_Type>::serialize( Archive& ar,
134  unsigned int ) {
135  //NOTHING TO DUMP
136 }
137 #endif //GENOM_SERIALIZATION
138 
139 } // namespace generic
140 } // namespace torc
141 
142 #endif // TORC_GENERIC_SCALAR_HPP
Composite< _Type >::Type Type
Definition: Scalar.hpp:39
Composite< _Type >::SizeType SizeType
Definition: Scalar.hpp:42
A single object with no child objects.
Definition: Scalar.hpp:34
Scalar< _Type > & operator=(const Scalar< _Type > &source)
Interface for objects that can be composed within each other.
Definition: Composite.hpp:45
Composite< _Type >::Pointer Pointer
Definition: Scalar.hpp:40
boost::shared_ptr< Type > Pointer
Definition: Composite.hpp:55
CompositionType
Defines possible Composition types.
The Error object thrown by different methods of EdifOM.
Definition: Error.hpp:41
virtual const Pointer get(const std::vector< SizeType > &indices) const
Definition: Scalar.hpp:115
Contains definition for CompositionType.
virtual CompositionType getCompositionType() const
Definition: Scalar.hpp:95
virtual void getChildren(List &outChildren) const
Definition: Scalar.hpp:125
virtual SizeType getSize() const
Definition: Scalar.hpp:103
virtual ~Scalar()
Definition: Scalar.hpp:88
Composite< _Type >::List List
Definition: Scalar.hpp:41
std::vector< Pointer > List
Definition: Composite.hpp:61