Files
xahaud/src/ripple/resource/impl/Manager.cpp
Vinnie Falco 2009f8b1ca Add insight support to TaggedCache, KeyCache:
* Move TaggedCache, KeyCache to common
* Add radmap module, FullBelowCache class
* Add get_seconds_clock
* Inject FullBelowCache in SHAMap
2014-02-03 23:00:45 -08:00

124 lines
3.1 KiB
C++

//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012, 2013 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
namespace ripple {
namespace Resource {
class ManagerImp
: public Manager
, public Thread
{
public:
Journal m_journal;
Logic m_logic;
ManagerImp (insight::Collector::ptr const& collector,
Journal journal)
: Thread ("Resource::Manager")
, m_journal (journal)
, m_logic (collector, get_seconds_clock (), journal)
{
startThread ();
}
~ManagerImp ()
{
stopThread ();
}
Consumer newInboundEndpoint (IPAddress const& address)
{
return m_logic.newInboundEndpoint (address);
}
Consumer newOutboundEndpoint (IPAddress const& address)
{
return m_logic.newOutboundEndpoint (address);
}
Consumer newAdminEndpoint (std::string const& name)
{
return m_logic.newAdminEndpoint (name);
}
Gossip exportConsumers ()
{
return m_logic.exportConsumers();
}
void importConsumers (std::string const& origin, Gossip const& gossip)
{
m_logic.importConsumers (origin, gossip);
}
//--------------------------------------------------------------------------
Json::Value getJson ()
{
return m_logic.getJson ();
}
Json::Value getJson (int threshold)
{
return m_logic.getJson (threshold);
}
//--------------------------------------------------------------------------
void onWrite (PropertyStream::Map& map)
{
m_logic.onWrite (map);
}
//--------------------------------------------------------------------------
void run ()
{
do
{
m_logic.periodicActivity();
wait (1000);
}
while (! threadShouldExit ());
}
};
//------------------------------------------------------------------------------
Manager::Manager ()
: PropertyStream::Source ("resource")
{
}
Manager::~Manager ()
{
}
//------------------------------------------------------------------------------
std::unique_ptr <Manager> make_Manager (
insight::Collector::ptr const& collector,
Journal journal)
{
return std::make_unique <ManagerImp> (collector, journal);
}
}
}