|
Boost : |
From: Jan Langer (jan_at_[hidden])
Date: 2002-02-26 16:00:28
On Tue, 26 Feb 2002, Jan Langer wrote:
>On Tue, 26 Feb 2002, dylan_nicholson wrote:
>>We need something better than require() for setting multiple
>>properties: Let's say I wanted to set the owner and group at the
>>same time, and doing both together at the OS level would take half as
>>long as doing one then the other.
>>The best I can think of is:
>>
>> attribute_set a(my_file_name);
>> a.defer();
>> a.set<owner>("dylan");
>> a.set<group>("users");
>> a.commit();
>>
>>defer() and commit() again are completely optional. If you only need
>>one attribute, or don't care about the potential performance hit,
>>then leave them out. I would probably go further and say an
>>implementation is allowed to ignore them too, so that failing to call
>>commit() after defer() has an implementation-defined outcome.
>
>why not drop the defer() and say that calls to set can always be
>buffered. you can also commit (or flush) them be hand or at least on
>destruction of the attribute_set.
>i'll try to write an implementation of an (at least two) example
>attributes.
i updated the posix-version again.
i added a hierarchy_iterator which can be used like this:
std::vector <std::string> v (hierarchy_iterator::begin (),
hierarchy_iterator::end ());
it returns always "/" on dereferenciation and has only two states: begin
and end.
i added the attributes user and group for testing purposes.
and implemented the commit mechanism for buffered attribute setting
proposed by dylan (see above) . this is illustrated in the example
owner_test.cpp which compares the time used on changing the attributes.
it works like this:
{
attribute_set a (file);
set <group <char> > (a, "users");
commit <group <char> > (a); // write group
set <user <char> > (a, "jan");
} // write user
or
{
attribute_set a (file);
set <group <char> > (a, "users");
set <user <char> > (a, "jan");
} // write user and group
or
{
set <group <char> > (file, "users"); // write group
set <user <char> > (file, "jan"); // write user
}
-- 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