COPASI API  4.16.103
CCallParameters.h
Go to the documentation of this file.
1 /* Begin CVS Header
2  $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/function/CCallParameters.h,v $
3  $Revision: 1.23 $
4  $Name: $
5  $Author: shoops $
6  $Date: 2011/07/05 19:24:03 $
7  End CVS Header */
8 
9 // Copyright (C) 2011 - 2010 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc. and EML Research, gGmbH.
16 // All rights reserved.
17 
18 /**
19  * CFunctionParameterMap
20  *
21  * Created for Copasi by Stefan Hoops
22  * (C) Stefan Hoops 2002
23  */
24 
25 #ifndef COPASI_CCallParameters
26 #define COPASI_CCallParameters
27 
28 #include <vector>
31 #include "report/CCopasiObject.h"
32 
33 /**
34  * CCallParameterPointers
35  *
36  * This is what is actually passed to a function. Some of the void* can be
37  * pointers to vector<const CCopasiObject*>
38  */
39 template < typename Type >
40 class CCallParameters : private std::vector<void *>
41 {
42 public:
43  union UType
44  {
45  const Type * value;
47  // std::vector< void * > * unTyped;
48  };
49 
50  typedef typename std::vector< UType >::const_iterator const_iterator;
51 
52  // Operations
53 public:
54  CCallParameters(const size_t & size = 0):
55  std::vector<void *>(size)
56  {}
57 
59  std::vector<void *>(src)
60  {}
61 
63 
64  void resize(const size_t & size)
65  {
66  ((std::vector<void *> *) this)->resize(size);
67 
68  std::vector<void *>::iterator it
69  = ((std::vector<void *> *) this)->begin();
70  typename std::vector<void *>::iterator end
71  = ((std::vector<void *> *) this)->end();
72 
73  for (; it != end; ++it) *it = NULL;
74  }
75 
76  inline void push_back(const Type * value)
77  {((std::vector<const Type *> *) this)->push_back(value);}
78 
79  inline void push_back(CCallParameters< Type > * vector)
80  {((std::vector<void *> *) this)->push_back(vector);}
81 
82  inline void clear()
83  {((std::vector<void *> *) this)->clear();}
84 
85  inline size_t size() const
86  {return ((std::vector<void *> *) this)->size();}
87 
88  inline UType & operator[](const size_t & index)
89  {return (*(std::vector< UType > *)this)[index];}
90 
91  inline const UType & operator[](const size_t & index) const
92  {return (*(const std::vector< UType > *)this)[index];}
93 
94  inline const_iterator begin() const
95  {return ((std::vector<UType> *) this)->begin();}
96 
97  inline const_iterator end() const
98  {return ((std::vector<UType> *) this)->end();}
99 };
100 
101 /**
102  * CFunctionParameterMap
103  *
104  * This class describes how a reaction fills the call parameters of a function.
105  * It is generated from a CFunctionParameters object.
106  * The reaction provides what exactly is to be passed as function parameters.
107  */
109 {
110 public:
112 
114 
116 
117  /**
118  * Destructor();
119  */
121 
122  /**
123  * Sets a specific parameter. Works only if the parameter is no vector
124  */
125  void setCallParameter(const std::string paramName, const CCopasiObject* obj);
126 
127  /**
128  * Adds an object to a specific parameter vector. Works only if the parameter is a vector
129  */
130  void addCallParameter(const std::string paramName, const CCopasiObject* obj);
131 
132  /**
133  * Removes an object from a specific parameter vector. Works only if the parameter is a vector
134  */
135  void removeCallParameter(const std::string paramName, const CCopasiObject* obj);
136 
137  /**
138  * Removes all objects from a specific parameter vector. Works only if the parameter is a vector.
139  */
140  void clearCallParameter(const std::string paramName);
141 
142  /**
143  * Initializes a CallParameters object from a CFunctionParameters object.
144  */
146 
147  size_t findParameterByName(const std::string & name,
148  CFunctionParameter::DataType & dataType) const;
149 
150 private:
151 
152  /**
153  * Clear the mPointers and mObjects vectors.
154  */
155  void clearCallParameters();
156 
157  /**
158  * Create the mPointers and mObjects vectors with
159  * type information from the CFunctionParameters object.
160  */
161  void initCallParameters();
162 
163  /**
164  * Check if all pointers are !=NULL.
165  */
166  void checkCallParameters() const;
167 
168  /**
169  * This is a vector of pointers to the data that is passed to a function
170  */
172 
173  /**
174  * This is a vector of pointers to objects. Each objects needs to have a value
175  * that can be passed to a function
176  */
178 
179  /**
180  * The CFunctionParameters object provides the data types of the call parameters
181  */
183 
184  // these are preliminary
185 public:
187 
189 
190  const CCallParameters<C_FLOAT64> & getPointers() const;
191 
193 
195 
196  std::vector< const CCopasiObject * > getObjects(const size_t & index) const;
197 };
198 
199 #endif // COPASI_CCallParameters
const_iterator begin() const
void clearCallParameter(const std::string paramName)
void push_back(CCallParameters< Type > *vector)
void push_back(const Type *value)
const CFunctionParameters & getFunctionParameters() const
CCallParameters< CCopasiObject > & getObjects()
void resize(const size_t &size)
CFunctionParameters * mpFunctionParameters
CCallParameters< C_FLOAT64 > & getPointers()
CCallParameters< C_FLOAT64 > mPointers
CCallParameters< Type > * vector
void initializeFromFunctionParameters(const CFunctionParameters &src)
size_t size() const
void setCallParameter(const std::string paramName, const CCopasiObject *obj)
void checkCallParameters() const
static CCopasiObject * pUnmappedObject
const_iterator end() const
() void(yyvaluep))
void removeCallParameter(const std::string paramName, const CCopasiObject *obj)
UType & operator[](const size_t &index)
void addCallParameter(const std::string paramName, const CCopasiObject *obj)
CCallParameters< CCopasiObject > mObjects
const UType & operator[](const size_t &index) const
size_t findParameterByName(const std::string &name, CFunctionParameter::DataType &dataType) const
CCallParameters(const size_t &size=0)
CCallParameters(const CCallParameters &src)
std::vector< UType >::const_iterator const_iterator