cloudy  trunk
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
version.h
Go to the documentation of this file.
1 /* This file is part of Cloudy and is copyright (C)1978-2008 by Gary J. Ferland and
2  * others. For conditions of distribution and use see copyright notice in license.txt */
3 
4 #ifndef _VERSION_H_
5 #define _VERSION_H_
6 
8 #include "date.h"
9 
10 static const int CLD_MAJOR = 8;
11 static const int CLD_MINOR = 0;
12 static const int CLD_PATCH = 0;
13 
14 static const string Url = "$HeadURL$";
15 
16 static const char* CITATION = "Ferland, G. J., Korista, K. T., Verner, D. A., Ferguson, J. W., Kingdon, J. B., & Verner, E. M. 1998, PASP, 110, 761";
17 static const char* CITATION_LATEX = "\\bibitem[Ferland et al.(1998)]{1998PASP..110..761F} Ferland, G.~J., Korista, K.~T., Verner, D.~A., Ferguson, J.~W., Kingdon, J.~B., \\& Verner, E.~M.\\ 1998, \\pasp, 110, 761";
18 static const char* CITATION_SHORT = "Ferland et al. (1998)";
19 
20 class t_version : public Singleton<t_version>
21 {
22  friend class Singleton<t_version>;
23 protected:
25  {
26  static const char chMonth[12][4] =
27  { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
28 
29  /* is this a release version? */
30  lgRelease = true;
31 
32  /* is this a beta version? 0 for no
33  * if this is non-zero then lgRelease above should be false */
34  nBetaVer = 0;
35 
36  if( lgRelease )
37  {
38  if( CLD_PATCH > 0 )
39  sprintf( chVersion, "%2.2i.%2.2i (patch level %d)", CLD_MAJOR, CLD_MINOR, CLD_PATCH );
40  else
41  sprintf( chVersion, "%2.2i.%2.2i", CLD_MAJOR, CLD_MINOR );
42  }
43  else if( nBetaVer > 0 )
44  {
45  sprintf( chVersion, "%2.2i.%2.2i beta %ld (prerelease)", CLD_MAJOR, CLD_MINOR, nBetaVer );
46  }
47  else
48  {
49  sprintf( chVersion, "%2.2i.%2.2i.%2.2i", YEAR%100, MONTH+1, DAY );
50  }
51 
52  sprintf( chDate, "%2.2i%3.3s%2.2i", YEAR%100, chMonth[MONTH], DAY );
53 
54  // analyze the URL to determine where we live, the version number is derived from that
55  // the code below is based on the following naming scheme:
56  //
57  // /branches/c08_branch -- release branch, all bug fixes are submitted here
58  //
59  // /tags/develop/c08.00_rc1 -- release candidates go here
60  //
61  // /tags/release/c08.00 -- first official release
62  // /tags/release/c08.01 -- first bug-fix rollup, etc...
63  //
64  // /tags/patch_versions/c08.00_pl00 -- identical to /tags/release/c08.00
65  // /tags/patch_versions/c08.00_pl01 -- first patch update, etc...
66 
67  vector<string> Part;
68  Split( Url, "/", Part, SPM_RELAX );
69  if( Part.size() >= 3 )
70  {
71  // the last two parts are "source" and "version.h $", we don't need them...
72  // the one before is the relevant identifier (e.g. "c08.01")
73  // for conciseness we will refer to it below as the "branch"
74  string Branch = Part[Part.size()-3];
75 
76  bool lgReleaseTag = ( Url.find("/tags/release/") != string::npos );
77  bool lgPatchTag = ( Url.find("/tags/patch_versions/") != string::npos );
78  bool lgDevelopTag = ( Url.find("/tags/develop/") != string::npos );
79  // this expects a branch name like "c08_branch"
80  bool lgReleaseBranch = ( Url.find("/branches/") != string::npos &&
81  Branch.size() == 10 && Branch[0] == 'c' &&
82  Branch.find("_branch") != string::npos );
83 
84  bool lgReleaseChk = ( lgReleaseTag || lgPatchTag );
85 
86  long nBetaVerChk;
87 
88  // determine if this is a beta version
89  string::size_type ptr;
90  if( lgDevelopTag && ( ptr = Branch.find( "_rc" ) ) != string::npos )
91  // this expects a branch name like "c08.00_rc1"
92  sscanf( Branch.substr( ptr+3 ).c_str(), "%ld", &nBetaVerChk );
93  else
94  nBetaVerChk = 0;
95 
96  int nMajorLevel=0, nMinorLevel=0, nPatchLevel=0;
97 
98  if( lgReleaseBranch || lgReleaseChk || nBetaVerChk > 0 )
99  {
100  // this expects a branch name starting with "c08"
101  sscanf( Branch.substr(1,2).c_str(), "%d", &nMajorLevel );
102  if( nMajorLevel != CLD_MAJOR )
103  fprintf( ioQQQ, "PROBLEM - CLD_MAJOR mismatch, please check version.h\n" );
104  }
105 
106  if( lgReleaseChk || nBetaVerChk > 0 )
107  {
108  // this expects a branch name starting with "c08.01"
109  sscanf( Branch.substr(4,2).c_str(), "%d", &nMinorLevel );
110  if( nMinorLevel != CLD_MINOR )
111  fprintf( ioQQQ, "PROBLEM - CLD_MINOR mismatch, please check version.h\n" );
112  }
113 
114  if( lgPatchTag )
115  {
116  // this expects a branch name like "c08.01_pl02"
117  sscanf( Branch.substr(9,2).c_str(), "%d", &nPatchLevel );
118  if( nPatchLevel != CLD_PATCH )
119  fprintf( ioQQQ, "PROBLEM - CLD_PATCH mismatch, please check version.h\n" );
120  // c08.00_pl00 is identical to release c08.00, so pass it off as the latter...
121  if( nPatchLevel == 0 )
122  lgReleaseTag = true;
123  }
124 
125  if( nBetaVerChk > 0 )
126  {
127  if( nBetaVerChk != nBetaVer )
128  fprintf( ioQQQ, "PROBLEM - nBetaVer mismatch, please check version.h\n" );
129  }
130 
131  if( lgReleaseChk != lgRelease )
132  fprintf( ioQQQ, "PROBLEM - lgRelease setting wrong, please check version.h\n" );
133  }
134 
135  char mode[6];
136  if( sizeof(long) == 4 )
137  strncpy( mode, "ILP32", 6 );
138  else if( sizeof(long) == 8 )
139  strncpy( mode, "LP64", 6 );
140  else
141  strncpy( mode, "?????", 6 );
142 
143  /* now generate info on how we were compiled, including compiler version */
144  sprintf( chInfo,
145  "cdInit compiled on %s in OS %s using the %s %i compiler in %s mode.",
146  __DATE__, __OS, __COMP, __COMP_VER, mode );
147 
151  }
152 public:
155 
158 
160  long int nBetaVer;
161 
163  bool lgRelease;
164 
168 
170  const char *chCitation;
171 
173  const char *chCitationShort;
174 
176  const char *chCitationLatex;
177 };
178 
179 #endif /* _VERSION_H_ */

Generated for cloudy by doxygen 1.8.1.1