Cypress  1.0
C++ Spiking Neural Network Simulation Framework
resource.hpp
Go to the documentation of this file.
1 /*
2  * Cypress -- C++ Spiking Neural Network Simulation Framework
3  * Copyright (C) 2016 Andreas Stöckel
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
33 #pragma once
34 
35 #ifndef CYPRESS_UTIL_RESOURCE_HPP
36 #define CYPRESS_UTIL_RESOURCE_HPP
37 
38 #include <cstdint>
39 #include <string>
40 #include <vector>
41 
42 namespace cypress {
46 class Resource {
47 private:
48  const std::vector<uint8_t> m_data;
49  mutable std::string m_filename;
50  mutable int m_fd;
51 
52 public:
56  Resource(const std::vector<uint8_t> &data) : m_data(data), m_fd(-1) {}
57 
61  Resource(const std::string &data)
62  : m_data(data.begin(), data.end()), m_fd(-1)
63  {
64  }
65 
69  ~Resource();
70 
74  const std::vector<uint8_t> &data() const { return m_data; }
75 
80  const std::string &open() const;
81 
86  const std::string open_local(std::string filename) const;
87 };
88 }
89 #endif /* CYPRESS_UTIL_RESOURCE_HPP */
const std::string open_local(std::string filename) const
Resource(const std::string &data)
Definition: resource.hpp:61
Definition: resource.hpp:46
const std::vector< uint8_t > & data() const
Definition: resource.hpp:74
const std::string & open() const
Resource(const std::vector< uint8_t > &data)
Definition: resource.hpp:56
Definition: brainscales_lib.hpp:39