torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Commentable.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_COMMENTABLE_HPP
17 #define TORC_GENERIC_COMMENTABLE_HPP
18 
19 #include <string>
20 #include <vector>
21 
22 #ifdef GENOM_SERIALIZATION
23 #include <boost/serialization/access.hpp>
24 #include <boost/serialization/weak_ptr.hpp>
25 #endif //GENOM_SERIALIZATION
26 namespace torc {
27 namespace generic {
28 
29 /**
30  * @brief Represents all classes that can hold user comments
31  *
32  * The Commentable class holds a list of user comments that the users can modify. This class is
33  * inherited by all classes that can hold comments by user. Comments can be programatically
34  * inserted by clients or can be specified in edif files by <i>(comment "string1" ..)</i> syntax.
35  */
36 class Commentable {
37 #ifdef GENOM_SERIALIZATION
38  friend class boost::serialization::access;
39 #endif
40 
41 public:
42  /**
43  * Add a comment to the object
44  *
45  * @param[in] comment The comment to add to an existing list of comments
46  */
47  void addComment(const std::string& comment);
48 
49  /**
50  * Get the list of all comments
51  *
52  * @return A list of all comments on this object
53  */
54  inline const std::vector<std::string>& getComments() const;
55 
56  /**
57  * Get the list of all comments
58  *
59  * @param[in] inSource A list of all comments to be set on this object
60  */
61  void setComments(const std::vector<std::string>& inSource);
62 
63 protected:
64  Commentable();
65 
66 public:
67  virtual ~Commentable() throw ();
68 
69 private:
70 #ifdef GENOM_SERIALIZATION
71  template <class Archive> void serialize(Archive& ar, unsigned int);
72 #endif //GENOM_SERIALIZATION
73  Commentable(const Commentable& source);
74 
75  Commentable& operator=(const Commentable& source);
76 
77  std::vector<std::string> mComments;
78 };
79 
80 /**
81  * Get the list of all comments
82  *
83  * @return A list of all comments on this object
84  */
85 inline const std::vector<std::string>& Commentable::getComments() const {
86  return mComments;
87 }
88 
89 } // namespace generic
90 } // namespace torc
91 
92 #endif // TORC_GENERIC_COMMENTABLE_HPP
void addComment(const std::string &comment)
Definition: Commentable.cpp:36
Represents all classes that can hold user comments.
Definition: Commentable.hpp:36
std::string string
void setComments(const std::vector< std::string > &inSource)
Definition: Commentable.cpp:45
std::vector< std::string > mComments
Definition: Commentable.hpp:77
const std::vector< std::string > & getComments() const
Definition: Commentable.hpp:85
Commentable & operator=(const Commentable &source)