]> git.mxchange.org Git - simgear.git/blobdiff - simgear/package/Root.hxx
Tweak HTTP code to always sleep.
[simgear.git] / simgear / package / Root.hxx
index ef232187d0d7c548e3c56964c8a69b9a6a631bea..176651091e98429e44f5777b886f16266653539c 100644 (file)
@@ -19,9 +19,7 @@
 #define SG_PACKAGE_ROOT_HXX
 
 #include <vector>
-#include <map>
-#include <deque>
-#include <set>
+#include <memory> // for auto_ptr
 
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/package/Delegate.hxx>
@@ -31,7 +29,10 @@ class SGPropertyNode;
 namespace simgear
 {
     
-namespace HTTP { class Client; }
+namespace HTTP {
+    class Client;
+    class Request;
+}
     
 namespace pkg
 {
@@ -44,16 +45,13 @@ class Install;
 typedef std::vector<Package*> PackageList;
 typedef std::vector<Catalog*> CatalogList;
 
-typedef std::map<std::string, Catalog*> CatalogDict;
-
 class Root
 {
 public:
     Root(const SGPath& aPath, const std::string& aVersion);
     virtual ~Root();
     
-    SGPath path() const
-        { return m_path; }
+    SGPath path() const;
     
     void setLocale(const std::string& aLocale);
         
@@ -63,12 +61,18 @@ public:
     
     CatalogList catalogs() const;
         
-    void setMaxAgeSeconds(int seconds);
-
+    void setMaxAgeSeconds(unsigned int seconds);
+    unsigned int maxAgeSeconds() const;
+    
     void setHTTPClient(HTTP::Client* aHTTP);
 
-    HTTP::Client* getHTTPClient() const;
-
+    /**
+     * Submit an HTTP request. The Root may delay or queue requests if it needs
+     * too, for example during startup when the HTTP engine may not have been
+     * set yet.
+     */
+    void makeHTTPRequest(HTTP::Request* req);
+    
     /**
      * the version string of the root. Catalogs must match this version,
      * or they will be ignored / rejected.
@@ -112,18 +116,10 @@ private:
     void installProgress(Install* aInstall, unsigned int aBytes, unsigned int aTotal);
     void finishInstall(Install* aInstall);    
     void failedInstall(Install* aInstall, Delegate::FailureCode aReason);
-    
-    SGPath m_path;
-    std::string m_locale;
-    HTTP::Client* m_http;
-    CatalogDict m_catalogs;
-    unsigned int m_maxAgeSeconds;
-    Delegate* m_delegate;
-    std::string m_version;
-    
-    std::set<Catalog*> m_refreshing;
-    std::deque<Install*> m_updateDeque;
-};  
+
+    class RootPrivate;
+    std::auto_ptr<RootPrivate> d;
+};
     
 } // of namespace pkg