torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
physical/Renamable.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 /// \file
17 /// \brief Header for the Renamable class.
18 
19 #ifndef TORC_PHYSICAL_RENAMABLE_HPP
20 #define TORC_PHYSICAL_RENAMABLE_HPP
21 
22 #include "torc/physical/Named.hpp"
23 #include <string>
24 #include <boost/smart_ptr.hpp>
25 
26 namespace torc {
27 namespace physical {
28 
29  // forward declarations
30 
31  /// \brief Forward declaration of Progenitor template (a parent of the Renamable object).
32  template <class T> class Progenitor;
33 
34  /// \brief Concept for any object that can be renamed.
35 // /// \details No support is provided at this level for renaming, because many subclasses may
36 // /// may require oversight from their parent to avoid name collisions.
37 // /// \todo Add a setName() accessor to support renaming. For many design elements, this may
38 // /// require permission from the parent, to avoid name collisions. We could make the
39 // /// function virtual, but that would come at the cost of a vtable, and that's very
40 // /// expensive for things like Config objects. In general, the renaming should probably be
41 // /// managed by the Progeny<T> template.
42  template <class T> class Renamable : public Named {
43  protected:
44  // types
45  /// \brief Imported type name.
47  // friends
48  /// \brief The Progenitor class has access to our internals.
49  friend class Progenitor<T>;
50  // accessors
51  /// \brief Sets the object name.
52  void setName(const string& inName) { mName = inName; }
53  public:
54  // constructors
55  /// \brief Constructor which must specify the object name.
56  /// \param inName The object name.
57  Renamable(const string& inName) : Named(inName) {}
58  // accessors
59  /// \brief Illegally sets the object name.
60  /// \deprecated.
61  void deprecatedSetName(const string& inName) { mName = inName; }
62  };
63 
64 } // namespace physical
65 } // namespace torc
66 
67 #endif // TORC_PHYSICAL_RENAMABLE_HPP
std::string string
Imported type name.
void deprecatedSetName(const string &inName)
Illegally sets the object name.
string mName
The name of the object.
Definition: Named.hpp:43
Concept for any object that can be named.
Definition: Named.hpp:36
std::string string
Header for the Named class.
Concept for any object that may have children.
Definition: Progenitor.hpp:36
Concept for any object that can be renamed.
void setName(const string &inName)
Sets the object name.
Renamable(const string &inName)
Constructor which must specify the object name.