mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
New SiteFiles for fetching and managing ripple.txt files
This commit is contained in:
45
src/ripple/sitefiles/api/Listener.h
Normal file
45
src/ripple/sitefiles/api/Listener.h
Normal file
@@ -0,0 +1,45 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_SITEFILES_LISTENER_H_INCLUDED
|
||||
#define RIPPLE_SITEFILES_LISTENER_H_INCLUDED
|
||||
|
||||
namespace ripple {
|
||||
namespace SiteFiles {
|
||||
|
||||
/** SiteFiles listeners receive notifications on new files and sections.
|
||||
Calls are made on an implementation-defined, unspecified thread.
|
||||
Subclasses implementations should not perform blocking i/o or take
|
||||
a long time.
|
||||
*/
|
||||
class Listener
|
||||
{
|
||||
public:
|
||||
/** Called every time a new site file is retrieved.
|
||||
Notifications for Site files retrieved before a listener was added will
|
||||
be sent at the time the listener is added.
|
||||
*/
|
||||
virtual void onSiteFileFetch (
|
||||
std::string const& name, SiteFile const& siteFile) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
59
src/ripple/sitefiles/api/Manager.h
Normal file
59
src/ripple/sitefiles/api/Manager.h
Normal file
@@ -0,0 +1,59 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_SITEFILES_MANAGER_H_INCLUDED
|
||||
#define RIPPLE_SITEFILES_MANAGER_H_INCLUDED
|
||||
|
||||
namespace ripple {
|
||||
namespace SiteFiles {
|
||||
|
||||
/** Fetches and maintains a collection of ripple.txt files from domains. */
|
||||
class Manager
|
||||
: public Stoppable
|
||||
, public PropertyStream::Source
|
||||
{
|
||||
protected:
|
||||
explicit Manager (Stoppable& parent);
|
||||
|
||||
public:
|
||||
/** Create a new Manager. */
|
||||
static Manager* New (Stoppable& parent, Journal journal);
|
||||
|
||||
/** Destroy the object.
|
||||
Any pending fetch operations are aborted.
|
||||
*/
|
||||
virtual ~Manager () { }
|
||||
|
||||
/** Adds a listener. */
|
||||
virtual void addListener (Listener& listener) = 0;
|
||||
|
||||
/** Remove a listener. */
|
||||
virtual void removeListener (Listener& listener) = 0;
|
||||
|
||||
/** Add a URL leading to a ripple.txt file.
|
||||
This call does not block. The URL will be fetched asynchronously.
|
||||
Parsing errors are reported to the journal.
|
||||
*/
|
||||
virtual void addURL (std::string const& urlstr) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
56
src/ripple/sitefiles/api/Section.h
Normal file
56
src/ripple/sitefiles/api/Section.h
Normal file
@@ -0,0 +1,56 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_SITEFILES_SECTION_H_INCLUDED
|
||||
#define RIPPLE_SITEFILES_SECTION_H_INCLUDED
|
||||
|
||||
namespace ripple {
|
||||
namespace SiteFiles {
|
||||
|
||||
/** A Site File section.
|
||||
Each section has a name, an associative map of key/value pairs,
|
||||
and a vector of zero or more free-form data strings.
|
||||
*/
|
||||
class Section
|
||||
{
|
||||
public:
|
||||
typedef boost::unordered_map <std::string, std::string> MapType;
|
||||
typedef std::vector <std::string> DataType;
|
||||
|
||||
Section(int = 0); // dummy argument for emplace()
|
||||
|
||||
// Observers
|
||||
std::string const& get (std::string const& key) const;
|
||||
std::string const& operator[] (std::string const& key) const;
|
||||
DataType const& data() const;
|
||||
|
||||
// Modifiers
|
||||
void set (std::string const& key, std::string const& value);
|
||||
std::string& operator[] (std::string const& key);
|
||||
void push_back (std::string const& data);
|
||||
|
||||
private:
|
||||
MapType m_map;
|
||||
DataType m_data;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
49
src/ripple/sitefiles/api/SiteFile.h
Normal file
49
src/ripple/sitefiles/api/SiteFile.h
Normal file
@@ -0,0 +1,49 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_SITEFILES_SITEFILE_H_INCLUDED
|
||||
#define RIPPLE_SITEFILES_SITEFILE_H_INCLUDED
|
||||
|
||||
namespace ripple {
|
||||
namespace SiteFiles {
|
||||
|
||||
class SiteFile
|
||||
{
|
||||
public:
|
||||
SiteFile (int = 0); // dummy argument for emplace
|
||||
|
||||
typedef boost::unordered_map <std::string, Section> SectionsType;
|
||||
|
||||
/** Retrieve a section by name. */
|
||||
/** @{ */
|
||||
Section const& get (std::string const& name) const;
|
||||
Section const& operator[] (std::string const& key) const;
|
||||
/** @} */
|
||||
|
||||
/** Retrieve or create a section with the specified name. */
|
||||
Section& insert (std::string const& name);
|
||||
|
||||
private:
|
||||
SectionsType m_sections;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user