File: component2test.cc

package info (click to toggle)
wvstreams 4.0.2-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 6,420 kB
  • ctags: 6,518
  • sloc: cpp: 52,544; sh: 5,770; ansic: 810; makefile: 461; tcl: 114; perl: 18
file content (45 lines) | stat: -rw-r--r-- 1,024 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "wvmoniker.h"
#include "wvistreamlist.h"
#include "wvstreamclone.h"
#include "wvlog.h"
#include "wvlogrcv.h"

#include <assert.h>


int main()
{
    WvLogConsole rcv(2, WvLog::Debug2);
    
    // get streams from a component
    IWvStream *url1 = wvcreate<IWvStream>("http://mai/");
    IWvStream *url2 = wvcreate<IWvStream>("https://mai/~apenwarr/");
    
    // add handy WvStreams-style functionality by cloning them
    WvStreamClone a(url1);
    WvStreamClone b(url2);

    // make them do something useful
    WvLog l1("log1", WvLog::Info);
    WvLog l2("log2", WvLog::Info);
    a.autoforward(l1);
    b.autoforward(l2);
    
    // create a list of them (in fact, we could use a WvStreamList here...)
    WvIStreamList l;
    l.append(&a, false);
    l.append(&b, false);
  
    while (a.isok() || b.isok())
    {
	if (l.select(-1))
	    l.callback();
    }
    
    if (a.geterr())
	wvcon->print("url1: %s\n", a.errstr());
    if (b.geterr())
	wvcon->print("url2: %s\n", b.errstr());
    
    return 0;
}