COPASI API  4.16.103
copasimathml.h
Go to the documentation of this file.
1 /* Begin CVS Header
2  $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/utilities/copasimathml.h,v $
3  $Revision: 1.5 $
4  $Name: $
5  $Author: shoops $
6  $Date: 2011/11/09 16:45:26 $
7  End CVS Header */
8 
9 // Copyright (C) 2011 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 #ifndef COPASI_MATHML
19 #define COPASI_MATHML
20 
21 #include "model/CModelValue.h"
22 //#include "model/CMetab.h"
23 #include "model/CCompartment.h"
26 
27 #define SPC(level) std::string(level, ' ')
28 
29 class CMathMl
30 {
31 public:
32 
33  static std::string fixName(const std::string & name)
34  {
35  std:: string Fixed;
36 
37  if (name.find_first_of(" ()*+-") == std::string::npos)
38  Fixed = name;
39  else
40  Fixed = "\"" + name + "\"";
41 
43  }
44 
45  static std::string getMMLName(const CCopasiObject* obj)
46  {
47  if (!obj) return "no object";
48 
49  //model value
50  const CModelValue* mv = dynamic_cast<const CModelValue*>(obj);
51 
52  if (mv) return "<mi>" + fixName(mv->getObjectName()) + "</mi>";
53 
54  //metabolite
55  //const CMetab* met = dynamic_cast<const CMetab*>(obj);
56  //if (met) return "<mi>[" + met->getObjectName() + "]</mi>";
57 
58  //compartment
59  const CCompartment* comp = dynamic_cast<const CCompartment*>(obj);
60 
61  if (comp) return "<msub><mi>V</mi><mi>" + fixName(comp->getObjectName())
62  + "</mi></msub>";
63 
64  //reference
65  if (obj->getObjectType() == "Reference")
66  {
67  //model value
68  if (obj->getObjectName() == "Value")
69  {
70  mv = dynamic_cast<const CModelValue*>(obj->getObjectParent());
71 
72  if (mv) return "<mi>" + fixName(mv->getObjectName()) + "</mi>";
73  }
74 
75  //compartment
76  if (obj->getObjectName() == "Volume")
77  {
78  comp = dynamic_cast<const CCompartment*>(obj->getObjectParent());
79 
80  if (comp) return "<msub><mi>V</mi><mi>" + fixName(comp->getObjectName())
81  + "</mi></msub>";
82  }
83  }
84 
85  return "<mi>" + fixName(obj->getObjectDisplayName()) + "</mi>";
86  }
87 };
88 
89 #endif
static std::string getMMLName(const CCopasiObject *obj)
Definition: copasimathml.h:45
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
Header file of class CModelEntity and CModelValue.
const std::string & getObjectName() const
static std::string fixName(const std::string &name)
Definition: copasimathml.h:33
const std::string & getObjectType() const
static std::string encode(const std::string &str, const EncodingType &type=standard)
CCopasiContainer * getObjectParent() const