MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
hint_impl.cc
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/base/hint_impl.cc,v 1.19 2017/01/12 14:46:09 masarati Exp $ */
2 /*
3  * MBDyn (C) is a multibody analysis code.
4  * http://www.mbdyn.org
5  *
6  * Copyright (C) 1996-2017
7  *
8  * Pierangelo Masarati <masarati@aero.polimi.it>
9  * Paolo Mantegazza <mantegazza@aero.polimi.it>
10  *
11  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
12  * via La Masa, 34 - 20156 Milano, Italy
13  * http://www.aero.polimi.it
14  *
15  * Changing this copyright notice is forbidden.
16  *
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation (version 2 of the License).
20  *
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */
31 
32 #include "mbconfig.h" /* This goes first in every *.c,*.cc file */
33 
34 #include "hint_impl.h"
35 
36 Hint *
37 ParseHint(DataManager *pDM, const char *s)
38 {
39  if (strncasecmp(s, "drive{", STRLENOF("drive{")) == 0) {
40  s += STRLENOF("drive{");
41 
42  size_t len = strlen(s);
43 
44  if (s[len - 1] != '}') {
45  return 0;
46  }
47 
48  char *sDriveStr = new char[len + 1];
49  memcpy(sDriveStr, s, len + 1);
50  sDriveStr[len - 1] = ';';
51 
52  return new DriveHint(sDriveStr);
53 
54  } else if (strncasecmp(s, "drive3{", STRLENOF("drive3{")) == 0) {
55  s += STRLENOF("drive3{");
56 
57  size_t len = strlen(s);
58 
59  if (s[len - 1] != '}') {
60  return 0;
61  }
62 
63  char *sDriveStr = new char[len + 1];
64  memcpy(sDriveStr, s, len + 1);
65  sDriveStr[len - 1] = ';';
66 
67  return new TplDriveHint<Vec3>(sDriveStr);
68 
69  } else if (strncasecmp(s, "drive6{", STRLENOF("drive6{")) == 0) {
70  s += STRLENOF("drive6{");
71 
72  size_t len = strlen(s);
73 
74  if (s[len - 1] != '}') {
75  return 0;
76  }
77 
78  char *sDriveStr = new char[len + 1];
79  memcpy(sDriveStr, s, len + 1);
80  sDriveStr[len - 1] = ';';
81 
82  return new TplDriveHint<Vec6>(sDriveStr);
83  }
84 
85  return 0;
86 }
87 
88 /* ParsableHint - start */
89 
91 : sHint((char *)s)
92 {
93  NO_OP;
94 }
95 
97 {
98  if (sHint != 0) {
100  }
101 }
102 
103 /* DriveHint - start */
104 
105 DriveHint::DriveHint(const char *s)
106 : ParsableHint(s)
107 {
108  NO_OP;
109 }
110 
112 {
113  NO_OP;
114 }
115 
116 DriveCaller *
118 {
119  std::istringstream in(sHint);
120  InputStream In(in);
121 
122  MBDynParser HP(pDM->GetMathParser(), In, "DriveHint::pCreateDrive");
123  HP.ExpectArg();
124  HP.SetDataManager(pDM);
125 
126  return HP.GetDriveCaller(false);
127 }
128 
129 /* DriveHint - end */
130 
131 
132 /* TplDriveHint - start */
133 
136 
137 /* TplDriveHint - end */
Definition: hint.h:38
TplDriveHint6 tdh6(0)
virtual void ExpectArg(void)
Definition: parser.cc:798
MathParser & GetMathParser(void) const
Definition: dataman.h:341
Hint * ParseHint(DataManager *pDM, const char *s)
Definition: hint_impl.cc:37
#define SAFEDELETEARR(pnt)
Definition: mynewmem.h:713
ParsableHint(const char *s)
Definition: hint_impl.cc:90
#define NO_OP
Definition: myassert.h:74
TplDriveHint3 tdh3(0)
virtual ~ParsableHint(void)
Definition: hint_impl.cc:96
DriveCaller * pCreateDrive(DataManager *pDM) const
Definition: hint_impl.cc:117
DriveHint(const char *s)
Definition: hint_impl.cc:105
char * sHint
Definition: hint_impl.h:45
#define STRLENOF(s)
Definition: mbdyn.h:166
virtual ~DriveHint(void)
Definition: hint_impl.cc:111