/usr/include/xylib/cache.h is in libxy-dev 1.3-1.1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | // Public API of xylib library.
// Licence: Lesser GNU Public License 2.1 (LGPL)
/// This header is new in 0.4 and may be changed in future.
/// Support for caching files read by xylib.
/// Usage is similar to load_file() from xylib.h:
/// shared_ptr<const xylib::DataSet> my_dataset = xylib::cached_load_file(...);
/// or
/// xylib::DataSet const& my_dataset = xylib::Cache::Get()->load_file(...);
#ifndef XYLIB_CACHE_H_
#define XYLIB_CACHE_H_
#ifndef __cplusplus
#error "xylib/cache.h is a C++ only header."
#endif
#include <ctime>
#include <string>
#include <vector>
#include "xylib.h"
// MSVC has shared_ptr in <memory>, but let's use boost
#ifndef _MSC_VER
// the value here (1 or 0) is set by xylib configure script
// (yes, the configure script can modify this file!)
#define XYLIB_USE_TR1_MEMORY 1
#endif
#if XYLIB_USE_TR1_MEMORY
# include <tr1/memory>
using std::tr1::shared_ptr;
#else
# include <boost/shared_ptr.hpp>
using boost::shared_ptr;
#endif
namespace xylib
{
struct CacheImp;
// singleton
class XYLIB_API Cache
{
public:
// get instance
static Cache* Get()
{ if (instance_ == NULL) instance_ = new Cache(); return instance_; }
// Arguments are the same as in load_file() in xylib.h,
// but a const ref is returned instead of pointer.
shared_ptr<const DataSet> load_file(std::string const& path,
std::string const& format_name="",
std::string const& options="");
// set max. number of cached files, default=1
void set_max_size(size_t max_size);
// get max. number of cached files
inline size_t get_max_size() const;
// clear cache
void clear_cache();
private:
static Cache *instance_; // for singleton pattern
CacheImp* imp_;
Cache();
};
inline
shared_ptr<const DataSet> cached_load_file(std::string const& path,
std::string const& format_name="",
std::string const& options="")
{
return Cache::Get()->load_file(path, format_name, options);
}
} // namespace xylib
#endif // XYLIB_CACHE_H_
|