torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Component.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_PACKER_COMPONENT_HPP
17 #define TORC_PACKER_COMPONENT_HPP
18 
19 #include "torc/physical/Named.hpp"
23 
24 #include <string>
25 
26 namespace torc {
27 namespace physical {
28 
29  /// \brief Hierarchical componenet.
30  class Component : public Named, public Progeny<class Component>,
31  protected Progenitor<class Component> {
32  protected:
35 
36  /// \brief Protected constructor.
37  Component(const string& inName) : Named(inName), Progenitor<class Component>(){}
38  public:
39  typedef PrimitivePinSharedPtrVector::const_iterator PrimitivePinSharedPtrConstIterator;
40  typedef PrimitivePinSharedPtrVector::iterator PrimitivePinSharedPtrIterator;
41  // PrimitivePin iterators
42  size_t getPrimitivePinCount(void) const { return mPrimitivePins.size(); }
47  // PrimitivePin population
48  bool addPrimitivePin(PrimitivePinSharedPtr& inPrimitivePinPtr) {
49  /// \todo Acquire mutex.
51  PrimitivePinSharedPtrIterator result = std::find(PrimitivePinsEnd(), e, inPrimitivePinPtr);
52  if(result != e) return false;
53  mPrimitivePins.push_back(inPrimitivePinPtr);
54  return true;
55  /// \todo Release mutex.
56  }
57  bool removePrimitivePin(PrimitivePinSharedPtr& inPrimitivePinPtr) {
58  /// \todo Acquire mutex.
60  PrimitivePinSharedPtrIterator result = std::find(PrimitivePinsBegin(), e, inPrimitivePinPtr);
61  if(result == e) return false;
62  mPrimitivePins.erase(result);
63  /// \todo Release mutex.
64  return true;
65  }
67  NameComparator predicate(inName);
68  return std::find_if(PrimitivePinsBegin(), PrimitivePinsEnd(), predicate);
69  }
70  // operators
71  bool operator ==(const Component& rhs) const { return mName == rhs.mName; }
72 
73  };
74 
75  /// \brief Shared pointer encapsulation of a componenet
76  typedef boost::shared_ptr<Component> ComponentSharedPtr;
77 
78  /// \brief Weak pointer encapsulation of a componenet
79  typedef boost::weak_ptr<Component> ComponentWeakPtr;
80 
81  /// \brief Vector of componenet shared pointers.
82  typedef std::vector<ComponentSharedPtr> ComponentSharedPtrVector;
83 
84 } // namespace physical
85 } // namespace torc
86 
87 #endif // TORC_PACKER_COMPONENT_HPP
std::vector< ComponentSharedPtr > ComponentSharedPtrVector
Vector of componenet shared pointers.
Definition: Component.hpp:82
bool operator==(const Component &rhs) const
Definition: Component.hpp:71
bool removePrimitivePin(PrimitivePinSharedPtr &inPrimitivePinPtr)
Definition: Component.hpp:57
bool addPrimitivePin(PrimitivePinSharedPtr &inPrimitivePinPtr)
Definition: Component.hpp:48
string mName
The name of the object.
Definition: Named.hpp:43
boost::weak_ptr< Component > ComponentWeakPtr
Weak pointer encapsulation of a componenet.
Definition: Component.hpp:79
PrimitivePinSharedPtrIterator PrimitivePinsEnd(void)
Definition: Component.hpp:46
PrimitivePinSharedPtrIterator findPrimitivePin(const string &inName)
Definition: Component.hpp:66
Concept for any object that can be named.
Definition: Named.hpp:36
std::string string
size_t getPrimitivePinCount(void) const
Definition: Component.hpp:42
Header for the Progenitor class.
Comparator class to serve as a predicate when searching for names.
Definition: Named.hpp:61
PrimitivePinSharedPtrVector::iterator PrimitivePinSharedPtrIterator
Definition: Component.hpp:40
Header for the Named class.
boost::shared_ptr< Component > ComponentSharedPtr
Shared pointer encapsulation of a componenet.
Definition: Component.hpp:76
PrimitivePinSharedPtrIterator PrimitivePinsBegin(void)
Definition: Component.hpp:45
PrimitivePinSharedPtrVector mPrimitivePins
Definition: Component.hpp:34
Concept for any object that may have children.
Definition: Progenitor.hpp:36
Concept for any object that may have a parent.
Definition: Progeny.hpp:29
Hierarchical componenet.
Definition: Component.hpp:30
Header for the Progeny class.
Component(const string &inName)
Protected constructor.
Definition: Component.hpp:37
PrimitivePinSharedPtrVector::const_iterator PrimitivePinSharedPtrConstIterator
Definition: Component.hpp:39
boost::shared_ptr< PrimitivePin > PrimitivePinSharedPtr
Shared pointer encapsulation of a componenet.
std::vector< PrimitivePinSharedPtr > PrimitivePinSharedPtrVector
Vector of componenet shared pointers.
PrimitivePinSharedPtrConstIterator PrimitivePinsEnd(void) const
Definition: Component.hpp:44
PrimitivePinSharedPtrConstIterator PrimitivePinsBegin(void) const
Definition: Component.hpp:43