00001 // Torc - Copyright 2011 University of Southern California. All Rights Reserved. 00002 // $HeadURL: https://svn.east.isi.edu/torc/trunk/src/torc/physical/Renamable.hpp $ 00003 // $Id: Renamable.hpp 489 2011-06-16 13:39:33Z nsteiner $ 00004 00005 // This program is free software: you can redistribute it and/or modify it under the terms of the 00006 // GNU General Public License as published by the Free Software Foundation, either version 3 of the 00007 // License, or (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 00010 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 00011 // the GNU General Public License for more details. 00012 // 00013 // You should have received a copy of the GNU General Public License along with this program. If 00014 // not, see <http://www.gnu.org/licenses/>. 00015 00016 /// \file 00017 /// \brief Header for the Renamable class. 00018 00019 #ifndef TORC_PHYSICAL_RENAMABLE_HPP 00020 #define TORC_PHYSICAL_RENAMABLE_HPP 00021 00022 #include "torc/physical/Named.hpp" 00023 #include <string> 00024 #include <boost/smart_ptr.hpp> 00025 00026 namespace torc { 00027 namespace physical { 00028 00029 // forward declarations 00030 00031 /// \brief Forward declaration of Progenitor template (a parent of the Renamable object). 00032 template <class T> class Progenitor; 00033 00034 /// \brief Concept for any object that can be renamed. 00035 // /// \details No support is provided at this level for renaming, because many subclasses may 00036 // /// may require oversight from their parent to avoid name collisions. 00037 // /// \todo Add a setName() accessor to support renaming. For many design elements, this may 00038 // /// require permission from the parent, to avoid name collisions. We could make the 00039 // /// function virtual, but that would come at the cost of a vtable, and that's very 00040 // /// expensive for things like Config objects. In general, the renaming should probably be 00041 // /// managed by the Progeny<T> template. 00042 template <class T> class Renamable : public Named { 00043 protected: 00044 // types 00045 /// \brief Imported type name. 00046 typedef std::string string; 00047 // friends 00048 /// \brief The Progenitor class has access to our internals. 00049 friend class Progenitor<T>; 00050 // accessors 00051 /// \brief Sets the object name. 00052 void setName(const string& inName) { mName = inName; } 00053 public: 00054 // constructors 00055 /// \brief Constructor which must specify the object name. 00056 /// \param inName The object name. 00057 Renamable(const string& inName) : Named(inName) {} 00058 }; 00059 00060 } // namespace physical 00061 } // namespace torc 00062 00063 #endif // TORC_PHYSICAL_RENAMABLE_HPP