/* */ #include "RpcMethodFactory.h" #include "RpcMethodImpl.h" #include "OptionParser.h" #include "OptionHandler.h" namespace aria2 { namespace rpc { namespace { std::map> cache; } // namespace namespace { std::unique_ptr noSuchRpcMethod; } // namespace namespace { std::unique_ptr createMethod(const std::string& methodName) { if(methodName == AddUriRpcMethod::getMethodName()) { return make_unique(); #ifdef ENABLE_BITTORRENT } else if(methodName == AddTorrentRpcMethod::getMethodName()) { return make_unique(); #endif // ENABLE_BITTORRENT #ifdef ENABLE_METALINK } else if(methodName == AddMetalinkRpcMethod::getMethodName()) { return make_unique(); #endif // ENABLE_METALINK } else if(methodName == RemoveRpcMethod::getMethodName()) { return make_unique(); } else if(methodName == PauseRpcMethod::getMethodName()) { return make_unique(); } else if(methodName == ForcePauseRpcMethod::getMethodName()) { return make_unique(); } else if(methodName == PauseAllRpcMethod::getMethodName()) { return make_unique(); } else if(methodName == ForcePauseAllRpcMethod::getMethodName()) { return make_unique(); } else if(methodName == UnpauseRpcMethod::getMethodName()) { return make_unique(); } else if(methodName == UnpauseAllRpcMethod::getMethodName()) { return make_unique(); } else if(methodName == ForceRemoveRpcMethod::getMethodName()) { return make_unique(); } else if(methodName == ChangePositionRpcMethod::getMethodName()) { return make_unique(); } else if(methodName == TellStatusRpcMethod::getMethodName()) { return make_unique(); } else if(methodName == GetUrisRpcMethod::getMethodName()) { return make_unique(); } else if(methodName == GetFilesRpcMethod::getMethodName()) { return make_unique(); #ifdef ENABLE_BITTORRENT } else if(methodName == GetPeersRpcMethod::getMethodName()) { return make_unique(); #endif // ENABLE_BITTORRENT } else if(methodName == GetServersRpcMethod::getMethodName()) { return make_unique(); } else if(methodName == TellActiveRpcMethod::getMethodName()) { return make_unique(); } else if(methodName == TellWaitingRpcMethod::getMethodName()) { return make_unique(); } else if(methodName == TellStoppedRpcMethod::getMethodName()) { return make_unique(); } else if(methodName == GetOptionRpcMethod::getMethodName()) { return make_unique(); } else if(methodName == ChangeUriRpcMethod::getMethodName()) { return make_unique(); } else if(methodName == ChangeOptionRpcMethod::getMethodName()) { return make_unique(); } else if(methodName == GetGlobalOptionRpcMethod::getMethodName()) { return make_unique(); } else if(methodName == ChangeGlobalOptionRpcMethod::getMethodName()) { return make_unique(); } else if(methodName == PurgeDownloadResultRpcMethod::getMethodName()) { return make_unique(); } else if(methodName == RemoveDownloadResultRpcMethod::getMethodName()) { return make_unique(); } else if(methodName == GetVersionRpcMethod::getMethodName()) { return make_unique(); } else if(methodName == GetSessionInfoRpcMethod::getMethodName()) { return make_unique(); } else if(methodName == ShutdownRpcMethod::getMethodName()) { return make_unique(); } else if(methodName == ForceShutdownRpcMethod::getMethodName()) { return make_unique(); } else if(methodName == GetGlobalStatRpcMethod::getMethodName()) { return make_unique(); } else if(methodName == SaveSessionRpcMethod::getMethodName()) { return make_unique(); } else if(methodName == SystemMulticallRpcMethod::getMethodName()) { return make_unique(); } else { return nullptr; } } } // namespace RpcMethod* getMethod(const std::string& methodName) { auto itr = cache.find(methodName); if(itr == cache.end()) { auto m = createMethod(methodName); if(m) { auto rv = cache.insert(std::make_pair(methodName, std::move(m))); return (*rv.first).second.get(); } else { if(!noSuchRpcMethod) { noSuchRpcMethod = make_unique(); } return noSuchRpcMethod.get(); } } else { return (*itr).second.get(); } } } // namespace rpc } // namespace aria2