ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/GoogleTron/GoogleTron.cpp
Revision: 677
Committed: 2006-03-04T07:11:04-08:00 (19 years, 3 months ago) by douglas
File size: 1442 byte(s)
Log Message:
I should probably go to sleep now...

File Contents

# User Rev Content
1 douglas 672 // Google Tron
2     //
3     // Douglas Thrift
4     //
5     // $Id$
6    
7     #include <cxx/standard.hh>
8    
9 douglas 673 #include <api/process.hpp>
10 douglas 672 #include <app/simple.hpp>
11 douglas 673 #include <xml/textwriter.hpp>
12 douglas 672
13 douglas 676 #include "GoogleTron.hpp"
14 douglas 674 #include "GzipWriter.hpp"
15 douglas 677 #include "Sleep.hpp"
16 douglas 674
17 douglas 672 int Main(const app::Options &options)
18     {
19 douglas 677 GoogleTron tron(_B("sitemap.gz"));
20 douglas 676
21     return 0;
22     }
23    
24 douglas 677 GoogleTron::GoogleTron(const cse::String &sitemap) : working(true), sitemap(sitemap)
25 douglas 676 {
26 douglas 677 // XXX: start some threads
27 douglas 676 }
28    
29     GoogleTron::~GoogleTron()
30     {
31 douglas 677 // XXX: wait on threads
32    
33     working = false;
34    
35     // XXX: wait on output thread
36 douglas 676 }
37    
38     int GoogleTron::Output()
39     {
40 douglas 677 _S<GzipWriter> gzip(sitemap);
41 douglas 674 _S<xml::TextWriter> writer(gzip);
42 douglas 673 xml::ScopeElement urlset(writer, _B("urlset"));
43    
44     writer.SetAttribute(_B("xmlns"), _B("http://www.google.com/schemas/sitemap/0.84"));
45    
46 douglas 677 do
47     {
48     Sleep();
49    
50     _synchronized (queueLock)
51     if (queue.size())
52     {
53     xml::ScopeElement url_(writer, _B("url"));
54     const Url &url(queue.front());
55    
56     {
57     xml::ScopeElement loc(writer, _B("loc"));
58    
59     writer.OutputText(url.GetLocation());
60     }
61    
62     {
63     xml::ScopeElement lastmod(writer, _B("lastmod"));
64    
65     writer.OutputText(url.GetModified());
66     }
67    
68     {
69     xml::ScopeElement changefreq(writer, _B("changefreq"));
70    
71     writer.OutputText(url.GetFrequency());
72     }
73    
74     {
75     xml::ScopeElement priority(writer, _B("priority"));
76    
77     writer.OutputText(url.GetPriority());
78     }
79    
80     queue.pop();
81     }
82     }
83     while (working);
84    
85 douglas 672 return 0;
86     }

Properties

Name Value
svn:eol-style native
svn:keywords Id