MADARA  3.1.8
madara::knowledge::Files Class Reference

This class provides file repo capabilities to the knowledge base. More...

#include <Files.h>

Collaboration diagram for madara::knowledge::Files:

Public Member Functions

 Files (ThreadSafeContext &map)
 Constructor. More...
 
MADARA_Export int read_file (const std::string &knowledge_key, const std::string &filename)
 Read a file into the knowledge base. More...
 
MADARA_Export int read_file (const char *filename, ACE_Mem_Map &mem_map)
 Read a file into an ACE_Mem_Map. More...
 
MADARA_Export int read_policy (const std::string &policy_key, const std::string &policy_file)
 Read a policy into the knowledge base. More...
 
MADARA_Export int shape_file (const std::string &source_key, const std::string &target_key, const std::string &policy_key)
 Shape a file according to a shaping policy. More...
 
MADARA_Export ssize_t write_file (const std::string &knowledge_key, const std::string &filename)
 Write a file from the knowledge base to a specified location. More...
 
MADARA_Export ssize_t write_file (const char *filename, void *&buffer, size_t &size)
 Write a memory buffer to file. More...
 

Private Attributes

ThreadSafeContextmap_
 

Static Private Attributes

static const std::string files_folder_ = "files"
 
static const std::string policies_folder_ = "policies"
 

Detailed Description

This class provides file repo capabilities to the knowledge base.

Definition at line 24 of file Files.h.

Constructor & Destructor Documentation

madara::knowledge::Files::Files ( ThreadSafeContext map)

Constructor.

Parameters
mapknowledge context

Definition at line 14 of file Files.cpp.

Member Function Documentation

int madara::knowledge::Files::read_file ( const std::string &  knowledge_key,
const std::string &  filename 
)

Read a file into the knowledge base.

Parameters
filenamefile to read
knowledge_keykey to store the file into

Definition at line 43 of file Files.cpp.

int madara::knowledge::Files::read_file ( const char *  filename,
ACE_Mem_Map &  mem_map 
)

Read a file into an ACE_Mem_Map.

Read a file and update a buffer and size.

Parameters
filenamefile to read
mem_mapmemory map of file
Returns

Definition at line 32 of file Files.cpp.

int madara::knowledge::Files::read_policy ( const std::string &  policy_key,
const std::string &  policy_file 
)

Read a policy into the knowledge base.

Parameters
policy_keykey to read the policy into
policy_filefile to read the policy from

Definition at line 207 of file Files.cpp.

int madara::knowledge::Files::shape_file ( const std::string &  source_key,
const std::string &  target_key,
const std::string &  policy_key 
)

Shape a file according to a shaping policy.

Parameters
source_keyfile that needs to be shaped
target_keytarget key to save the shaped file into
policy_keypolicy to use for shaping the file

Definition at line 21 of file Files.cpp.

ssize_t madara::knowledge::Files::write_file ( const std::string &  knowledge_key,
const std::string &  filename 
)

Write a file from the knowledge base to a specified location.

Parameters
filenamefile to write to
knowledge_keykey to read the file from

Definition at line 111 of file Files.cpp.

ssize_t madara::knowledge::Files::write_file ( const char *  filename,
void *&  buffer,
size_t &  size 
)

Write a memory buffer to file.

Parameters
filenamefile to write to
bufferpointer to buffer
sizesize of the buffer
Returns
amount written to file (-1 if error)

Definition at line 179 of file Files.cpp.

Member Data Documentation

const std::string madara::knowledge::Files::files_folder_ = "files"
staticprivate

Definition at line 88 of file Files.h.

ThreadSafeContext& madara::knowledge::Files::map_
private

Definition at line 94 of file Files.h.

const std::string madara::knowledge::Files::policies_folder_ = "policies"
staticprivate

Definition at line 91 of file Files.h.


The documentation for this class was generated from the following files: