#pragma once #include #include #include #include namespace xrpl { // Forward declarations namespace NodeStore { class Database; } namespace Resource { class Manager; } namespace perf { class PerfLog; } // This is temporary until we migrate all code to use ServiceRegistry. class Application; template < class Key, class T, bool IsKeyCache, class SharedWeakUnionPointer, class SharedPointerType, class Hash, class KeyEqual, class Mutex> class TaggedCache; class STLedgerEntry; using SLE = STLedgerEntry; using CachedSLEs = TaggedCache; // Forward declarations class AcceptedLedger; class AmendmentTable; class Cluster; class CollectorManager; class DatabaseCon; class Family; class HashRouter; class InboundLedgers; class InboundTransactions; class JobQueue; class LedgerCleaner; class LedgerMaster; class LedgerReplayer; class LoadFeeTrack; class LoadManager; class ManifestCache; class NetworkOPs; class NetworkIDService; class OpenLedger; class OrderBookDB; class Overlay; class PathRequestManager; class PeerReservationTable; class PendingSaves; class RelationalDatabase; class ServerHandler; class SHAMapStore; class TimeKeeper; class TransactionMaster; class TxQ; class ValidatorList; class ValidatorSite; template class Validations; class RCLValidationsAdaptor; using RCLValidations = Validations; using NodeCache = TaggedCache; /** Service registry for dependency injection. This abstract interface provides access to various services and components used throughout the application. It separates the service locator pattern from the Application lifecycle management. Components that need access to services can hold a reference to ServiceRegistry rather than Application when they only need service access and not lifecycle management. */ class ServiceRegistry { public: ServiceRegistry() = default; virtual ~ServiceRegistry() = default; // Core infrastructure services virtual CollectorManager& getCollectorManager() = 0; virtual Family& getNodeFamily() = 0; virtual TimeKeeper& getTimeKeeper() = 0; virtual JobQueue& getJobQueue() = 0; virtual NodeCache& getTempNodeCache() = 0; virtual CachedSLEs& getCachedSLEs() = 0; virtual NetworkIDService& getNetworkIDService() = 0; // Protocol and validation services virtual AmendmentTable& getAmendmentTable() = 0; virtual HashRouter& getHashRouter() = 0; virtual LoadFeeTrack& getFeeTrack() = 0; virtual LoadManager& getLoadManager() = 0; virtual RCLValidations& getValidations() = 0; virtual ValidatorList& getValidators() = 0; virtual ValidatorSite& getValidatorSites() = 0; virtual ManifestCache& getValidatorManifests() = 0; virtual ManifestCache& getPublisherManifests() = 0; // Network services virtual Overlay& getOverlay() = 0; virtual Cluster& getCluster() = 0; virtual PeerReservationTable& getPeerReservations() = 0; virtual Resource::Manager& getResourceManager() = 0; // Storage services virtual NodeStore::Database& getNodeStore() = 0; virtual SHAMapStore& getSHAMapStore() = 0; virtual RelationalDatabase& getRelationalDatabase() = 0; // Ledger services virtual InboundLedgers& getInboundLedgers() = 0; virtual InboundTransactions& getInboundTransactions() = 0; virtual TaggedCache& getAcceptedLedgerCache() = 0; virtual LedgerMaster& getLedgerMaster() = 0; virtual LedgerCleaner& getLedgerCleaner() = 0; virtual LedgerReplayer& getLedgerReplayer() = 0; virtual PendingSaves& getPendingSaves() = 0; virtual OpenLedger& getOpenLedger() = 0; virtual OpenLedger const& getOpenLedger() const = 0; // Transaction and operation services virtual NetworkOPs& getOPs() = 0; virtual OrderBookDB& getOrderBookDB() = 0; virtual TransactionMaster& getMasterTransaction() = 0; virtual TxQ& getTxQ() = 0; virtual PathRequestManager& getPathRequestManager() = 0; // Server services virtual ServerHandler& getServerHandler() = 0; virtual perf::PerfLog& getPerfLog() = 0; // Configuration and state virtual bool isStopping() const = 0; virtual beast::Journal getJournal(std::string const& name) = 0; virtual boost::asio::io_context& getIOContext() = 0; virtual Logs& getLogs() = 0; virtual std::optional const& getTrapTxID() const = 0; /** Retrieve the "wallet database" */ virtual DatabaseCon& getWalletDB() = 0; // Temporary: Get the underlying Application for functions that haven't // been migrated yet. This should be removed once all code is migrated. virtual Application& getApp() = 0; }; } // namespace xrpl