torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Nameable.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_NAMEABLE_HPP
17 #define TORC_GENERIC_NAMEABLE_HPP
18 
19 //BOOST
20 #ifdef GENOM_SERIALIZATION
21 #include <boost/serialization/access.hpp>
22 #include <boost/serialization/weak_ptr.hpp>
23 #endif //GENOM_SERIALIZATION
24 #include "torc/generic/Error.hpp"
25 
26 namespace torc {
27 namespace generic {
28 
29 /**
30  * @brief An object that has a name
31  *
32  * The Nameable class provides an interface for and implements functionality that allows an object of a derivd class to have a string name.
33  */
34 class Nameable {
35 #ifdef GENOM_SERIALIZATION
36  friend class boost::serialization::access;
37 #endif
38 
39 protected:
40  explicit Nameable();
41 
42 public:
43  virtual ~Nameable() throw ();
44 
45 private:
46  Nameable(const Nameable& source);
47 
48  Nameable& operator=(const Nameable& source);
49 
50 public:
51  /**
52  * Get the object name
53  *
54  * @return Name of the object
55  */
56  inline virtual const std::string getName() const;
57 
58  /**
59  * Set a name for this object
60  *
61  * @param[in] inSource Name of the object
62  *
63  * @exception Error Could not set name, because name is empty (Will be used by array members)
64  * <ul>
65  * <li>
66  * Id : eMessageIdErrorEmptyItemName
67  * </li>
68  * <li> Context Data
69  * <ul>
70  * <li>Nameable - <i>String</i></li>
71  * </ul>
72  * </li>
73  * </ul>
74  */
75  void setName(const std::string& inSource) throw (Error);
76 
77 private:
78 #ifdef GENOM_SERIALIZATION
79  template <class Archive> void serialize(Archive& ar, unsigned int);
80 #endif //GENOM_SERIALIZATION
82 };
83 
84 /**
85  * Get the object name
86  *
87  * @return Name of the object
88  */
89 inline const std::string Nameable::getName() const {
90  return mName;
91 }
92 
93 } // namespace generic
94 } // namespace torc
95 
96 #endif // TORC_GENERIC_NAMEABLE_HPP
void setName(const std::string &inSource)
Definition: Nameable.cpp:41
Nameable & operator=(const Nameable &source)
std::string string
The Error object thrown by different methods of EdifOM.
Definition: Error.hpp:41
virtual const std::string getName() const
Definition: Nameable.hpp:89
An object that has a name.
Definition: Nameable.hpp:34