Log In | Get Help   
Home My Page Projects Code Snippets Project Openings Mareframe
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files
[mareframe] Annotation of /trunk/gadget/suitfuncptrvector.cc
[mareframe] / trunk / gadget / suitfuncptrvector.cc Repository:
ViewVC logotype

Annotation of /trunk/gadget/suitfuncptrvector.cc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : agomez 1 #include "suitfuncptrvector.h"
2 :     #include "errorhandler.h"
3 :     #include "gadget.h"
4 :     #include "global.h"
5 :    
6 :     SuitFuncPtrVector::~SuitFuncPtrVector() {
7 :     if (v != 0) {
8 :     delete[] v;
9 :     v = 0;
10 :     }
11 :     }
12 :    
13 :     void SuitFuncPtrVector::resize(SuitFunc* value) {
14 :     int i;
15 :     if (v == 0) {
16 :     v = new SuitFunc*[1];
17 :     } else {
18 :     SuitFunc** vnew = new SuitFunc*[size + 1];
19 :     for (i = 0; i < size; i++)
20 :     vnew[i] = v[i];
21 :     delete[] v;
22 :     v = vnew;
23 :     }
24 :     v[size] = value;
25 :     size++;
26 :     }
27 :    
28 :     void SuitFuncPtrVector::Delete(int pos, Keeper* const keeper) {
29 :     int i;
30 :     if (size > 1) {
31 :     SuitFunc** vnew = new SuitFunc*[size - 1];
32 :     for (i = 0; i < pos; i++)
33 :     vnew[i] = v[i];
34 :     for (i = pos; i < size - 1; i++)
35 :     vnew[i] = v[i + 1];
36 :     for (i = 0; i < v[pos]->numConstants(); i++)
37 :     v[pos]->getConstants()[i].Delete(keeper);
38 :     delete[] v;
39 :     v = vnew;
40 :     size--;
41 :     } else {
42 :     delete[] v;
43 :     v = 0;
44 :     size = 0;
45 :     }
46 :     }
47 :    
48 :     void SuitFuncPtrVector::readSuitFunction(CommentStream& infile,
49 :     const char* suitname, const TimeClass* const TimeInfo, Keeper* const keeper) {
50 :    
51 :     SuitFunc* tempFunc = 0;
52 :    
53 :     if ((strcasecmp(suitname, "expsuitfunca") == 0) || (strcasecmp(suitname, "exponential") == 0)) {
54 :     tempFunc = new ExpSuitFuncA();
55 :    
56 :     } else if ((strcasecmp(suitname, "constsuitfunc") == 0) || (strcasecmp(suitname, "constant") == 0)) {
57 :     tempFunc = new ConstSuitFunc();
58 :    
59 :     } else if (strcasecmp(suitname, "straightline") == 0) {
60 :     tempFunc = new StraightSuitFunc();
61 :    
62 :     } else if (strcasecmp(suitname, "straightlineunbounded") == 0) {
63 :     tempFunc = new StraightUnboundedSuitFunc();
64 :    
65 :     } else if ((strcasecmp(suitname, "newexponentiall50") == 0) || (strcasecmp(suitname, "expsuitfuncl50") == 0) || (strcasecmp(suitname, "exponentiall50") == 0)){
66 :     handle.logFileMessage(LOGWARN, "\nNote that this exponentiall50 has had a factor of 4 removed from the source code");
67 :    
68 :     tempFunc = new ExpSuitFuncL50();
69 :    
70 :     } else if ((strcasecmp(suitname, "andersensuitfunc") == 0) || (strcasecmp(suitname, "andersen") == 0)) {
71 :     tempFunc = new AndersenSuitFunc();
72 :    
73 :     } else if (strcasecmp(suitname, "richards") == 0) {
74 :     tempFunc = new RichardsSuitFunc();
75 :    
76 :     } else if (strcasecmp(suitname, "gamma") == 0) {
77 :     tempFunc = new GammaSuitFunc();
78 :    
79 :     } else if (strcasecmp(suitname, "newinverse") == 0) {
80 :     tempFunc = new InverseSuitFunc();
81 :    
82 :     } else if (strcasecmp(suitname, "andersenfleet") == 0) {
83 :     tempFunc = new AndersenFleetSuitFunc();
84 :    
85 :     /* } else if ((strcasecmp(suitname, "expsuitfuncl50") == 0) || (strcasecmp(suitname, "exponentiall50") == 0)) {
86 :     handle.logFileMessage(LOGFAIL, "\nThe exponentiall50 suitability function is no longer supported\nUse the newexponentiall50 suitability function instead\nNote that this function has had a factor of 4 removed from the source code");
87 :     */
88 :     } else if (strcasecmp(suitname, "inverse") == 0) {
89 :     handle.logFileMessage(LOGFAIL, "\nThe inverse suitability function is no longer supported\nUse the newinverse suitability function instead\nNote that this function has had a factor of 4 removed from the source code");
90 :    
91 :     } else if (strcasecmp(suitname, "improvedexpsuitfunc") == 0) {
92 :     handle.logFileMessage(LOGFAIL, "\nThe improvedexpsuitfunc suitability function is no longer supported");
93 :    
94 :     } else if (strcasecmp(suitname, "improvedandextendedexpsuitfunc") == 0) {
95 :     handle.logFileMessage(LOGFAIL, "\nThe improvedandextendedexpsuitfunc suitability function is no longer supported");
96 :    
97 :     } else if (strcasecmp(suitname, "extendedexpsuitfuncl50") == 0) {
98 :     handle.logFileMessage(LOGFAIL, "\nThe extendedexpsuitfuncl50 suitability function is no longer supported");
99 :    
100 :     } else if (strcasecmp(suitname, "badexpsuitfuncl50") == 0) {
101 :     handle.logFileMessage(LOGFAIL, "\nThe badexpsuitfuncl50 suitability function is no longer supported");
102 :    
103 :     } else if (strcasecmp(suitname, "surveyselection") == 0) {
104 :     handle.logFileMessage(LOGFAIL, "\nThe surveyselection suitability function is no longer supported");
105 :    
106 :     } else if (strcasecmp(suitname, "cloglog") == 0) {
107 :     handle.logFileMessage(LOGFAIL, "\nThe cloglog suitability function is no longer supported");
108 :    
109 :     } else if (strcasecmp(suitname, "combination") == 0) {
110 :     handle.logFileMessage(LOGFAIL, "\nThe combination suitability function is no longer supported");
111 :    
112 :     } else
113 :     handle.logFileMessage(LOGFAIL, "no valid suitability function found");
114 :    
115 :     tempFunc->readConstants(infile, TimeInfo, keeper);
116 :     this->resize(tempFunc);
117 :     }

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge