00001 // Torc - Copyright 2011 University of Southern California. All Rights Reserved. 00002 // $HeadURL: https://torc-isi.svn.sourceforge.net/svnroot/torc-isi/branches/staging/0.9/src/torc/common/Annotated.hpp $ 00003 // $Id: Annotated.hpp 10 2011-10-12 18:40:16Z 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 Annotated class. 00018 00019 #ifndef TORC_COMMON_ANNOTATED_HPP 00020 #define TORC_COMMON_ANNOTATED_HPP 00021 00022 #include <boost/unordered_map.hpp> 00023 #include <boost/any.hpp> 00024 00025 namespace torc { 00026 namespace common { 00027 00028 /// \brief Concept for any object that can be annotated. 00029 class Annotated { 00030 typedef boost::uint32_t uint32; 00031 protected: 00032 // members 00033 /// \brief Map containing any annotations. 00034 boost::unordered_map<boost::uint32_t, boost::any> mAnnotations; 00035 00036 public: 00037 // constructors 00038 /// \brief Default constructor containing no annotations. 00039 Annotated() {} 00040 /// \brief Destructor. 00041 ~Annotated() {} 00042 // accessors 00043 /// \brief Get an annotation. 00044 /// \detail Returns an empty annotation if the index doesn't exist. 00045 boost::any getAnnotation(uint32 inKey) { return mAnnotations[inKey]; } 00046 /// \brief Set an annotation. 00047 void setAnnotation(uint32 inKey, boost::any inValue) { mAnnotations[inKey] = inValue; } 00048 /// \brief Remove an annotation. 00049 void removeAnnotation(uint32 inKey) { mAnnotations.erase(inKey); } 00050 /// \brief Check if an annotation exists. 00051 bool hasAnnotation(uint32 inKey) { 00052 return (mAnnotations.find(inKey) != mAnnotations.end()); 00053 } 00054 00055 // enums 00056 /// \brief Enumeration for all types of annotations. 00057 enum EAnnotationType { 00058 ePlacerInstanceTypeIndex, 00059 ePlacerInstanceSitePtr, 00060 ePlacerInstanceCollection, 00061 eRouterNetTilewireSources, 00062 eRouterNetTilewireSinks, 00063 eRouterNetArcList, 00064 eRouterNetRouteNodePtrVector, 00065 eRouterNetRouteTime, 00066 eRouterNetArcVector, 00067 eAnnotationGlobalRouter, 00068 eAnnotationCount 00069 }; 00070 }; 00071 00072 } // namespace common 00073 } // namespace torc 00074 00075 #endif // TORC_COMMON_ANNOTATED_HPP