git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/Streamer@69149 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -1,7 +1,13 @@ |
1 |
-\name{Stream-class} |
|
1 |
+\name{Stream} |
|
2 | 2 |
\Rdversion{1.1} |
3 | 3 |
\docType{class} |
4 | 4 |
\alias{Stream-class} |
5 |
+ |
|
6 |
+\alias{Stream} |
|
7 |
+\alias{Stream-methods} |
|
8 |
+\alias{Stream,Consumer-method} |
|
9 |
+\alias{Stream,Producer-method} |
|
10 |
+ |
|
5 | 11 |
\alias{[[,Stream,numeric-method} |
6 | 12 |
\alias{length,Stream-method} |
7 | 13 |
\alias{lapply,Stream-method} |
... | ... |
@@ -21,6 +27,8 @@ |
21 | 27 |
} |
22 | 28 |
|
23 | 29 |
\usage{ |
30 |
+Stream(x, ..., verbose=FALSE) |
|
31 |
+ |
|
24 | 32 |
\S4method{length}{Stream}(x) |
25 | 33 |
|
26 | 34 |
\S4method{[[}{Stream,numeric}(x, i, j, ...) |
... | ... |
@@ -32,15 +40,17 @@ |
32 | 40 |
|
33 | 41 |
\arguments{ |
34 | 42 |
|
35 |
- \item{x, X}{An instance of class \code{Stream}.} |
|
36 |
- |
|
43 |
+ \item{x, X}{For \code{Stream}, \code{x} is a \code{Producer} |
|
44 |
+ instance. For other functions, an instance of class \code{Stream}.} |
|
45 |
+ |
|
37 | 46 |
\item{FUN}{A function to be applied to each successful \code{yield()} |
38 | 47 |
of \code{X}.} |
39 | 48 |
|
40 | 49 |
\item{i, j}{Numeric index of the ith stream element (\code{j} is |
41 | 50 |
ignored by this method).} |
42 | 51 |
|
43 |
- \item{...}{For \code{lapply}, \code{sapply}, additional arguments to |
|
52 |
+ \item{...}{For \code{Stream}, zero or more \code{Consumer} |
|
53 |
+ instances. For \code{lapply}, \code{sapply}, additional arguments to |
|
44 | 54 |
\code{FUN}.} |
45 | 55 |
|
46 | 56 |
\item{simplify}{See \code{?base::sapply}.} |
... | ... |
@@ -48,11 +58,26 @@ |
48 | 58 |
\item{USE.NAMES}{See \code{?base::sapply} but note that names do not |
49 | 59 |
usually make sense for instances of class \code{Producer}.} |
50 | 60 |
|
61 |
+ \item{verbose}{A \code{logical(1)} indicating whether status |
|
62 |
+ information should be reported.} |
|
63 |
+ |
|
51 | 64 |
} |
52 | 65 |
|
53 | 66 |
\section{Constructors}{ |
54 |
- Instances from this class are constructed with calls to \code{Stream}; |
|
55 |
- see \code{?Stream} |
|
67 |
+ |
|
68 |
+ Arguments to \code{Stream} must consist of a single \code{Producer} |
|
69 |
+ and zero or more \code{Consumer} components. |
|
70 |
+ |
|
71 |
+ When invoked with the \code{Producer} as the first argument, |
|
72 |
+ \code{Stream(P, C1, C2)} produces a stream in which the data is read |
|
73 |
+ by \code{P}, then processed by \code{C1}, then processed by \code{C2}. |
|
74 |
+ |
|
75 |
+ When invoked with the \code{Consumer} as the first argument, the |
|
76 |
+ \code{...} must include a \code{Producer} as the \emph{last} |
|
77 |
+ argument. \code{Stream(C1, C2, P)} produces a stream in which the data |
|
78 |
+ is read by \code{P}, then processed by \code{C2}, then processed by |
|
79 |
+ \code{C1}. |
|
80 |
+ |
|
56 | 81 |
} |
57 | 82 |
|
58 | 83 |
\section{Methods}{ |
... | ... |
@@ -101,6 +126,18 @@ |
101 | 126 |
|
102 | 127 |
} |
103 | 128 |
|
104 |
-\examples{showClass("Stream")} |
|
129 |
+\examples{ |
|
130 |
+fl <- system.file("extdata", "s_1_sequence.txt", package="Streamer") |
|
131 |
+b <- RawInput(fl, 100L, reader=rawReaderFactory(1e4)) |
|
132 |
+s <- Stream(b, Rev(), RawToChar()) |
|
133 |
+s |
|
134 |
+yield(s) |
|
135 |
+reset(s) |
|
136 |
+while (length(yield(s))) cat("tick\n") |
|
137 |
+ |
|
138 |
+strm <- Stream(Seq(to=10), FunctionConsumer(function(y) 1/y)) |
|
139 |
+sapply(strm, c) |
|
140 |
+} |
|
141 |
+ |
|
105 | 142 |
|
106 | 143 |
\keyword{classes} |
107 | 144 |
deleted file mode 100644 |
... | ... |
@@ -1,42 +0,0 @@ |
1 |
-\name{Streamer-class} |
|
2 |
-\Rdversion{1.1} |
|
3 |
-\docType{class} |
|
4 |
-\alias{Streamer-class} |
|
5 |
- |
|
6 |
-\title{Class defining methods shared by all classes} |
|
7 |
-\description{ |
|
8 |
- |
|
9 |
- A virtual base class from which all classes in the Streamer package |
|
10 |
- derive. |
|
11 |
- |
|
12 |
-} |
|
13 |
- |
|
14 |
-\section{Methods}{ |
|
15 |
- |
|
16 |
- See \code{Stream}, \code{Producer}, and \code{Consumer} Methods. |
|
17 |
- |
|
18 |
-} |
|
19 |
- |
|
20 |
-\section{Internal Class Fields and Methods}{ |
|
21 |
- |
|
22 |
- Internal fields of this class are are described with, e.g., |
|
23 |
- \code{getRefClass("Streamer")$fields}. |
|
24 |
- |
|
25 |
- Internal methods of this class are described with |
|
26 |
- \code{getRefClass("Streamer")$methods()} and |
|
27 |
- \code{getRefClass("Streamer")$help()}. |
|
28 |
- |
|
29 |
-} |
|
30 |
- |
|
31 |
-\author{Martin Morgan \url{mtmorgan@fhcrc.org}} |
|
32 |
- |
|
33 |
-\seealso{ |
|
34 |
- |
|
35 |
- \code{\link{Streamer-package}}, \code{\linkS4class{Consumer}-class}, |
|
36 |
- \code{\linkS4class{Producer}-class}, \code{\linkS4class{Stream}-class}. |
|
37 |
- |
|
38 |
-} |
|
39 |
- |
|
40 |
-\examples{showClass("Streamer")} |
|
41 |
- |
|
42 |
-\keyword{classes} |
7 | 8 |
deleted file mode 100644 |
... | ... |
@@ -1,61 +0,0 @@ |
1 |
-\name{Stream} |
|
2 |
- |
|
3 |
-\alias{Stream} |
|
4 |
-\alias{Stream-methods} |
|
5 |
-\alias{Stream,Consumer-method} |
|
6 |
-\alias{Stream,Producer-method} |
|
7 |
- |
|
8 |
-\title{Function to create a Stream from a Producer and zero or more Consumers} |
|
9 |
- |
|
10 |
-\description{ |
|
11 |
- |
|
12 |
- \code{Stream} is used to create a stream from a single \code{Producer} |
|
13 |
- and zero or more \code{Consumer} instances. |
|
14 |
- |
|
15 |
-} |
|
16 |
- |
|
17 |
-\usage{ |
|
18 |
-Stream(x, ..., verbose=FALSE) |
|
19 |
-} |
|
20 |
- |
|
21 |
-\arguments{ |
|
22 |
- \item{x}{An instance of a \code{Consumer} or \code{Producer}} |
|
23 |
- \item{\dots}{Additional \code{Consumer} or \code{Producer} instances.} |
|
24 |
- \item{verbose}{A \code{logical(1)} indicating whether status |
|
25 |
- information should be reported.} |
|
26 |
-} |
|
27 |
- |
|
28 |
-\details{ |
|
29 |
- |
|
30 |
- Arguments to \code{Stream} must consist of a single \code{Producer} |
|
31 |
- and zero or more \code{Consumer} components. |
|
32 |
- |
|
33 |
- When invoked with the \code{Producer} as the first argument, |
|
34 |
- \code{Stream(P, C1, C2)} produces a stream in which the data is read |
|
35 |
- by \code{P}, then processed by \code{C1}, then processed by \code{C2}. |
|
36 |
- |
|
37 |
- When invoked with the \code{Consumer} as the first argument, the |
|
38 |
- \code{...} must include a \code{Producer} as the \emph{last} |
|
39 |
- argument. \code{Stream(C1, C2, P)} produces a stream in which the data |
|
40 |
- is read by \code{P}, then processed by \code{C2}, then processed by |
|
41 |
- \code{C1}. |
|
42 |
- |
|
43 |
-} |
|
44 |
- |
|
45 |
-\value{An instance of class \code{\linkS4class{Stream}}.} |
|
46 |
- |
|
47 |
-\author{Martin Morgan \url{mtmorgan@fhcrc.org}} |
|
48 |
- |
|
49 |
-\seealso{\code{\link{yield}}, \code{\linkS4class{Stream}-class}.} |
|
50 |
- |
|
51 |
-\examples{ |
|
52 |
-fl <- system.file("extdata", "s_1_sequence.txt", package="Streamer") |
|
53 |
-b <- RawInput(fl, 100L, reader=rawReaderFactory(1e4)) |
|
54 |
-s <- Stream(b, Rev(), RawToChar()) |
|
55 |
-s |
|
56 |
-yield(s) |
|
57 |
-reset(s) |
|
58 |
-while (length(yield(s))) cat("tick\n") |
|
59 |
-} |
|
60 |
- |
|
61 |
-\keyword{manip} |