torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Status.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_STATUS_HPP
17 #define TORC_GENERIC_STATUS_HPP
18 
19 #include <vector>
20 
27 #include "torc/generic/Error.hpp"
30 
31 namespace torc { namespace generic { class Written; } }
32 namespace torc { namespace generic { class BaseVisitor; } }
33 
34 namespace torc {
35 namespace generic {
36 
37 /**
38  * @brief Represents EDIF status construct
39  *
40  * Status is used to convey accounting and problem analysis information for the design.
41  */
42 class Status : public Commentable, public Visitable, public UserDataContainer,
43  public SelfReferencing<Status> {
44 
45  friend class FactoryType<Status> ;
46 
47 public:
48 
49  /**
50  * Convenience class to visit a status.
51  */
53 
54  /**
55  * Convenience class to create a status.
56  */
57  class Factory : public FactoryType<Status> {
58  public:
60  /**
61  * Create a status.
62  *
63  * @param[in] inContainer Pointer of the status container.
64  *
65  * @return Pointer to created status.
66  */
67  StatusSharedPtr virtual newStatusPtr(const StatusContainerSharedPtr& inContainer)
68  throw (Error);
69 
70  };
71 
72  virtual ~Status() throw ();
73 
74  /**
75  * Get the vector of written statements.
76  *
77  * @return vector Containing written statements
78  */
79  inline void getWrittens(std::vector<WrittenSharedPtr>& outValues) const;
80 
81  /**
82  * Set the vector of written statements.
83  *
84  * @param[in] inSource Vector containing written statements
85  */
86  void setWrittens(const std::vector<WrittenSharedPtr>& inSource);
87 
88  /**
89  * Add a written statement to the vector of written statements.
90  * If an empty pointer is supplied, it returns without doing anything.
91  *
92  * @param[in] inWritten A pointer to a written object.
93  *
94  * @exception Error Written could not be added.
95  */
96  void addWritten(WrittenSharedPtr& inWritten) throw (Error);
97 
98  /**
99  * Receive a visitor to this class. The visit method of the visitor is called
100  * and a reference to this object is passed as a parameter. It has to be noted however,
101  * that a dynamic_cast is performed inside this method. If the cast fails,
102  * an appropriate exception is thrown by this method. This situation can arise when
103  * the passed Visitor object does not inherit from the appropriate visitor specialization.
104  * See Visitor documentation for more details.
105  *
106  * @param[in,out] visitor A reference to the visitor object
107  * @exception Error Visitor type inappropriate for visiting this object
108  * or any other error thrown by the Visitor::throw() method.
109  */
110  virtual void accept(BaseVisitor& visitor) throw (Error);
111 
112 protected:
113  Status();
114 
115 private:
117 
118 };
119 
120 inline void Status::getWrittens(std::vector<WrittenSharedPtr>& outValues) const {
121  outValues.insert(outValues.end(), mWrittens.begin(), mWrittens.end());
122 }
123 
124 } // namespace generic
125 } // namespace torc
126 
127 #endif // TORC_GENERIC_STATUS_HPP
An acyclic inoutVisitor implementation.
Definition: VisitorType.hpp:57
boost::shared_ptr< StatusContainer > StatusContainerSharedPtr
std::vector< WrittenSharedPtr > mWrittens
Definition: Status.hpp:116
void setWrittens(const std::vector< WrittenSharedPtr > &inSource)
Definition: Status.cpp:51
Represents all classes that can hold user comments.
Definition: Commentable.hpp:36
boost::shared_ptr< Written > WrittenSharedPtr
Represents class that can hold userData.
void getWrittens(std::vector< WrittenSharedPtr > &outValues) const
Definition: Status.hpp:120
The Error object thrown by different methods of EdifOM.
Definition: Error.hpp:41
A base class for Visitor.
Definition: VisitorType.hpp:31
virtual void accept(BaseVisitor &visitor)
Definition: Status.cpp:70
virtual StatusSharedPtr newStatusPtr(const StatusContainerSharedPtr &inContainer)
Definition: Status.cpp:28
void addWritten(WrittenSharedPtr &inWritten)
Definition: Status.cpp:66
boost::shared_ptr< Status > StatusSharedPtr
A placeholder for a factory method.
Definition: FactoryType.hpp:35
Represents EDIF status construct.
Definition: Status.hpp:42
VisitorType< Status > Visitor
Definition: Status.hpp:52
An object that receives an inoutVisitor.
Definition: Visitable.hpp:38
virtual ~Status()
Definition: Status.cpp:44