00001 /* 00002 * Name: filter.m4 00003 * 00004 * Description: 00005 * DOXYGEN Input file filter for DRAMA source files. 00006 * 00007 * This file must be complatible with both Solaris and GNU m4. All 00008 * unused macros are deleted and this comment must end up as a C/C++ 00009 * compatible comment which is not picked up by DOXYGEN. 00010 * 00011 * Synopsis: 00012 * DCF(func) => Produces a link to a DRAMA C source file func.html 00013 * in ../routines. 00014 * DDL(link,text) => Produce a link to ../link.html, specified link text. 00015 * 00016 * Language: m4 macro. 00017 * 00018 * Author: Tony Farrell, AAO. 00019 * 00020 * "@(#) $Id: ACMM:DramaHtml/filter.m4,v 3.24 03-Nov-2009 09:07:29+11 tjf $" 00021 * 00022 * History: 00023 * 10-Nov-2004 - TJF - Original Version. 00024 */ 00025 00026 00027 00028 #ifndef GITTEMPLSINC 00029 #define GITTEMPLSINC 00030 /* 00031 * Copyright (c) Anglo-Australian Telescope Board, 1995. 00032 * Not to be used for commercial purposes without AATB permission. 00033 * 00034 * @(#) $Id: ACMM:DramaGit/gittpl.h,v 3.49 17-Sep-2009 14:08:15+10 tjf $ 00035 * 00036 * Template versions of the Git C++ interfaces - within the GitTpl namespace. 00037 * 00038 * This file now uses DOXYGEN comments to generate the C++ web pages. 00039 * m4 macros of the form @htmlonly <a href="../routines/function.html">function()</a>@endhtmlonly are used in the comments 00040 * to refer to DRAMA C function documention (see DramaHtml/Makefile, 00041 * DramaHtml/doxygen.config and DramaHtml/filter.m4 for detials) 00042 * 00043 */ 00044 00045 #include "Git.h" 00046 #include <string> 00047 #include <limits.h> 00048 00049 namespace GitTpl { 00055 class EnumLookupClass { 00056 public: 00065 virtual unsigned int GetMaxValue() const = 0; 00076 virtual const char ** GetStringArray() const = 0; 00079 virtual ~EnumLookupClass() {} 00080 }; 00081 00104 template <typename LookupClass, typename EnumType> DPUBLICCLASS Enum : public Git { 00105 private: 00106 EnumType value; // The underlying value and the only memory used by the class. 00107 LookupClass lookupObject; // allows us to invoke the methods of this class. 00108 00109 // Set the value of the object from an int. If out of range, set to 00110 // GetMaxValue + 1. 00111 void SetValue(const unsigned int i) { 00112 if (i > lookupObject.GetMaxValue()) 00113 value = InvalidValue(); 00114 else 00115 value = (EnumType)i; 00116 } 00117 EnumType InvalidValue() const { 00118 return (EnumType)(lookupObject.GetMaxValue()+1); 00119 } 00120 protected: 00121 public: 00127 Enum() { 00128 value = InvalidValue(); 00129 } 00136 Enum(EnumType InitialValue) : value(InitialValue) {} 00137 00148 Enum(const SdsId& Id, 00149 const char * const Name, 00150 const int Position, 00151 StatusType *status, 00152 const char *Default=0, 00153 const int Flags = Git::Upper|Git::Abbrev) { 00154 value = InvalidValue(); 00155 Get(Id, Name, Position, status, Default, Flags); 00156 } 00157 00173 void Get(const SdsId& Id, 00174 const char * const Name, 00175 const int Position, 00176 StatusType *status, 00177 const char *Default=0, 00178 const int Flags = Git::Upper|Git::Abbrev|Git::KeepErr) { 00179 char string[100]; 00180 int index; 00181 GitArgGetS((SdsIdType)Id,Name,Position, 00182 lookupObject.GetStringArray(), 00183 Default, 00184 Flags,sizeof(string),string,&index,status); 00185 SetValue(index); 00186 }; 00189 operator EnumType() const { 00190 return value; 00191 } 00194 operator const char *() const { 00195 return lookupObject.GetStringArray()[int(value)]; 00196 } 00199 virtual ~Enum() {}; 00200 00201 }; 00202 00203 00204 00228 template <long int MinVal, 00229 long int MaxVal, 00230 long int DefaultVal=0> DPUBLICCLASS Real : public GitReal { 00231 private: 00232 // Return the range we need. 00233 virtual const double * Range() { 00234 static const double range[] = { MinVal, MaxVal }; 00235 return range; 00236 } 00237 public: 00238 00243 Real(const double def = (double)DefaultVal) : GitReal(def) { } 00244 00256 Real ( /*Constructor with automatic Get */ 00257 const SdsId& Id, 00258 const char * const Name, 00259 const int Position, 00260 StatusType * const status, 00261 const double Default = (double)DefaultVal, 00262 const int Flags = Git::KeepErr) : GitReal(Default) { 00263 GitReal::Get(Id,Name,Position,status,Default,Flags); 00264 } 00265 }; 00266 00286 template <long int MinVal=LONG_MIN, 00287 long int MaxVal=LONG_MAX, 00288 long int DefaultVal=0> DPUBLICCLASS Int : public GitInt { 00289 private: 00290 // Return the range we need. 00291 virtual const long int * Range() { 00292 static const long int range[] = { MinVal, MaxVal }; 00293 return range; 00294 } 00295 public: 00296 00301 Int(const long def = DefaultVal) : GitInt(def) { } 00302 00314 Int ( /*Constructor with automatic Get */ 00315 const SdsId& Id, 00316 const char * const Name, 00317 const int Position, 00318 StatusType * const status, 00319 const long Default = DefaultVal, 00320 const int Flags = Git::KeepErr) : GitInt(Default) { 00321 GitInt::Get(Id,Name,Position,status,Default,Flags); 00322 } 00323 }; 00324 00335 class String : public std::string { 00336 00337 private: 00338 static const unsigned DefaultStringLength = 100; 00339 00340 public: 00343 String() : std::string() {} 00348 String(const std::string & str) : std::string(str) {} 00357 String(const std::string & str, size_type pos, size_type n=std::string::npos) : 00358 std::string(str, pos, n) {} 00363 String(const char * s) : std::string(s) {} 00369 String(const char * s, size_type n) : std::string(s,n) {} 00372 String(size_type n, char c) : std::string(n,c) {} 00378 template<class InputIterator> 00379 String(InputIterator beg, InputIterator end) : std::string(beg,end){} 00380 00392 String( const SdsId& Id, 00393 const char * const Name, 00394 const int Position, 00395 StatusType * const status, 00396 const char * Default = 0, 00397 const int Flags = Git::KeepErr) { 00398 this->Get(Id, Name, Position, status, Default, Flags); 00399 } 00400 00401 00406 String operator=(const std::string str) { 00407 this->std::string::operator=(str); 00408 return *this; 00409 } 00414 String operator=(const String str) { 00415 this->std::string::operator=(str); 00416 return *this; 00417 } 00423 String operator=(const char *s) { 00424 this->std::string::operator=(s); 00425 return *this; 00426 } 00434 String& operator=(char c) { 00435 this->std::string::operator=(c); 00436 return *this; 00437 } 00449 /* 00450 * source of this function is in gitcpp.C. 00451 */ 00452 void Get (const SdsId& Id, 00453 const char * const Name, 00454 const int Position, 00455 StatusType * const status, 00456 const char * Default = 0, 00457 const int Flags = Git::KeepErr); 00458 }; /* String */ 00459 00460 00461 } /* namespace Git */ 00462 #endif /* define GITNEWINC */ 00463
Click here for the DRAMA home page and here for the AAO home page.
For more information, contact tjf@aaoepp.aao.gov.au Generated on Tue Nov 3 09:09:56 2009 for AAO DRAMA C++ Interfaces by
1.2.18