Sophie

Sophie

distrib > Mandriva > 2007.0 > i586 > by-pkgid > ad1ba1135a9c9eeffc2e538163e00373 > files > 711

libCommonC++2_1.4-devel-1.4.1-1mdv2007.0.i586.rpm

\section{ost::Mapped\-File Class Reference}
\label{classost_1_1_mapped_file}\index{ost::MappedFile@{ost::MappedFile}}
Create and map a disk file into memory.Map a named disk file into memory.  


{\tt \#include $<$file.h$>$}

Inheritance diagram for ost::Mapped\-File::\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=3cm]{classost_1_1_mapped_file}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf Mapped\-File} (const char $\ast$fname, {\bf Access} mode)
\begin{CompactList}\small\item\em Open a file for mapping. \item\end{CompactList}\item 
{\bf Mapped\-File} (const char $\ast$fname, {\bf Access} mode, size\_\-t size)
\begin{CompactList}\small\item\em Create if not exists, and map a file of specified size into memory. \item\end{CompactList}\item 
{\bf Mapped\-File} (const char $\ast$fname, {\bf pos\_\-t} offset, size\_\-t size, {\bf Access} mode)
\begin{CompactList}\small\item\em Map a portion or all of a specified file in the specified shared memory access mode. \item\end{CompactList}\item 
virtual {\bf $\sim$Mapped\-File} ()
\begin{CompactList}\small\item\em Release a mapped section of memory associated with a file. \item\end{CompactList}\item 
void {\bf sync} (void)
\begin{CompactList}\small\item\em Synchronize the contents of the mapped portion of memory with the disk file and wait for completion. \item\end{CompactList}\item 
void {\bf sync} (char $\ast$address, size\_\-t len)
\begin{CompactList}\small\item\em Synchronize a segment of memory mapped from a segment fetch. \item\end{CompactList}\item 
void {\bf update} (size\_\-t offset=0, size\_\-t len=0)
\begin{CompactList}\small\item\em Map a portion of the memory mapped from the file back to the file and do not wait for completion. \item\end{CompactList}\item 
void {\bf update} (char $\ast$address, size\_\-t len)
\begin{CompactList}\small\item\em Update a mapped region back to disk as specified by address and length. \item\end{CompactList}\item 
void {\bf release} (char $\ast$address, size\_\-t len)
\begin{CompactList}\small\item\em Release (unmap) a memory segment. \item\end{CompactList}\item 
char $\ast$ {\bf fetch} (size\_\-t offset=0)
\begin{CompactList}\small\item\em Fetch a pointer to an offset within the memory mapped portion of the disk file. \item\end{CompactList}\item 
char $\ast$ {\bf fetch} (off\_\-t pos, size\_\-t len)
\begin{CompactList}\small\item\em Fetch and map a portion of a disk file to a logical memory block. \item\end{CompactList}\item 
bool {\bf lock} (void)
\begin{CompactList}\small\item\em Lock the currently mapped portion of a file. \item\end{CompactList}\item 
void {\bf unlock} (void)
\begin{CompactList}\small\item\em Unlock a locked mapped portion of a file. \item\end{CompactList}\item 
size\_\-t {\bf page\-Aligned} (size\_\-t size)
\begin{CompactList}\small\item\em Compute map size to aligned page boundry. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Create and map a disk file into memory.Map a named disk file into memory. 

This portable class works under both Posix via mmap and under the win32 API. A mapped file can be referenced directly by it's memory segment. One can map and unmap portions of a file on demand, and update changed memory pages mapped from files immediately through {\bf sync()}{\rm (p.\,\pageref{classost_1_1_mapped_file_f5fe36ccac8879fd2ca8b63574686cac})}.

\begin{Desc}
\item[Author:]David Sugar $<${\tt dyfet@ostel.com}$>$ \end{Desc}




\subsection{Constructor \& Destructor Documentation}
\index{ost::MappedFile@{ost::Mapped\-File}!MappedFile@{MappedFile}}
\index{MappedFile@{MappedFile}!ost::MappedFile@{ost::Mapped\-File}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}ost::Mapped\-File::Mapped\-File (const char $\ast$ {\em fname}, {\bf Access} {\em mode})}\label{classost_1_1_mapped_file_1d8d79711c6d0874ef50f0fee1d768ee}


Open a file for mapping. 

More than one segment of a file may be mapped into seperate regions of memory.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em fname}]file name to access for mapping. \item[{\em mode}]access mode to map file. \end{description}
\end{Desc}
\index{ost::MappedFile@{ost::Mapped\-File}!MappedFile@{MappedFile}}
\index{MappedFile@{MappedFile}!ost::MappedFile@{ost::Mapped\-File}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}ost::Mapped\-File::Mapped\-File (const char $\ast$ {\em fname}, {\bf Access} {\em mode}, size\_\-t {\em size})}\label{classost_1_1_mapped_file_65b2b05ede145124ba7d903f2c118b28}


Create if not exists, and map a file of specified size into memory. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em fname}]file name to access for mapping. \item[{\em mode}]access mode to map file. \item[{\em size}]of file to map. \end{description}
\end{Desc}
\index{ost::MappedFile@{ost::Mapped\-File}!MappedFile@{MappedFile}}
\index{MappedFile@{MappedFile}!ost::MappedFile@{ost::Mapped\-File}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}ost::Mapped\-File::Mapped\-File (const char $\ast$ {\em fname}, {\bf pos\_\-t} {\em offset}, size\_\-t {\em size}, {\bf Access} {\em mode})}\label{classost_1_1_mapped_file_dbf54b1e56999a84f4a017d0c9b82405}


Map a portion or all of a specified file in the specified shared memory access mode. 

Valid mapping modes include mapped\-Read, mapped\-Write, and mapped\-Read\-Write.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em fname}]pathname of file to map into memory. \item[{\em offset}]from start of file to begin mapping in bytes. \item[{\em size}]of mapped area in bytes. \item[{\em mode}]to map file. \end{description}
\end{Desc}
\index{ost::MappedFile@{ost::Mapped\-File}!~MappedFile@{$\sim$MappedFile}}
\index{~MappedFile@{$\sim$MappedFile}!ost::MappedFile@{ost::Mapped\-File}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual ost::Mapped\-File::$\sim$Mapped\-File ()\hspace{0.3cm}{\tt  [virtual]}}\label{classost_1_1_mapped_file_349f9927a4bfe1106955f1d44959ab2b}


Release a mapped section of memory associated with a file. 

The mapped area is updated back to disk. 

\subsection{Member Function Documentation}
\index{ost::MappedFile@{ost::Mapped\-File}!fetch@{fetch}}
\index{fetch@{fetch}!ost::MappedFile@{ost::Mapped\-File}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}char$\ast$ ost::Mapped\-File::fetch (off\_\-t {\em pos}, size\_\-t {\em len})}\label{classost_1_1_mapped_file_7c8db51c98075be049e6ae2efc7966c2}


Fetch and map a portion of a disk file to a logical memory block. 

\begin{Desc}
\item[Returns:]pointer to memory segment. \end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em pos}]offset of file segment to map. \item[{\em len}]size of memory segment to map. \end{description}
\end{Desc}
\index{ost::MappedFile@{ost::Mapped\-File}!fetch@{fetch}}
\index{fetch@{fetch}!ost::MappedFile@{ost::Mapped\-File}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}char$\ast$ ost::Mapped\-File::fetch (size\_\-t {\em offset} = {\tt 0})\hspace{0.3cm}{\tt  [inline]}}\label{classost_1_1_mapped_file_0d8be211f29d23d39051a86512dee853}


Fetch a pointer to an offset within the memory mapped portion of the disk file. 

This really is used for convience of matching operations between Update and Fetch, as one could simply have accessed the base pointer where the file was mapped directly.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em offset}]from start of mapped memory. \end{description}
\end{Desc}
\index{ost::MappedFile@{ost::Mapped\-File}!lock@{lock}}
\index{lock@{lock}!ost::MappedFile@{ost::Mapped\-File}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool ost::Mapped\-File::lock (void)}\label{classost_1_1_mapped_file_b94baac40118fa5c6903ce42109c7903}


Lock the currently mapped portion of a file. 

\begin{Desc}
\item[Returns:]true if pages are locked. \end{Desc}
\index{ost::MappedFile@{ost::Mapped\-File}!pageAligned@{pageAligned}}
\index{pageAligned@{pageAligned}!ost::MappedFile@{ost::Mapped\-File}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}size\_\-t ost::Mapped\-File::page\-Aligned (size\_\-t {\em size})}\label{classost_1_1_mapped_file_f6498463d62c3e69d10919f8687b95ea}


Compute map size to aligned page boundry. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em size}]request. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]page aligned size. \end{Desc}
\index{ost::MappedFile@{ost::Mapped\-File}!release@{release}}
\index{release@{release}!ost::MappedFile@{ost::Mapped\-File}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void ost::Mapped\-File::release (char $\ast$ {\em address}, size\_\-t {\em len})}\label{classost_1_1_mapped_file_58b384efa39d1fc1d8833974209de206}


Release (unmap) a memory segment. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em address}]address of memory segment to release. \item[{\em len}]length of memory segment to release. \end{description}
\end{Desc}
\index{ost::MappedFile@{ost::Mapped\-File}!sync@{sync}}
\index{sync@{sync}!ost::MappedFile@{ost::Mapped\-File}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void ost::Mapped\-File::sync (char $\ast$ {\em address}, size\_\-t {\em len})}\label{classost_1_1_mapped_file_057579ccc63c7e06190abea4bba9a43e}


Synchronize a segment of memory mapped from a segment fetch. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em address}]memory address to update. \item[{\em len}]size of segment. \end{description}
\end{Desc}
\index{ost::MappedFile@{ost::Mapped\-File}!sync@{sync}}
\index{sync@{sync}!ost::MappedFile@{ost::Mapped\-File}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void ost::Mapped\-File::sync (void)}\label{classost_1_1_mapped_file_f5fe36ccac8879fd2ca8b63574686cac}


Synchronize the contents of the mapped portion of memory with the disk file and wait for completion. 

This assures the memory mapped from the file is written back. \index{ost::MappedFile@{ost::Mapped\-File}!unlock@{unlock}}
\index{unlock@{unlock}!ost::MappedFile@{ost::Mapped\-File}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void ost::Mapped\-File::unlock (void)}\label{classost_1_1_mapped_file_47776d201f8d2f8f9f0288f797e3da4c}


Unlock a locked mapped portion of a file. 

\index{ost::MappedFile@{ost::Mapped\-File}!update@{update}}
\index{update@{update}!ost::MappedFile@{ost::Mapped\-File}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void ost::Mapped\-File::update (char $\ast$ {\em address}, size\_\-t {\em len})}\label{classost_1_1_mapped_file_6fd5874fd9ffe5f058775b3d34a95064}


Update a mapped region back to disk as specified by address and length. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em address}]address of segment. \item[{\em len}]length of segment. \end{description}
\end{Desc}
\index{ost::MappedFile@{ost::Mapped\-File}!update@{update}}
\index{update@{update}!ost::MappedFile@{ost::Mapped\-File}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void ost::Mapped\-File::update (size\_\-t {\em offset} = {\tt 0}, size\_\-t {\em len} = {\tt 0})}\label{classost_1_1_mapped_file_99b20ddc2524e8ec1ce544d362e786b3}


Map a portion of the memory mapped from the file back to the file and do not wait for completion. 

This is useful when mapping a database file and updating a single record.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em offset}]offset into the mapped region of memory. \item[{\em len}]length of partial region (example, record length). \end{description}
\end{Desc}


The documentation for this class was generated from the following file:\begin{CompactItemize}
\item 
{\bf file.h}\end{CompactItemize}