Changeset 96c1461 in nscp for include/nscapi/targets.hpp


Ignore:
Timestamp:
11/27/11 22:04:35 (18 months ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2
Children:
9853bc3
Parents:
16198e3
Message:
  • Major refactoring in the command line interface
  • Added support for alias to many common module (command line) so: nscp eventlog (is the same as nscp client --module CheckEventLog)
  • Fixed issue with CheckEventLog message rendering and eventid
  • Refactored all Client modules to all support command line, commands and submissions.
  • Added uniform handling of "everything" to all Client plugins
  • Fixed SyslogClient to work "as advertised" (ie. all hardcoded stuff is removed)
  • Fixed utf8 issue with text strings (now have a working concept which needs to be implementd "all over the place")
  • Many issues and fixes related to clients.
  • Fixed so CheckEvent? log (insert) works much better (added new options)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • include/nscapi/targets.hpp

    r7515d00 r96c1461  
    1111#include <nscapi/settings_proxy.hpp> 
    1212 
     13#include <net/net.hpp> 
     14 
    1315namespace nscapi { 
    1416  struct target_handler { 
     
    1719      std::wstring host; 
    1820      std::wstring alias; 
    19       std::wstring protocol; 
     21      //std::wstring protocol; 
     22      std::wstring address; 
    2023      std::wstring parent; 
    2124      typedef std::map<std::wstring,std::wstring> options_type; 
     
    2629        ss << _T("Target: ") << alias; 
    2730        ss << _T(", host: ") << host; 
    28         ss << _T(", protocol: ") << protocol; 
     31//        ss << _T(", protocol: ") << protocol; 
     32        ss << _T(", address: ") << address; 
    2933        ss << _T(", parent: ") << parent; 
    3034        BOOST_FOREACH(options_type::value_type o, options) { 
     
    3236        } 
    3337        return ss.str(); 
     38      } 
     39 
     40      bool has_protocol() { 
     41        return !address.empty(); 
     42      } 
     43      std::wstring get_protocol() { 
     44        net::wurl url = net::parse(address); 
     45        return url.protocol; 
     46      } 
     47      bool has_option(std::wstring key) { 
     48        return options.find(key) != options.end(); 
     49      } 
     50      bool has_option(std::string key) { 
     51        return has_option(utf8::cvt<std::wstring>(key)); 
    3452      } 
    3553 
     
    4058    target_list_type target_list; 
    4159    target_list_type template_list; 
    42     void add(boost::shared_ptr<nscapi::settings_proxy> proxy, std::wstring path, std::wstring key, std::wstring value) { 
    43       add(read_target(proxy, path, key, value)); 
     60    target add(boost::shared_ptr<nscapi::settings_proxy> proxy, std::wstring path, std::wstring key, std::wstring value) { 
     61      target t = read_target(proxy, path, key, value); 
     62      add(t); 
     63      return t; 
    4464    } 
    4565    void add(target t) { 
     
    5070    } 
    5171    target read_target(boost::shared_ptr<nscapi::settings_proxy> proxy, std::wstring path, std::wstring alias, std::wstring host); 
     72    void rebuild(); 
    5273 
    5374    optarget find_target(std::wstring alias); 
     75    bool has_target(std::wstring alias); 
    5476    static void apply_parent(target &t, target &p); 
    5577    std::wstring to_wstring(); 
Note: See TracChangeset for help on using the changeset viewer.