git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@129 270642c3-0616-0410...
[senf.git] / Socket / FileHandle.hh
1 // $Id$
2 //
3 // Copyright (C) 2006 
4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 //     Stefan Bund <stefan.bund@fokus.fraunhofer.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 #ifndef HH_FileHandle_
24 #define HH_FileHandle_ 1
25
26 // Custom includes
27 #include <memory> // std::auto_ptr
28
29 //#include "FileHandle.mpp"
30 ///////////////////////////////hh.p////////////////////////////////////////
31 #include "FileHandle.ih"
32
33 namespace satcom {
34 namespace lib {
35     
36     /** \brief
37      */
38     class FileHandle
39     {
40     public:
41         ///////////////////////////////////////////////////////////////////////////
42         // Types
43
44         ///////////////////////////////////////////////////////////////////////////
45         ///\name Structors and default members
46         ///@{
47
48         // protected default constructor
49         // default copy constructor
50         // default copy assignment
51         // default destructor
52
53         // no conversion constructors
54
55         ///@}
56         ///////////////////////////////////////////////////////////////////////////
57         
58         void close();
59         void terminate();
60
61         bool readable() const;
62         void waitReadable() const;
63         bool writeable() const;
64         void waitWriteable() const;
65
66         bool blocking() const;
67         void blocking(bool status);
68
69         bool eof() const;
70         bool valid() const;
71
72         operator bool () const;
73         bool operator!() const;
74
75         int fd() const;
76
77         static FileHandle cast_static(FileHandle handle);
78         static FileHandle cast_dynamic(FileHandle handle);
79
80     protected:
81         explicit FileHandle(std::auto_ptr<FileBody> body);
82
83         FileBody & body();
84         FileBody const & body() const;
85         static FileBody & body(FileHandle & handle);
86         static FileBody const & body(FileHandle const & handle);
87
88         void fd(int fd);
89
90     private:
91         FileBody::ptr body_;
92     };
93
94 }}
95
96 ///////////////////////////////hh.e////////////////////////////////////////
97 #include "FileHandle.cci"
98 //#include "FileHandle.ct"
99 //#include "FileHandle.cti"
100 #endif
101
102 \f
103 // Local Variables:
104 // mode: c++
105 // c-file-style: "satcom"
106 // End: