Skip to content

Instantly share code, notes, and snippets.

@aozturk
Last active January 3, 2016 05:49
Show Gist options
  • Select an option

  • Save aozturk/8418146 to your computer and use it in GitHub Desktop.

Select an option

Save aozturk/8418146 to your computer and use it in GitHub Desktop.

Revisions

  1. aozturk revised this gist Jul 16, 2014. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions AMS_API.cpp
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    namespace AMS {
    class IService {
    public:

    // Create or just return a singleton instance
    static IService& instance();
    // Destroy the singleton instance
    @@ -44,6 +44,5 @@ namespace AMS {

    // Run service in debug mode
    void debug_mode() { m_consoleLogger->setLevel("debug"); }

    };
    } //namespace AMS
  2. aozturk revised this gist Jul 16, 2014. 1 changed file with 0 additions and 9 deletions.
    9 changes: 0 additions & 9 deletions AMS_API.cpp
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,3 @@
    #pragma once

    #include "AMS/Net/Context.h"
    #include "AMS/PubSub/PubSub.h"
    #include "AMS/Reactor/Poller.h"
    #include "AMS/Reactor/IHandler.h"
    #include "AMS/Reactor/Dispatcher.h"
    #include "AMS/Discovery/Aliveness.h"

    namespace AMS {
    class IService {
    public:
  3. aozturk revised this gist Jul 16, 2014. 1 changed file with 46 additions and 31 deletions.
    77 changes: 46 additions & 31 deletions AMS_API.cpp
    Original file line number Diff line number Diff line change
    @@ -1,43 +1,58 @@
    // creates or just returns a singleton AMS service instance
    static IService& IService::instance();
    #pragma once

    // creates (or joins to) a messaging domain that is restricted for communication
    void IService::create_domain(std::string domainName, std::string appName);
    #include "AMS/Net/Context.h"
    #include "AMS/PubSub/PubSub.h"
    #include "AMS/Reactor/Poller.h"
    #include "AMS/Reactor/IHandler.h"
    #include "AMS/Reactor/Dispatcher.h"
    #include "AMS/Discovery/Aliveness.h"

    // starts/stops the reactor for both the communication and the dynamic discovery
    void IService::reactor_start();
    void IService::reactor_stop();
    namespace AMS {
    class IService {
    public:

    // creates a subscriber for T-typed messages
    template<typename T>
    void IService::create_subscriber();
    // Create or just return a singleton instance
    static IService& instance();
    // Destroy the singleton instance
    static void destroy();

    // subscribes a handler object for T-typed messages received
    template<typename T>
    void IService::subscribe(IHandler& handler);
    // Create a messaging domain restricted for communication
    void create_domain(std::string domainName, std::string selfDesc);

    // unsubscribes from receiving T-typed messages
    template<typename T>
    void IService::unsubscribe();
    // Create a subscriber for T-typed messages
    template<typename T>
    void create_subscriber();

    // creates a publisher for T-typed messages
    template<typename T>
    void IService::create_publisher();
    // Create a publisher for T-typed messages
    template<typename T>
    void create_publisher();

    // sends a message to all subscribers
    void IService::send_message(IMsgObj& obj);
    // Subscribe a handler to T-typed messages dispatched automatically
    template<typename T>
    void subscribe(IHandler& handler);

    // registers a notifier for peer status updates within the domain
    void IService::register_discovery(IPeerNotification* notifier);
    // Unsubscribe from receiving T-typed messages
    template<typename T>
    void unsubscribe();

    // returns the own host ip address
    std::string IService::get_host_ip() const;
    // Send a message to all subscribers
    void send_message(IMsgObj& obj);

    // destroys the service singleton instance
    static void IService::destroy();
    // Start/stop the reactor for the communication
    void reactor_start();
    void reactor_stop();

    // returns the service global logger
    Poco::Logger& IService::logger();
    // Register a notifier for peer status updates within the domain
    void register_discovery(IPeerNotification* notifier);

    // runs the service in debug mode for exhaustive logging
    void IService::debug_mode();
    // Return the host ip address
    std::string get_host_ip() const;

    // Return the service logger
    Poco::Logger& logger() { return *m_consoleLogger; }

    // Run service in debug mode
    void debug_mode() { m_consoleLogger->setLevel("debug"); }

    };
    } //namespace AMS
  4. aozturk renamed this gist Jul 16, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. aozturk revised this gist Apr 20, 2014. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions AMS_API.h
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@

    // creates or just returns a singleton AMS service instance
    static IService& IService::instance();

    @@ -41,4 +40,4 @@ static void IService::destroy();
    Poco::Logger& IService::logger();

    // runs the service in debug mode for exhaustive logging
    void IService::debug_mode();
    void IService::debug_mode();
  6. aozturk revised this gist Apr 20, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion AMS_API.h
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@

    // creates or just returns a singleton AMS service instance
    static IService& IService::instance();

    @@ -40,4 +41,4 @@ static void IService::destroy();
    Poco::Logger& IService::logger();

    // runs the service in debug mode for exhaustive logging
    void IService::debug_mode();
    void IService::debug_mode();
  7. aozturk revised this gist Jan 14, 2014. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions AMS_API.h
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    /// creates or just returns a singleton AMS service instance
    // creates or just returns a singleton AMS service instance
    static IService& IService::instance();

    // creates (or joins to) a messaging domain that is restricted for communication
    @@ -26,18 +26,18 @@ void IService::create_publisher();

    // sends a message to all subscribers
    void IService::send_message(IMsgObj& obj);
    Registers a notifier for peer status updates within the domain

    // registers a notifier for peer status updates within the domain
    void IService::register_discovery(IPeerNotification* notifier);
    Returns the own host ip address

    // returns the own host ip address
    std::string IService::get_host_ip() const;
    Destroys the service singleton instance

    // destroys the service singleton instance
    static void IService::destroy();
    Returns the service global logger

    // returns the service global logger
    Poco::Logger& IService::logger();
    Runs the service in debug mode for exhaustive logging

    // runs the service in debug mode for exhaustive logging
    void IService::debug_mode();
  8. aozturk revised this gist Jan 14, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion AMS_API.h
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    /* creates or just returns a singleton AMS service instance */
    /// creates or just returns a singleton AMS service instance
    static IService& IService::instance();

    // creates (or joins to) a messaging domain that is restricted for communication
  9. aozturk revised this gist Jan 14, 2014. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions AMS_API.h
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,4 @@
    /**
    * creates or just returns a singleton AMS service instance
    */
    /* creates or just returns a singleton AMS service instance */
    static IService& IService::instance();

    // creates (or joins to) a messaging domain that is restricted for communication
  10. aozturk created this gist Jan 14, 2014.
    45 changes: 45 additions & 0 deletions AMS_API.h
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@
    /**
    * creates or just returns a singleton AMS service instance
    */
    static IService& IService::instance();

    // creates (or joins to) a messaging domain that is restricted for communication
    void IService::create_domain(std::string domainName, std::string appName);

    // starts/stops the reactor for both the communication and the dynamic discovery
    void IService::reactor_start();
    void IService::reactor_stop();

    // creates a subscriber for T-typed messages
    template<typename T>
    void IService::create_subscriber();

    // subscribes a handler object for T-typed messages received
    template<typename T>
    void IService::subscribe(IHandler& handler);

    // unsubscribes from receiving T-typed messages
    template<typename T>
    void IService::unsubscribe();

    // creates a publisher for T-typed messages
    template<typename T>
    void IService::create_publisher();

    // sends a message to all subscribers
    void IService::send_message(IMsgObj& obj);
    Registers a notifier for peer status updates within the domain

    void IService::register_discovery(IPeerNotification* notifier);
    Returns the own host ip address

    std::string IService::get_host_ip() const;
    Destroys the service singleton instance

    static void IService::destroy();
    Returns the service global logger

    Poco::Logger& IService::logger();
    Runs the service in debug mode for exhaustive logging

    void IService::debug_mode();