Continued with renaming-season:
[core.git] / framework / main / interfaces / block / class_Block.php
1 <?php
2 // Own namespace
3 namespace CoreFramework\Filesystem;
4
5 // Import framework stuff
6 use CoreFramework\Generic\FrameworkInterface;
7
8 /**
9  * A block interface
10  *
11  * @author              Roland Haeder <webmaster@ship-simu.org>
12  * @version             0.0.0
13  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
14  * @license             GNU GPL 3.0 or any newer version
15  * @link                http://www.ship-simu.org
16  *
17  * This program is free software: you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation, either version 3 of the License, or
20  * (at your option) any later version.
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program. If not, see <http://www.gnu.org/licenses/>.
29  */
30 interface Block extends FrameworkInterface {
31         /**
32          * Reads the file header
33          *
34          * @return      void
35          */
36         function readFileHeader ();
37
38         /**
39          * Flushes the file header
40          *
41          * @return      void
42          */
43         function flushFileHeader ();
44
45         /**
46          * Determines whether the EOF has been reached
47          *
48          * @return      $isEndOfFileReached             Whether the EOF has been reached
49          */
50         function isEndOfFileReached ();
51
52         /**
53          * Getter for file name
54          *
55          * @return      $fileName       The current file name
56          */
57         function getFileName ();
58
59         /**
60          * Initializes counter for valid entries, arrays for damaged entries and
61          * an array for gap seek positions. If you call this method on your own,
62          * please re-analyze the file structure. So you are better to call
63          * analyzeFile() instead of this method.
64          *
65          * @return      void
66          */
67         function initCountersGapsArray ();
68
69         /**
70          * Getter for header size
71          *
72          * @return      $totalEntries   Size of file header
73          */
74         function getHeaderSize ();
75
76         /**
77          * Setter for header size
78          *
79          * @param       $headerSize             Size of file header
80          * @return      void
81          */
82         function setHeaderSize ($headerSize);
83
84         /**
85          * Getter for header array
86          *
87          * @return      $totalEntries   Size of file header
88          */
89         function getHeader ();
90
91         /**
92          * Setter for header
93          *
94          * @param       $header         Array for a file header
95          * @return      void
96          */
97         function setHeader (array $header);
98
99         /**
100          * Updates seekPosition attribute from file to avoid to much access on file.
101          *
102          * @return      void
103          */
104         function updateSeekPosition ();
105
106         /**
107          * Getter for total entries
108          *
109          * @return      $totalEntries   Total entries in this file
110          */
111         function getCounter ();
112
113         /**
114          * "Getter" for file size
115          *
116          * @return      $fileSize       Size of currently loaded file
117          */
118         function getFileSize ();
119
120         /**
121          * Writes given value to the file and returns a hash and gap position for it
122          *
123          * @param       $groupId        Group identifier
124          * @param       $value          Value to be added to the stack
125          * @return      $data           Hash and gap position
126          */
127         function writeValueToFile ($groupId, $rawData);
128
129         /**
130          * Writes given raw data to the file and returns a gap position and length
131          *
132          * @param       $groupId        Group identifier
133          * @param       $hash           Hash from encoded value
134          * @param       $encoded        Encoded value to be written to the file
135          * @return      $data           Gap position and length of the raw data
136          */
137         function writeDataToFreeGap ($groupId, $hash, $encoded);
138
139         /**
140          * Writes data at given position
141          *
142          * @param       $seekPosition   Seek position
143          * @param       $data                   Data to be written
144          * @param       $flushHeader    Whether to flush the header (default: flush)
145          * @return      void
146          */
147         function writeData ($seekPosition, $data, $flushHeader = TRUE);
148
149         /**
150          * Searches for next suitable gap the given length of data can fit in
151          * including padding bytes.
152          *
153          * @param       $length                 Length of raw data
154          * @return      $seekPosition   Found next gap's seek position
155          */
156         function searchNextGap ($length);
157
158 }