         return nil;
     }
     
-    /**
-    func writeHeader(header: CMutablePointer<H>) {
-        
-        let headerData = header.withUnsafePointer {
-            NSData(bytes:$0, length:sizeof(H))
-        }
-        
-        self.fileHandle.writeData(headerData)
-    }
-*/
-    
-    func writeHeader(inout header: H) {
-        
-        let headerData = NSData(bytesNoCopy:&header, length:sizeof(H), freeWhenDone:false)
-    
-        self.fileHandle.writeData(headerData)
-    }
-    
-    // Default code
-    // subclass should override this methode
-    func writeHeader(inout forData data:D, atPos pos:CUnsignedLongLong) {
- 
-        var header = H()
-        header.used = true
-        
-        writeHeader(&header)
-    }
-    
-    //#pragma mark - CRUD DATA
-    
-    // todo move to ObjectStore
-    subscript(index: UID) -> D! {
-        get {
-            self.seekToFileID(index)
-            return self.readData()
-        }
-        
-        set(newValue) {
-            var pos = self.calculatePos(index)
-            self.writeData(newValue, atPos: pos)
-        }
-    }
-    
-    // CREATE Use Case is a 2-step action
-    // - register -> pos
-    // - writeData:AtPos: (UPDATE)
-    
-    func createData(inout data: D) -> UID {
-        
-        var pos = register()
-        
-        writeData(data, atPos: pos)
+    func readData() -> D! {
+        
+        var data = self.fileHandle.readDataOfLength(sizeof(D)); //return NSData
+        
+        // works only by value?
+        if data {
+            var result = D()
+            
+            data.getBytes(&result)
+            
+            return result
+        }
+        
+        return nil;
+    }
+    
+    
+    // #pragma mark WRITE -------------------------------------------------------
+    
+    func createBlock(data: D) -> UID {
+        
+        var pos = registerBlock()
+        
+        writeBlock(data, atPos: pos)
         
         return calculateID(pos)
     }
     
-    func register() -> CUnsignedLongLong {
+    func registerBlock() -> CUnsignedLongLong {
         
         var pos: CUnsignedLongLong? = Array(unusedDataSegments.keys)[0]
         

        return pos!;
    }
    
    // READ
        
    func readData() -> D! {
        
        var data = self.fileHandle.readDataOfLength(sizeof(D)); //return NSData
        
        // works only by value?
        if data {
            var buffer : CMutablePointer<D> = nil
            data.getBytes(&buffer)
            
            let result = buffer.withUnsafePointer {p in
                p.memory
            }
            
            return result;
        }
        
        return nil;
    }
    
    // UPDATE
    
    func writeData(data: D, atPos pos: CUnsignedLongLong) {
        
        // TODO: FIX
        var a = data
        let buffer = NSData(bytesNoCopy:&a, length:sizeof(D), freeWhenDone:false)
        
        self.fileHandle.seekToFileOffset(pos)
        self.writeHeader(forData: &a, atPos: pos)
        
        writeData(buffer)
    }
    
    func writeData(data: NSData) {
        self.fileHandle.writeData(data);
    }
    
    // subclases have to override
    func deleteData(aID: UID) -> CUnsignedLongLong {
        
        var pos = self.seekToFileID(aID)
        
        var header = H()
        header.used = false
        
        self.writeHeader(&header)
        
        self.unusedDataSegments[pos] = true
        
        return pos
    }
        
}

// Concept requirements & implementation

// A block contains a header and data

// CRUD D
// - generic data
// - generic header
