export_data_internal.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ACADO Toolkit.
3  *
4  * ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
5  * Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
6  * Milan Vukov, Rien Quirynen, KU Leuven.
7  * Developed within the Optimization in Engineering Center (OPTEC)
8  * under supervision of Moritz Diehl. All rights reserved.
9  *
10  * ACADO Toolkit is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 3 of the License, or (at your option) any later version.
14  *
15  * ACADO Toolkit is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with ACADO Toolkit; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  *
24  */
26 
28 
29 std::string ExportDataInternal::fcnPrefix = "acado";
30 
31 
32 using namespace CasADi;
33 
34 
35 //
36 // PUBLIC MEMBER FUNCTIONS:
37 //
38 
39 ExportDataInternal::ExportDataInternal( const std::string& _name,
40  ExportType _type,
41  ExportStruct _dataStruct,
42  const std::string& _prefix
43  )
44  : SharedObjectNode(), name( _name ), type( _type ), prefix( _prefix ), dataStruct( _dataStruct ),
45  description()
46 {
47  setFullName();
48 }
49 
51 {
52 }
53 
54 returnValue ExportDataInternal::setName( const std::string& _name
55  )
56 {
57  if ( _name.empty() == true )
59 
60  name = _name;
61 
62  setFullName();
63 
64  return SUCCESSFUL_RETURN;
65 }
66 
67 
69  )
70 {
71  type = _type;
72 
73  setFullName();
74 
75  return SUCCESSFUL_RETURN;
76 }
77 
78 returnValue ExportDataInternal::setPrefix( const std::string& _prefix
79  )
80 {
81  prefix = _prefix;
82 
83  setFullName();
84 
85  return SUCCESSFUL_RETURN;
86 }
87 
89  )
90 {
91  dataStruct = _dataStruct;
92 
93  setFullName();
94 
95  return SUCCESSFUL_RETURN;
96 }
97 
98 
99 
100 std::string ExportDataInternal::getName( ) const
101 {
102  return name;
103 }
104 
106 {
107  return type;
108 }
109 
110 std::string ExportDataInternal::getPrefix() const
111 {
112  return prefix;
113 }
114 
115 std::string ExportDataInternal::getTypeString( const std::string& _realString,
116  const std::string& _intString
117  ) const
118 {
119  switch ( type )
120  {
121  case INT:
122  return _intString;
123 
124  case REAL:
125  return _realString;
126 
127  case COMPLEX:
128  return std::string("double complex");
129 
130  case STATIC_CONST_INT:
131  return std::string("static const ") + _intString;
132 
133  case STATIC_CONST_REAL:
134  return std::string("static const ") + _realString;
135  }
136 
137  return std::string("unknownType");
138 }
139 
140 
142 {
143  return dataStruct;
144 }
145 
146 
148 {
149  std::stringstream tmp;
150 
151  tmp << prefix;
152 
153  if (prefix.empty() == false)
154  tmp << "_";
155 
156  switch ( dataStruct )
157  {
158  case ACADO_VARIABLES:
159  tmp << fcnPrefix + "Variables";
160  break;
161 
162  case ACADO_WORKSPACE:
163  tmp << fcnPrefix + "Workspace";
164  break;
165 
166  case ACADO_PARAMS:
167  tmp << fcnPrefix + "Params";
168  break;
169 
170  case ACADO_VARS:
171  tmp << fcnPrefix + "Vars";
172  break;
173 
174  case FORCES_PARAMS:
175  tmp << "params";
176  break;
177 
178  case FORCES_OUTPUT:
179  tmp << "output";
180  break;
181 
182  case FORCES_INFO:
183  tmp << "info";
184  break;
185 
186  default:
187  tmp << "";
188  break;
189  }
190 
191  return tmp.str();
192 }
193 
194 
196 {
197  if ( fullName.empty() == true )
198  return name;
199 
200  return fullName;
201 }
202 
203 
204 
205 //
206 // PROTECTED MEMBER FUNCTIONS:
207 //
208 
209 
210 //
211 // PRIVATE MEMBER FUNCTIONS:
212 //
213 
215 {
216  if ( dataStruct == ACADO_LOCAL )
217  {
218  if ( prefix.empty() == false )
219  {
220  fullName = prefix;
221  fullName += std::string("_") + name;
222  }
223  else
224  {
225  fullName = "";
226  }
227  }
228  else
229  {
230 // if ( prefix.isEmpty() == false )
231 // {
232 // fullName = prefix;
233 // fullName << "_" << getDataStructstd::string();
234 // }
235 // else
236 // {
238 // }
239 
240  fullName += std::string(".") + name;
241  }
242 
243  return SUCCESSFUL_RETURN;
244 }
245 
246 returnValue ExportDataInternal::setDoc( const std::string& _doc )
247 {
248  description = _doc;
249 
250  return SUCCESSFUL_RETURN;
251 }
252 
253 std::string ExportDataInternal::getDoc() const
254 {
255  return description;
256 }
257 
Internal class for the reference counting framework, see comments on the public class.
returnValue setDataStruct(ExportStruct _dataStruct)
std::string getFullName() const
Allows to pass back messages to the calling function.
std::string getTypeString(const std::string &_realString="real_t", const std::string &_intString="int") const
ExportDataInternal(const std::string &_name=std::string(), ExportType _type=REAL, ExportStruct _dataStruct=ACADO_LOCAL, const std::string &_prefix=std::string())
#define CLOSE_NAMESPACE_ACADO
virtual std::string getDoc() const
ExportStruct
virtual returnValue setDoc(const std::string &_doc)
returnValue setPrefix(const std::string &_prefix)
static std::string fcnPrefix
ExportType getType() const
ExportType
returnValue setName(const std::string &_name)
std::string getName() const
std::string getDataStructString() const
ExportStruct getDataStruct() const
#define BEGIN_NAMESPACE_ACADO
std::string getPrefix() const
returnValue setType(ExportType _type)
#define ACADOERROR(retval)
returnValue setFullName(void)


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:34:33