\section{KLock\-File Class Reference}
\label{classKLockFile}\index{KLockFile@{KLockFile}}
The KLock\-File class provides NFS safe lockfiles.  


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

Inheritance diagram for KLock\-File:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=48pt]{classKLockFile__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for KLock\-File:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=48pt]{classKLockFile__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Types}
\begin{CompactItemize}
\item 
typedef {\bf KShared\-Ptr}$<$ {\bf KLock\-File} $>$ {\bf Ptr}\label{classKLockFile_w0}

\item 
enum {\bf Lock\-Result} \{ {\bf Lock\-OK} =  0, 
{\bf Lock\-Fail}, 
{\bf Lock\-Error}, 
{\bf Lock\-Stale}
 \}
\item 
enum {\bf Lock\-Options} \{ {\bf Lock\-No\-Block} =  1, 
{\bf Lock\-Force} =  2
 \}
\end{CompactItemize}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf KLock\-File} (const {\bf QString} \&file)\label{classKLockFile_a0}

\item 
{\bf $\sim$KLock\-File} ()
\item 
{\bf Lock\-Result} {\bf lock} (int options=0)
\item 
bool {\bf is\-Locked} () const 
\item 
void {\bf unlock} ()
\item 
int {\bf stale\-Time} () const 
\item 
void {\bf set\-Stale\-Time} (int \_\-stale\-Time)
\item 
bool {\bf get\-Lock\-Info} (int \&pid, {\bf QString} \&hostname, {\bf QString} \&appname)
\end{CompactItemize}


\subsection{Detailed Description}
The KLock\-File class provides NFS safe lockfiles. 

\begin{Desc}
\item[Author:]Waldo Bastian $<${\tt bastian@kde.org}$>$ \end{Desc}
\begin{Desc}
\item[Since:]3.3 \end{Desc}




Definition at line 33 of file klockfile.h.

\subsection{Member Enumeration Documentation}
\index{KLockFile@{KLock\-File}!LockResult@{LockResult}}
\index{LockResult@{LockResult}!KLockFile@{KLock\-File}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}enum {\bf KLock\-File::Lock\-Result}}\label{classKLockFile_w7}


Possible return values of the lock function. 

\begin{Desc}
\item[Enumeration values: ]\par
\begin{description}
\index{LockOK@{LockOK}!KLockFile@{KLockFile}}\index{KLockFile@{KLockFile}!LockOK@{LockOK}}\item[{\em 
Lock\-OK\label{classKLockFile_w7w1}
}]Lock was acquired successfully. \index{LockFail@{LockFail}!KLockFile@{KLockFile}}\index{KLockFile@{KLockFile}!LockFail@{LockFail}}\item[{\em 
Lock\-Fail\label{classKLockFile_w7w2}
}]The lock could not be acquired because it is held by another process. \index{LockError@{LockError}!KLockFile@{KLockFile}}\index{KLockFile@{KLockFile}!LockError@{LockError}}\item[{\em 
Lock\-Error\label{classKLockFile_w7w3}
}]The lock could not be acquired due to an error. \index{LockStale@{LockStale}!KLockFile@{KLockFile}}\index{KLockFile@{KLockFile}!LockStale@{LockStale}}\item[{\em 
Lock\-Stale\label{classKLockFile_w7w4}
}]A stale lock has been detected. \end{description}
\end{Desc}



Definition at line 48 of file klockfile.h.\index{KLockFile@{KLock\-File}!LockOptions@{LockOptions}}
\index{LockOptions@{LockOptions}!KLockFile@{KLock\-File}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}enum {\bf KLock\-File::Lock\-Options}}\label{classKLockFile_w8}


\begin{Desc}
\item[Enumeration values: ]\par
\begin{description}
\index{LockNoBlock@{LockNoBlock}!KLockFile@{KLockFile}}\index{KLockFile@{KLockFile}!LockNoBlock@{LockNoBlock}}\item[{\em 
Lock\-No\-Block\label{classKLockFile_w8w5}
}]Return immediately, do not wait for the lock to become available. \index{LockForce@{LockForce}!KLockFile@{KLockFile}}\index{KLockFile@{KLockFile}!LockForce@{LockForce}}\item[{\em 
Lock\-Force\label{classKLockFile_w8w6}
}]Automatically remove a lock when a lock is detected that is stale for more than {\bf stale\-Time()}{\rm (p.\,\pageref{classKLockFile_a5})} seconds. \end{description}
\end{Desc}



Definition at line 70 of file klockfile.h.

\subsection{Constructor \& Destructor Documentation}
\index{KLockFile@{KLock\-File}!~KLockFile@{$\sim$KLockFile}}
\index{~KLockFile@{$\sim$KLockFile}!KLockFile@{KLock\-File}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KLock\-File::$\sim${\bf KLock\-File} ()}\label{classKLockFile_a1}


Destroys the object, releasing the lock if held. 



Definition at line 73 of file klockfile.cpp.

References unlock().

\subsection{Member Function Documentation}
\index{KLockFile@{KLock\-File}!lock@{lock}}
\index{lock@{lock}!KLockFile@{KLock\-File}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KLock\-File::Lock\-Result} KLock\-File::lock (int {\em options} = {\tt 0})}\label{classKLockFile_a2}


Attempt to acquire the lock. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em options}]A set of {\bf Lock\-Options}{\rm (p.\,\pageref{classKLockFile_w8})} OR'ed together. \end{description}
\end{Desc}


Definition at line 199 of file klockfile.cpp.

References QText\-Stream::at\-End(), Lock\-Error, Lock\-Fail, Lock\-Force, Lock\-No\-Block, Lock\-OK, Lock\-Stale, KApplication::random(), and QText\-Stream::read\-Line().\index{KLockFile@{KLock\-File}!isLocked@{isLocked}}
\index{isLocked@{isLocked}!KLockFile@{KLock\-File}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KLock\-File::is\-Locked () const}\label{classKLockFile_a3}


Returns whether the lock is held or not. 



Definition at line 313 of file klockfile.cpp.\index{KLockFile@{KLock\-File}!unlock@{unlock}}
\index{unlock@{unlock}!KLockFile@{KLock\-File}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KLock\-File::unlock ()}\label{classKLockFile_a4}


Release the lock. 



Definition at line 318 of file klockfile.cpp.

References QFile::encode\-Name().

Referenced by $\sim$KLock\-File().\index{KLockFile@{KLock\-File}!staleTime@{staleTime}}
\index{staleTime@{staleTime}!KLockFile@{KLock\-File}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int KLock\-File::stale\-Time () const}\label{classKLockFile_a5}


Return the time in seconds after which a lock is considered stale The default is 30. 



Definition at line 80 of file klockfile.cpp.\index{KLockFile@{KLock\-File}!setStaleTime@{setStaleTime}}
\index{setStaleTime@{setStaleTime}!KLockFile@{KLock\-File}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KLock\-File::set\-Stale\-Time (int {\em \_\-stale\-Time})}\label{classKLockFile_a6}


Set the time in seconds after which a lock is considered stale. 



Definition at line 87 of file klockfile.cpp.\index{KLockFile@{KLock\-File}!getLockInfo@{getLockInfo}}
\index{getLockInfo@{getLockInfo}!KLockFile@{KLock\-File}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KLock\-File::get\-Lock\-Info (int \& {\em pid}, {\bf QString} \& {\em hostname}, {\bf QString} \& {\em appname})}\label{classKLockFile_a7}


Returns the pid, hostname and appname of the process holding the lock after the lock functon has returned with Lock\-Stale. 

\begin{Desc}
\item[Returns:]false if the pid and hostname could not be determined \end{Desc}


Definition at line 327 of file klockfile.cpp.

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