//------------------------------------------------------------------------------ /* Copyright (c) 2011-2013, OpenCoin, Inc. */ //============================================================================== #ifndef RIPPLE_PATHREQUEST_H #define RIPPLE_PATHREQUEST_H // A pathfinding request submitted by a client // The request issuer must maintain a strong pointer class RippleLineCache; // Return values from parseJson <0 = invalid, >0 = valid #define PFR_PJ_INVALID -1 #define PFR_PJ_NOCHANGE 0 #define PFR_PJ_CHANGE 1 class PathRequest : public boost::enable_shared_from_this { public: typedef boost::weak_ptr wptr; typedef boost::shared_ptr pointer; typedef const pointer& ref; typedef const wptr& wref; typedef std::pair currIssuer_t; public: // VFALCO TODO Break the cyclic dependency on InfoSub explicit PathRequest (boost::shared_ptr const& subscriber); bool isValid (const boost::shared_ptr&); bool isValid (); bool isNew (); Json::Value getStatus (); Json::Value doCreate (const boost::shared_ptr&, const Json::Value&); Json::Value doClose (const Json::Value&); Json::Value doStatus (const Json::Value&); bool doUpdate (const boost::shared_ptr&, bool fast); // update jvStatus static void updateAll (const boost::shared_ptr& ledger, bool newOnly); private: void setValid (); int parseJson (const Json::Value&, bool complete); typedef RippleRecursiveMutex LockType; typedef LockType::ScopedLockType ScopedLockType; LockType mLock; boost::weak_ptr wpSubscriber; // Who this request came from Json::Value jvId; Json::Value jvStatus; // Last result // Client request parameters RippleAddress raSrcAccount; RippleAddress raDstAccount; STAmount saDstAmount; std::set sciSourceCurrencies; std::vector vjvBridges; bool bValid; bool bNew; // Track all requests static std::set sRequests; typedef RippleRecursiveMutex StaticLockType; typedef LockType::ScopedLockType StaticScopedLockType; static StaticLockType sLock; }; #endif // vim:ts=4