SysInfo.cc
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
17 #include "SysInfo.hh"
18 
19 // Custom includes
20 #include "ScopedDirectory.hh"
21 #include "ParsedCommand.hh"
22 #include "Sysdir.hh"
23 
24 #define prefix_
25 //-/////////////////////////////////////////////////////////////////////////////////////////////////
26 
27 prefix_ senf::console::SysInfo::Proxy::Proxy(std::string const & name, std::string const & entry, int pos)
28 {
29  SysInfo::instance().setEntry( name, entry, pos);
30 }
31 
32 prefix_ senf::console::SysInfo::SysInfo()
33 {
34  sysdir().add("info", factory::Command(&SysInfo::dump, this));
35 }
36 
37 prefix_ void senf::console::SysInfo::setEntry(std::string const & name, std::string const & entry, int pos)
38 {
39  for (Entries::iterator d (entries_.begin()); d != entries_.end(); ++d) {
40  if (d->first.second == name) {
41  entries_.erase(d);
42  break;
43  }
44  }
45  entries_.insert( std::make_pair( std::make_pair(
46  pos < 0 ? std::numeric_limits<int>::max() : pos, name), entry));
47 }
48 
49 prefix_ void senf::console::SysInfo::dump(std::ostream & os)
50  const
51 {
52  for(auto const & entry: entries_) {
53  os << entry.second << std::endl;
54  }
55 }
56 
57 //-/////////////////////////////////////////////////////////////////////////////////////////////////
58 #undef prefix_
59 
60 
61 
62 // Local Variables:
63 // mode: c++
64 // fill-column: 100
65 // c-file-style: "senf"
66 // indent-tabs-mode: nil
67 // ispell-local-dictionary: "american"
68 // compile-command: "scons -u test"
69 // comment-column: 40
70 // End:
void setEntry(std::string const &name, std::string const &entry, int pos=-1)
Definition: SysInfo.cc:37
ScopedDirectory public header.
ScopedDirectory & sysdir()
Sysdir public header.
OverloadedCommandNode factory.
ParsedCommand public header.
SysInfo public header.
Proxy(std::string const &name, std::string const &entry, int pos=-1)
Definition: SysInfo.cc:27
static Self & instance()
#define prefix_
Definition: SysInfo.cc:24
unspecified_keyword_type name
Argument name.
void dump(std::ostream &os) const
Definition: SysInfo.cc:49
NodeType & add(std::string const &name, boost::shared_ptr< NodeType > node)