mt
 All Classes Files Functions Enumerations Groups Pages
object.h
1 /***************************************************************************
2  * Copyright (C) 2006 by Adolfo Rodriguez *
3  * adolfo.rodriguez@upc.edu *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
22 
23 // HEADER GUARD
24 #ifndef MT_OBJECT_H
25 #define MT_OBJECT_H
26 
27 // C++ STANDARD HEADERS
28 #include <iostream>
29 #include <string>
30 
31 // MT LIBRARY HEADERS
32 #include <mt/transform.h>
33 
34 
36 
37 namespace mt
38 {
39 
40 
42 
47 
48 class Object
49 {
50 public:
51 
52 // LIFECYCLE
53 
55  Object();
56 
58  Object(const Transform& origin,
59  const std::string& name);
60 
61  // Compiler generated copy constructor is being used
62 
63  // Compiler generated destructor is being used
64 
65 
66 // OPERATORS
67 
68  // Compiler generated assignment operator is being used
69 
70  bool operator==(const Object& obj) const;
71 
72  bool operator!=(const Object& obj) const;
73 
74 
75 // ACCESS
76 
78  Transform getOrigin() const;
79  Transform& getOriginRef();
80  const Transform& getOriginRef() const;
81 
83  std::string getName() const;
84  std::string& getNameRef();
85  const std::string& getNameRef() const;
86 
88  void setOrigin(const Transform& origin);
89 
91  void setName(const std::string& name);
92 
93 
94 private:
95 
96 // MEMBERS
97 
98  Transform m_origin;
99  std::string m_name;
100 
101 };
102 
104 
105 // OPERATORS
106 
107 std::ostream& operator<<(std::ostream& os,
108  const Object& obj);
109 
111 
112 // LIFECYCLE
113 
114 inline Object::Object() {}
115 
116 
117 inline Object::Object(const Transform& origin,
118  const std::string& name) :
119 
120  m_origin(origin),
121  m_name (name) {}
122 
123 
124 // OPERATORS
125 
126 inline bool Object::operator==(const Object& obj) const
127 {
128  return(m_origin == obj.getOrigin() &&
129  m_name == obj.getName());
130 }
131 
132 
133 inline bool Object::operator!=(const Object& obj) const
134 {
135  return !(*this == obj);
136 }
137 
138 
139 // ACCESS
140 
142 {
143  return m_origin;
144 }
145 
146 
147 inline Transform& Object::getOriginRef()
148 {
149  return m_origin;
150 }
151 
152 
153 inline const Transform& Object::getOriginRef() const
154 {
155  return m_origin;
156 }
157 
158 
159 inline std::string Object::getName() const
160 {
161  return m_name;
162 }
163 
164 
165 inline std::string& Object::getNameRef()
166 {
167  return m_name;
168 }
169 
170 
171 inline const std::string& Object::getNameRef() const
172 {
173  return m_name;
174 }
175 
176 
177 inline void Object::setOrigin(const Transform& origin)
178 {
179  m_origin = origin;
180 }
181 
182 
183 inline void Object::setName(const std::string& name)
184 {
185  m_name = name;
186 }
187 
188 
190 
191 inline std::ostream& operator<<(std::ostream& os,
192  const Object& obj)
193 {
194  return
195  os << "Object " << obj.getName() << " - origin:\n" << obj.getOrigin();
196 }
197 
198 } // mt
199 
200 #endif // MT_OBJECT_H