COPASI API  4.16.103
COutputHandler.h
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2014 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 // Copyright (C) 2004 - 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 #ifndef OUTPUT_HANDLER
16 #define OUTPUT_HANDLER
17 
18 #include <vector>
19 #include <set>
20 
21 class CCopasiObject;
22 class CCopasiContainer;
23 class CCopasiTask;
24 class Refresh;
25 class CCopasiDataModel;
26 
27 /**
28  * This is just the interface that is used to all output provided by COPASI.
29  */
31 {
32 public:
33  /**
34  * The output activity, indicating the status of the current operations
35  * performed by a task.
36  */
37  enum Activity
38  {
39  BEFORE = 0x01,
40  DURING = 0x02,
41  AFTER = 0x04
42  };
43 
44  /**
45  * Default constructor
46  */
48  mObjects()
49  {};
50 
51  /**
52  * Copy constructor
53  * @param const COutputInterface & src
54  */
56  mObjects(src.mObjects)
57  {};
58 
59  /**
60  * Destructor
61  */
62  virtual ~COutputInterface() {};
63 
64  /**
65  * compile the object list from name vector
66  * @param std::vector< CCopasiContainer * > listOfContainer
67  * @return bool success
68  */
69  virtual bool compile(std::vector< CCopasiContainer * > /* listOfContainer */, const CCopasiDataModel* /*pDataModel*/)
70  {return false;};
71 
72  /**
73  * Perform an output event for the current activity
74  * @param const Activity & activity
75  */
76  virtual void output(const Activity & /* activity */) {};
77 
78  /**
79  * Introduce an additional separator into the output
80  * @param const Activity & activity
81  */
82  virtual void separate(const Activity & /* activity */) {};
83 
84  /**
85  * Finish the output
86  */
87  virtual void finish() {};
88 
89  /**
90  * Close the stream if applicable
91  */
92  virtual void close() {};
93 
94  /**
95  * Retrieve the list of objects handled by the interface
96  * @return const std::set< const CCopasiObject * > & objects
97  */
98  virtual const std::set< const CCopasiObject * > & getObjects() const
99  {return mObjects;}
100 
101  // Attributes
102 protected:
103  /**
104  * All the objects which are output.
105  */
106  std::set< const CCopasiObject * > mObjects;
107 };
108 
109 /**
110  * This is the lass which drives all output of COPASI.
111  */
113 {
114  // Operations
115 
116 public:
117  /**
118  * Default Constructor
119  */
120  COutputHandler();
121 
122  /**
123  * Copy constructor
124  * @param const COutputInterface & src
125  */
126  COutputHandler(const COutputHandler & src);
127 
128  /**
129  * Destructor
130  */
131  virtual ~COutputHandler();
132 
133  /**
134  * compile the object list from name vector
135  * @param std::vector< CCopasiContainer * > listOfContainer
136  * @param const CCopasiDataModel* pDataModel
137  * @return bool success
138  */
139  virtual bool compile(std::vector< CCopasiContainer * > listOfContainer, const CCopasiDataModel* pDataModel);
140 
141  /**
142  * Perform an output event for the current activity
143  * @param const Activity & activity
144  */
145  virtual void output(const Activity & activity);
146 
147  /**
148  * Introduce an additional separator into the output
149  * @param const Activity & activity
150  */
151  virtual void separate(const Activity & activity);
152 
153  /**
154  * Finish the output
155  */
156  virtual void finish();
157 
158  /**
159  * Add an interface
160  * @param COutputInterface * pInterface;
161  */
162  virtual void addInterface(COutputInterface * pInterface);
163 
164  /**
165  * Remove an interface
166  * @param COutputInterface * pInterface;
167  */
168  virtual void removeInterface(COutputInterface * pInterface);
169 
170  /**
171  * Set whether the handler is the master handler
172  * @param COutputHandler * pMaster
173  */
174  void setMaster(COutputHandler * pMaster);
175 
176  /**
177  * Check whether the handler is a master
178  * @return bool isMaster
179  */
180  bool isMaster() const;
181 
182  std::set<COutputInterface *> getInterfaces() const;
183 
184 protected:
185  /**
186  * Refresh all objects
187  */
188  void refresh();
189 
190  /**
191  * Compile the object refresh list
192  * @param const std::vector< CCopasiContainer * > & listOfContainer
193  * @return bool success
194  */
195  bool compileRefresh(const std::vector< CCopasiContainer * > & listOfContainer, const CCopasiDataModel* pDataModel);
196 
197  // Attributes
198 protected:
199  /**
200  * A list of all active output interfaces.
201  */
202  std::set<COutputInterface *> mInterfaces;
203 
204  /**
205  * Points to the master handler. The master handler is responsible for the
206  * and object updates and all the output.
207  */
209 
210  /**
211  * An ordered list of refresh methods needed by the master
212  */
213  std::vector< Refresh * > mObjectRefreshes;
214 };
215 #endif
virtual void separate(const Activity &activity)
virtual ~COutputInterface()
std::vector< Refresh * > mObjectRefreshes
bool isMaster() const
virtual void removeInterface(COutputInterface *pInterface)
COutputInterface(const COutputInterface &src)
virtual const std::set< const CCopasiObject * > & getObjects() const
virtual void separate(const Activity &)
COutputHandler * mpMaster
void setMaster(COutputHandler *pMaster)
virtual void addInterface(COutputInterface *pInterface)
virtual ~COutputHandler()
std::set< COutputInterface * > getInterfaces() const
virtual void close()
virtual void finish()
bool compileRefresh(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiDataModel *pDataModel)
std::set< const CCopasiObject * > mObjects
virtual bool compile(std::vector< CCopasiContainer * > listOfContainer, const CCopasiDataModel *pDataModel)
virtual bool compile(std::vector< CCopasiContainer * >, const CCopasiDataModel *)
virtual void output(const Activity &activity)
std::set< COutputInterface * > mInterfaces
virtual void finish()
virtual void output(const Activity &)