resource.hpp
1 /*
2  * This file is part of CasADi.
3  *
4  * CasADi -- A symbolic framework for dynamic optimization.
5  * Copyright (C) 2010-2023 Joel Andersson, Joris Gillis, Moritz Diehl,
6  * KU Leuven. All rights reserved.
7  * Copyright (C) 2011-2014 Greg Horn
8  *
9  * CasADi is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 3 of the License, or (at your option) any later version.
13  *
14  * CasADi is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with CasADi; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  *
23  */
24 
25 
26 #ifndef CASADI_RESOURCE_HPP
27 #define CASADI_RESOURCE_HPP
28 
29 #include "shared_object.hpp"
30 #include "printable.hpp"
31 #include "generic_type.hpp"
32 
33 namespace casadi {
34  // Forward declaration
35  class ResourceInternal;
36  class SerializingStream;
37  class DeserializingStream;
38 
42  class CASADI_EXPORT Resource
43  : public SharedObject,
44  public SWIG_IF_ELSE(PrintableCommon, Printable<Resource>) {
45  public:
54  Resource(const std::string& path);
56  explicit Resource();
57 
59  static std::string type_name() {return "Resource";}
60 
62  static bool test_cast(const SharedObjectInternal* ptr);
63 
64 #ifndef SWIG
68  static Resource create(ResourceInternal *node);
69 
70  ResourceInternal* get() const;
71 
73  const ResourceInternal* operator->() const;
74 
76  ResourceInternal* operator->();
77 
79  const ResourceInternal& operator*() const;
80 #endif
81 
83  const std::string& path() const;
84 
88  void serialize(SerializingStream &s) const;
89 
96  void change_option(const std::string& option_name,
97  const GenericType& option_value);
98 
102  static Resource deserialize(DeserializingStream& s);
103  };
104 
105 } // namespace casadi
106 
107 #endif // CASADI_RESOURCE_HPP
Helper class for Serialization.
Generic data type, can hold different types such as bool, casadi_int, std::string etc.
RAII class base for reading from resources.
RAII class for reading from a zip file.
Definition: resource.hpp:44
static std::string type_name()
Readable name of the public class.
Definition: resource.hpp:59
Helper class for Serialization.
GenericShared implements a reference counting framework similar for efficient and.
The casadi namespace.
Definition: archiver.cpp:28
std::vector< casadi_int > path(const std::vector< casadi_int > &map, casadi_int i_start)