1
// ---------------------------------------------------------------------------
3
// - afnix:csm module - abstract local space class definition -
4
// ---------------------------------------------------------------------------
5
// - This program is free software; you can redistribute it and/or modify -
6
// - it provided that this copyright notice is kept intact. -
8
// - This program is distributed in the hope that it will be useful, but -
9
// - without any warranty; without even the implied warranty of -
10
// - merchantability or fitness for a particular purpose. In no event shall -
11
// - the copyright holder be liable for any direct, indirect, incidental or -
12
// - special damages arising in any way out of the use of this software. -
13
// ---------------------------------------------------------------------------
14
// - copyright (c) 1999-2015 amaury darsch -
15
// ---------------------------------------------------------------------------
17
#ifndef AFNIX_LOCALSPACE_HPP
18
#define AFNIX_LOCALSPACE_HPP
20
#ifndef AFNIX_WORKSPACE_HPP
21
#include "WorkSpace.hpp"
26
/// The LocalSpace class is a local implementation of the abstract
27
/// workspace class. A local space is constructed with a root directory
28
/// which serves as a root place for the whole workspace. The local space
29
/// is persistent, except for the global temporary directory if it exists.
30
/// There is no protection mechanism with respect to the underlying file
31
/// system hosting the local space. By default, a localspace is created in
32
/// a temporary space so it can be delete also at reboot.
33
/// @author amaury darsch
35
class LocalSpace : public WorkSpace {
37
/// the root directory
39
/// the temporary directory
43
/// create a default local space
46
/// create a local space by root directory
47
/// @param root the root directory
48
LocalSpace (const String& root);
50
/// create a local space by name, info and root directory
51
/// @param name the workspace name
52
/// @param info the workspace info
53
/// @param root the root directory
54
LocalSpace (const String& name, const String& info, const String& root);
56
/// destroy this local space
59
/// @return the class name
60
String repr (void) const;
62
/// check if a zone exists by name
63
/// @param zone the zone to check
64
bool iszone (const String& zone) const;
66
/// add a new working zone by name
67
/// @param zone the zone name
68
bool addzone (const String& zone);
70
/// check if an entity exists by zone and uri
71
/// @param zone the working zone
72
/// @param uri the uri to check
73
bool exists (const String& zone, const Uri& uri) const;
75
/// map a file path to a workspace uri if possible - no public mapping
76
/// @param zone the working zone
77
/// @param name the file name to map
78
String towuri (const String& zone, const String& name) const;
80
/// map a file name to a uri string if possible
81
/// @param zone the working zone
82
/// @param name the file name to map
83
String tonuri (const String& zone, const String& name) const;
85
/// get a workspace zone file list
86
/// @param zone the working zone
87
Strvec* getfiles (const String& zone) const;
89
/// get a workspace zone file list
90
/// get a workspace zone file table
91
/// @param zone the working zone
92
PrintTable* tofptbl (const String& zone) const;
94
/// get an input stream by zone and uri
95
/// @param zone the working zone
96
/// @param uri the uri to open
97
InputStream* getis (const String& zone, const Uri& uri) const;
99
/// get an output stream by zone and uri
100
/// @param zone the working zone
101
/// @param uri the uri to open
102
OutputStream* getos (const String& zone, const Uri& uri) const;
104
/// @return the local root directory
105
virtual String getroot (void) const;
108
// make the copy constructor private
109
LocalSpace (const LocalSpace&);
110
// make the assignment operator private
111
LocalSpace& operator = (const LocalSpace&);
114
/// create a new object in a generic way
115
/// @param argv the argument vector
116
static Object* mknew (Vector* argv);
118
/// @return true if the given quark is defined
119
bool isquark (const long quark, const bool hflg) const;
121
/// apply this object with a set of arguments and a quark
122
/// @param robj the current runnable
123
/// @param nset the current nameset
124
/// @param quark the quark to apply these arguments
125
/// @param argv the arguments to apply
126
Object* apply (Runnable* robj, Nameset* nset, const long quark,