30 prefix_ senf::console::detail::RestrictedExecutor::RestrictedExecutor(DirectoryNode &
root)
34 .policy(
senf::membind(&RestrictedExecutor::policyCallback,
this));
38 senf::console::detail::RestrictedExecutor::execute(std::ostream & output,
39 ParseCommandInfo
const & command)
41 executor_.execute(output, command);
45 senf::console::detail::RestrictedExecutor::operator()(std::ostream & output,
46 ParseCommandInfo
const & command)
48 execute(output, command);
52 senf::console::detail::RestrictedExecutor::getNode(ParseCommandInfo
const & command)
54 return executor_.getNode(command);
57 prefix_ bool senf::console::detail::RestrictedExecutor::parsed(GenericNode & node)
60 ParsedNodes::const_iterator i (parsedNodes_.begin());
61 ParsedNodes::const_iterator
const i_end (parsedNodes_.end());
62 for (; i != i_end; ++i)
63 if ( ! i->expired() && node.isChildOf(*(i->lock())) )
68 prefix_ void senf::console::detail::RestrictedExecutor::policyCallback(DirectoryNode & dir,
69 std::string
const &
name)
71 if (dir.hasChild(name)) {
72 GenericNode & item (dir.get(name));
73 if (restrict_ && ! item.isChildOf(*restrict_) && ! item.isDirectory())
74 throw Executor::IgnoreCommandException();
76 throw Executor::IgnoreCommandException();
78 else if (restrict_ && ! dir.isChildOf(*restrict_))
79 throw Executor::IgnoreCommandException();
88 {
return node.expired() || node.lock()->isChildOf(*newNode_); }
95 senf::console::detail::RestrictedExecutor::insertParsedNode(DirectoryNode & node)
98 std::remove_if(parsedNodes_.begin(), parsedNodes_.end(), RemoveNodesFn(node.thisptr())),
100 parsedNodes_.push_back(node.thisptr());
108 detail::RestrictedExecutor::RestrictGuard guard (executor_);
114 detail::RestrictedExecutor::RestrictGuard guard (executor_, restrict);
118 prefix_ void senf::console::ConfigBundle::parseInternal()
121 for (Sources::const_iterator i (sources_.begin()); i != sources_.end(); ++i)
122 (*i)->parse(executor_);
128 prefix_ senf::console::detail::RestrictedExecutor::RestrictGuard::
129 RestrictGuard(RestrictedExecutor & executor)
130 : executor_ (executor)
138 prefix_ senf::console::detail::RestrictedExecutor::RestrictGuard::
139 RestrictGuard(RestrictedExecutor & executor,
DirectoryNode & restrict)
140 : executor_ (executor)
142 executor_.restrict_ = restrict.
thisptr();
145 prefix_ senf::console::detail::RestrictedExecutor::RestrictGuard::~RestrictGuard()
147 if (! std::uncaught_exception())
148 executor_.insertParsedNode( *executor_.restrict_ );
155 prefix_ senf::console::detail::ConfigSource::~ConfigSource()
boost::shared_ptr< DirectoryNode > ptr
Config/console tree directory node.
boost::function< R(Args)> membind(R(T::*fn)(Args), T *ob)
DirectoryNode & root()
Get console root node.
void parse()
Parse config bundle.
unspecified_keyword_type name
Argument name.
boost::weak_ptr< DirectoryNode > weak_ptr
Config/console node tree base-class.