

% add the PATH to retrieve cls and sty beamer styles files
\makeatletter
\providecommand*{\input@path}{}
\edef\input@path{{../../support/beamer/}\input@path}% prepend
\makeatother

% \documentclass{pharoslides}
% \documentclass[aspectratio=169]{pharoslides} % format 16/9
\documentclass[withvideo]{pharoslides} % format 16/9 + incrustation video

\graphicspath{{./figures/}{../}{../../support/beamer/imgs/}}

%Information to be included in the title page:
\title{Stream Overview}
\subtitle{}
\author{Damien Cassou, Stéphane Ducasse and Luc Fabresse}
\institute{http://stephane.ducasse.free.fr}
\date{}
\slidesid{W3S10}

\begin{document}

\frame[plain]{\titlepage}



\begin{frame}[fragile]

\frametitle{What You Will Learn}

\begin{itemize}
\item What streams are?
\item How to use them
\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{Streams}

\begin{itemize}
\item Iterate over a sequence of elements
\begin{itemize}
\item e.g., collection, file, network
\end{itemize}

\item Current position separates past from future
\end{itemize}


\begin{center}
\includegraphics[width=1.0\textwidth]{figures/a_bcdeStef.png}\end{center}

\end{frame}



\begin{frame}[fragile]

\frametitle{API Overview}

\begin{itemize}
\item Creating
\begin{itemize}
\item \code{anObject readStream}
\item \code{anObject writeStream}
\item \code{Collection streamContents: {[}:stream \textbar{} ... {]}}
\item \code{(Read/Write)Stream on: aCollection}
\end{itemize}

\item Reading elements
\begin{itemize}
\item \code{next}
\item \code{upTo: anObject}
\item \code{upToEnd}
\end{itemize}

\item Writing elements
\begin{itemize}
\item \code{nextPut: anElement}
\item \code{nextPutAll: aCollection}
\end{itemize}

\end{itemize}
\end{frame}



\begin{frame}[fragile]

\frametitle{Reading Elements}

\begin{itemize}
\item \code{next}, \code{upTo: anObject}, \code{upToEnd}
\end{itemize}

\begin{listing}{}
| strean |
stream := #($a $b $c $d $e $f) readStream.

stream next.
> $a

stream upTo: $d.
>  #($b $c)

stream position.
> 4

stream upToEnd
> #($e $f)
\end{listing}
\end{frame}



\begin{frame}[fragile]

\frametitle{Writing Elements}

\begin{itemize}
\item \code{nexPut:}, \code{nextPutAll:}
\end{itemize}

\begin{listing}{}
stream := (Array new: 6) writeStream.

stream nextPut: 1.
stream contents.
> #(1)

stream nextPutAll: #(4 8 2 6 7).
stream contents.
> #(1 4 8 2 6 7)
\end{listing}
\end{frame}



\begin{frame}[fragile]

\frametitle{Writing to a File}

\begin{listing}{}
stream := 'hello.txt' asFileReference writeStream.
stream nextPutAll: 'Hello Pharo!'.
stream close.
\end{listing}
\end{frame}



\begin{frame}[fragile]

\frametitle{Reading from a File}

\begin{listing}{}
stream := 'hello.txt' asFileReference readStream.

stream next.
> $H

stream upToEnd.
> 'ello Pharo!'

stream close
\end{listing}
\end{frame}



\begin{frame}[fragile]

\frametitle{Creating Collections from a Stream}

When you want to create a collection by writing to a stream:

\begin{listing}{}
stream := OrderedCollection new writeStream.
stream nextPut: 1.
stream contents
\end{listing}

is equivalent to

\begin{listing}{}
OrderedCollection
   streamContents: [:stream | stream nextPut: 1]
\end{listing}

Both scripts return a collection with number 1 inside.
\end{frame}



\begin{frame}[fragile]

\frametitle{What You Should Know}

\begin{itemize}
\item A stream can read from and write to
\begin{itemize}
\item collections, files and network
\end{itemize}

\item A stream maintains a current position
\item A stream can help create collections
\end{itemize}
\end{frame}




% \setlength{\textwidth}{\originaltextwidth}
\setbeamertemplate{background canvas}{\insertBorderForHandout}

\begin{frame}[plain]

\begin{minipage}{\originaltextwidth}
\centering
\large


\vspace{2em}

A course by

\vspace{1em}

\hspace{-20px}\includegraphics[height=32px]{inriaLogo}\hspace{3em}\raisebox{7px}{and}\hspace{3em}\raisebox{-6px}{\includegraphics[height=30px]{logoutop}}

\vspace{2em}

in collaboration with

\vspace{1em}

\includegraphics[height=40px]{unisciellogo}\hskip 1.5em%
\raisebox{5px}{\includegraphics[height=30px]{unitlogo}}\hskip 2em%
\raisebox{8px}{\includegraphics[height=24px]{univLilleLogo}}\hskip 2em%
\raisebox{3px}{\includegraphics[height=29px]{logo-IMT}}\hskip 2em%
\raisebox{1px}{\includegraphics[height=32px]{minesDouaiLogo}}

\vspace{2.5em}

\includegraphics[width=50px]{by-nc-nd} \tiny \hskip 0.5em \raisebox{5px}{Inria 2016}

\medskip

\tiny
Except where otherwise noted, this work is licensed under CC BY-NC-ND 3.0 France

\url{https://creativecommons.org/licenses/by-nc-nd/3.0/fr/} 

\end{minipage}
\end{frame}

\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
