// Custom includes
#include <iostream>
#include "Server.hh"
+#include "Node.hh"
+#include "ScopedDirectory.hh"
#include "../Scheduler/Scheduler.hh"
#include "../Utils/Logger/SenfLog.hh"
#define prefix_
///////////////////////////////cc.p////////////////////////////////////////
+namespace {
+
+ void fn(std::ostream & output, senf::console::ParseCommandInfo const & command) {
+ typedef senf::console::ParseCommandInfo::ArgumentsRange::iterator iterator;
+ iterator i (command.arguments().begin());
+ iterator i_end (command.arguments().end());
+ for (; i != i_end; ++i) {
+ iterator::value_type::iterator j (i->begin());
+ iterator::value_type::iterator j_end (i->end());
+ for (; j != j_end; ++j)
+ output << j->value() << ' ';
+ }
+ output << "\n";
+ }
+
+ struct TestObject
+ {
+ senf::console::ScopedDirectory<TestObject> dir;
+
+ TestObject() : dir(this) {
+ dir.add("blub", &TestObject::blub)
+ .doc("Example of a member function");
+ }
+
+ void blub(std::ostream & output, senf::console::ParseCommandInfo const &) {
+ output << "blub\n";
+ }
+ };
+
+ void shutdownServer(std::ostream &, senf::console::ParseCommandInfo const &)
+ {
+ senf::Scheduler::instance().terminate();
+ throw senf::console::Executor::ExitException();
+ }
+
+}
+
int main(int, char const **)
{
senf::log::ConsoleTarget::instance().route< senf::SenfLog, senf::log::NOTICE >();
- senf::console::Server::start( senf::INet4SocketAddress("127.0.0.1:23232") )
- .name("testServer ");
+ senf::console::root()
+ .doc("This is the console test application");
+ senf::console::root()
+ .mkdir("network")
+ .doc("Network related settings");
+ senf::console::root()["network"]
+ .mkdir("eth0")
+ .doc("Ethernet device eth0");
+ senf::console::root()
+ .mkdir("server");
+ senf::console::root()["server"]
+ .add("shutdown", &shutdownServer)
+ .doc("Terminate server application");
+ senf::console::root()["network"]
+ .add("route", &fn)
+ .doc("Example of a directly registered function");
+
+ TestObject test;
+ senf::console::root()
+ .add("testob", test.dir)
+ .doc("Example of an instance directory");
+
+ senf::console::Server::start( senf::INet4SocketAddress("0.0.0.0:23232") )
+ .name("testServer");
senf::Scheduler::instance().process();
}