torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Status.cpp
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 #include "torc/generic/Status.hpp"
17 
18 namespace torc {
19 namespace generic {
20 
21 /**
22  * Create a status.
23  *
24  * @param[in] inContainer Pointer of the status container.
25  *
26  * @return Pointer to created status.
27  */
29  throw (Error) {
30  try {
31  StatusSharedPtr newStatus;
32  create(newStatus);
33  inContainer->addStatus(newStatus);
34  return newStatus;
35  } catch(Error& e) {
36  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
37  throw;
38  }
39 }
40 
42  mWrittens() {}
43 
44 Status::~Status() throw () {}
45 
46 /**
47  * Set the vector of written statements.
48  *
49  * @param[in] inSource Vector containing written statements
50  */
51 void Status::setWrittens(const std::vector<WrittenSharedPtr>& inSource) {
52  std::vector<WrittenSharedPtr>::const_iterator it = inSource.begin();
53  for(; it != inSource.end(); it++) {
54  mWrittens.push_back(*it);
55  }
56 }
57 
58 /**
59  * Add a written statement to the vector of written statements.
60  * If an empty pointer is supplied, it returns without doing anything.
61  *
62  * @param[in] inWritten A pointer to a written object.
63  *
64  * @exception Error Written could not be added.
65  */
66 void Status::addWritten(WrittenSharedPtr& inWritten) throw (Error) {
67  mWrittens.push_back(inWritten);
68 }
69 
70 void Status::accept(BaseVisitor& visitor) throw (Error) {
71  try {
72  runVisitor(*this, visitor);
73  } catch(Error& e) {
74  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
75  throw;
76  }
77 }
78 
79 } // namespace generic
80 } // namespace torc
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 runVisitor(_Tp &inoutVisited, BaseVisitor &inoutVisitor)
Definition: VisitorType.hpp:78
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
Represents EDIF status construct.
Definition: Status.hpp:42
An object that receives an inoutVisitor.
Definition: Visitable.hpp:38
virtual ~Status()
Definition: Status.cpp:44
void setCurrentLocation(const std::string &inFunction, const std::string &inFile, uint32_t inLine)
Definition: Error.cpp:73