From: Jan Langer (jan_at_[hidden])
Date: 2002-10-27 19:36:44
i finally had time to try a better implementation of an filesystem
attribute system. it now can be applied as follows:
cache c (path_name);
assert (c.get_path () == get <filename> (c));
size::value_type i = get <size> (c);
put <owner> (c, "nobody");
commit <owner> (c); // now it is on definitly changed
if commit is not called then it is done on c's destruction.
i implemented size, filename, owner and group for posix to demonstrate
the cache itself is nearly a property map according to the one at boost.
but there is no key, the key is the template parameter. it is
implemented by means of a map<type_info, value>.
i need a type_info wrapper as a key for the map. this is exactly what
the TypeInfo class of Loki does. so i just plainly included it as a
header. maybe it can be boostified, because andrei alexandrescu wanted
it in either way.
certain names i chose are not the best choice. so i'm open for any
the attribute objects itself are stored in the cache and can be accessed
size &s = c.at <size> ();
but i am still not really sure what should be allowed to be done with
it is very simple to define user defined attributes and use the same
cache. for example:
: public fs::attribute <true, int,
test_attr (fs::cache &pm)
: base_type (pm), v_ (17)
value_type do_get ()
void do_put (value_type v)
v_ = v;
void do_commit ()
std::string p = get_cache () // get_cache is inherited
std::cout << "commit: " << v_
<< "; file: " << p << '\n';
and it can be used exactly like the builtin-attributes.
i put the implementation in an archive on my homepage
(http://www.langernetz.de/attributes.tar.gz). if you think that this
could be a reasonable approach then i can commit it into the sandbox,
after asking jeremy siek for the right to do so.
-- jan langer ... jan_at_[hidden] "pi ist genau drei"
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk