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