From: tho Date: Wed, 16 Jun 2010 13:04:15 +0000 (+0000) Subject: added Version.hh X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=80afad5e6501794ebf74e49ebd7220fa355b4fce;p=senf.git added Version.hh Console: added sys/info command git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1638 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/SConscript b/senf/SConscript index e022ad3..f9fd61b 100644 --- a/senf/SConscript +++ b/senf/SConscript @@ -16,3 +16,19 @@ SConscript("Ext/SConscript") env.InstallSubdir(target = '$INCLUDEINSTALLDIR', source = sorted(env.Glob("*.hh", strings=True))) + +# Create Version.hh +MAJOR = 1 +MINOR = 1 +REV = int(os.popen("svn info | grep 'Last Changed Rev:' | awk '{print $4}'").read().strip().lower()) +env.CreateFile("Version.hh", env.Value( + '// auto-generated file.\n\n' + '#ifndef HH_SENF_Version\n' + '#define HH_SENF_Version\n\n' + '// SENF_VERSION %% 100000 is the revision number\n' + '// SENF_VERSION / 100000 %% 100 is the minor version\n' + '// SENF_VERSION / 10000000 is the major version\n' + '#define SENF_VERSION %(MAJOR)d%(MINOR)02d%(REV)05d\n\n' + '#define SENF_LIB_VERSION "%(MAJOR)d.%(MINOR)02d"\n\n' + '#define SENF_REVISION "%(REV)d"\n\n' + '#endif\n' % locals()) ) diff --git a/senf/Utils/Console/Server.cc b/senf/Utils/Console/Server.cc index 48ac147..8eb41ac 100644 --- a/senf/Utils/Console/Server.cc +++ b/senf/Utils/Console/Server.cc @@ -36,14 +36,23 @@ #include #include #include +#include #include "LineEditor.hh" #include "ScopedDirectory.hh" #include "Sysdir.hh" +#include "SysInfo.hh" #include "ParsedCommand.hh" //#include "Server.mpp" #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// +namespace { + senf::console::SysInfo::Proxy addSysInfo ( + "SENF: The Simple and Extensible Network Framework\n" + " © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research\n" + " Contact: senf-dev@lists.berlios.de\n" + " Version: " SENF_LIB_VERSION " Revision number: " SENF_REVISION "\n", 0); +} /////////////////////////////////////////////////////////////////////////// // senf::console::detail::NonBlockingSocketSink diff --git a/senf/Utils/Console/SysInfo.cc b/senf/Utils/Console/SysInfo.cc new file mode 100644 index 0000000..093453c --- /dev/null +++ b/senf/Utils/Console/SysInfo.cc @@ -0,0 +1,77 @@ +// $Id$ +// +// Copyright (C) 2010 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Thorsten Horstmann +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +/** \file + \brief SysInfo non-inline non-template implementation */ + +#include "SysInfo.hh" + +// Custom includes +#include +#include "ScopedDirectory.hh" +#include "Sysdir.hh" +#include "ParsedCommand.hh" + +#define prefix_ +///////////////////////////////cc.p//////////////////////////////////////// + +prefix_ senf::console::SysInfo::Proxy::Proxy(std::string const & descr, unsigned pos) +{ + SysInfo::instance().addEntry( descr, pos); +} + +prefix_ senf::console::SysInfo::SysInfo() +{ + sysdir().add("info", factory::Command(&SysInfo::dump, this)); +} + +prefix_ void senf::console::SysInfo::addEntry(std::string const & descr, unsigned pos) +{ + if (pos < 0) + descr_.push_back( descr); + else + descr_.insert( boost::next(descr_.begin(), pos > descr_.size() ? descr_.size() : pos), descr); + +} + +prefix_ void senf::console::SysInfo::dump(std::ostream & os) + const +{ + BOOST_FOREACH( std::string const & d, descr_) { + os << d << std::endl; + } +} + +///////////////////////////////cc.e//////////////////////////////////////// +#undef prefix_ + + + +// Local Variables: +// mode: c++ +// fill-column: 100 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// comment-column: 40 +// End: diff --git a/senf/Utils/Console/SysInfo.hh b/senf/Utils/Console/SysInfo.hh new file mode 100644 index 0000000..2a08e7c --- /dev/null +++ b/senf/Utils/Console/SysInfo.hh @@ -0,0 +1,63 @@ +// $Id$ +// +// Copyright (C) 2010 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Thorsten Horstmann +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +/** \file + \brief SysInfo public header */ + +#ifndef HH_SENF_Scheduler_Console_SysInfo_ +#define HH_SENF_Scheduler_Console_SysInfo_ 1 + +// Custom includes +#include +#include + +///////////////////////////////hh.p//////////////////////////////////////// +namespace senf { +namespace console { + + class SysInfo + : public singleton + { + public: + using singleton::instance; + void addEntry(std::string const & descr, unsigned pos=-1); + + struct Proxy { + Proxy(std::string const & descr, unsigned pos=-1); + }; + + private: + std::list descr_; + + SysInfo(); + void dump(std::ostream & os) const; + + friend class singleton; + }; + +}} + +///////////////////////////////hh.e//////////////////////////////////////// +//#include "SysInfo.cci" +//#include "SysInfo.ct" +//#include "SysInfo.cti" +#endif