COPASI API  4.16.103
CWriteConfig.h
Go to the documentation of this file.
1 /* Begin CVS Header
2  $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/utilities/CWriteConfig.h,v $
3  $Revision: 1.10 $
4  $Name: $
5  $Author: shoops $
6  $Date: 2006/04/27 01:32:43 $
7  End CVS Header */
8 
9 // Copyright 2005 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc. and EML Research, gGmbH.
11 // All rights reserved.
12 
13 /**
14  * CWriteConfig class. A more elaborate class description.
15  *
16  * New Class based on pmutils read functionality
17  * (C) Stefan Hoops 2001
18  */
19 
20 #ifndef COPASI_CWriteConfig
21 #define COPASI_CWriteConfig
22 
23 #include <sstream>
24 
26  {
27  public:
28  /**
29  * Default consructor.
30  * This creates a configuration buffer without assigning a filename.
31  * It is currently useless.
32  */
33  CWriteConfig();
34 
35  /**
36  * Specified consructor.
37  * This opens the configuration file using the filename specified
38  * as the argument.
39  * @param name name of the confguration file.
40  * @param mode output mode, defaults to creating a new file.
41  */
42  CWriteConfig(const std::string& name,
43  std::ios_base::openmode mode = std::ios_base::out);
44 
45  /**
46  * Destructor.
47  * The destructor calls the method flush().
48  */
49  ~CWriteConfig();
50 
51  /**
52  * Flush the output buffer to the configuration file.
53  * @return mFail
54  * @see mFail
55  */
56  C_INT32 flush();
57 
58  /**
59  * Returns the failure status.
60  * @return mFail
61  * @see mFail
62  */
63  C_INT32 fail();
64 
65  /**
66  * Writes a variable to the output file.
67  * @param name name of the variable to be written.
68  * @param type type of the variable to be written.
69  * @param *pout pointer to the location where the variable
70  * is stored.
71  * @return mFail
72  * @see mFail
73  */
74  C_INT32 setVariable(const std::string & name,
75  const std::string & type,
76  const void * pout);
77  C_INT32 setVariable(const std::string & name,
78  const std::string & type,
79  const void * pout1,
80  const void * pout2);
81 
82  /**
83  * Save various default values
84  */
85  void setDefaults();
86 
87  private:
88  /**
89  * Commits all information to the configuration file.
90  * This method is called by the destructor.
91  */
92  C_INT32 commit();
93 
94  /**
95  * Writes a version number to the file.
96  * This method is called by one of the constructors.
97  */
98  void writeVersion(void);
99 
100  /**
101  * Name of the configuration file.
102  */
103  std::string mFileName; // Config File Name
104 
105  /**
106  * Output file
107  */
108  std::stringstream mBuffer;
109 
110  /**
111  * Current line number in the configuration file
112  */
113  unsigned C_INT32 mLineNumber; // Current Line Number
114 
115  /**
116  * Open mode
117  */
118  std::ios_base::openmode mOpenMode;
119 
120  /**
121  * Failure status:
122  * 0 = no error
123  * !0 = error
124  */
125  C_INT32 mFail; // Failure State
126  };
127 #endif // COPASI_CWriteConfig
std::string mFileName
Definition: CWriteConfig.h:103
C_INT32 setVariable(const std::string &name, const std::string &type, const void *pout)
#define C_INT32
Definition: copasi.h:90
void writeVersion(void)
C_INT32 flush()
std::ios_base::openmode mOpenMode
Definition: CWriteConfig.h:118
C_INT32 mFail
Definition: CWriteConfig.h:125
C_INT32 fail()
C_INT32 commit()
unsigned C_INT32 mLineNumber
Definition: CWriteConfig.h:113
std::stringstream mBuffer
Definition: CWriteConfig.h:108
void setDefaults()