TBTK
Resource.h
Go to the documentation of this file.
1 /* Copyright 2017 Kristofer Bj√∂rnson
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
23 #ifndef COM_DAFER45_TBTK_RESOURCE
24 #define COM_DAFER45_TBTK_RESOURCE
25 
26 #include "TBTK/Serializable.h"
27 
28 #include <string>
29 #include <vector>
30 
31 namespace TBTK{
32 
33 class Resource{
34 public:
36  Resource();
37 
39  ~Resource();
40 
42  void setData(const std::string &data);
43 
45  const std::string& getData() const;
46 
48  void write(const std::string &uri);
49 
51  void read(const std::string &uri);
52 private:
54  std::string data;
55 
57  static size_t writeCallback(
58  void *data,
59  size_t size,
60  size_t nmemb,
61  void *userdata
62  );
63 
65  static size_t readCallback(
66  char *data,
67  size_t size,
68  size_t nmemb,
69  void *userdata
70  );
71 };
72 
73 inline void Resource::setData(const std::string &data){
74  this->data = data;
75 }
76 
77 inline const std::string& Resource::getData() const{
78  return data;
79 }
80 
81 }; //End namespace TBTK
82 
83 #endif
void read(const std::string &uri)
void setData(const std::string &data)
Definition: Resource.h:73
const std::string & getData() const
Definition: Resource.h:77
void write(const std::string &uri)
Definition: Resource.h:33
Definition: ModelFactory.h:35
Abstract base class for serializable objects.