 
 import Foundation
 
-
-// TODO add support core conding / encoding to header
-struct HEADER {
+struct ObjectStoreHeader : DataStoreHeader  {
     var used: Bool = true;
+    
 }
 
-class ManagedObjectStore<O: ObjectCoding ,H: Coding> : ObjectStore<O,H> {
+class ManagedObjectStore<O: PersistentObject> : ObjectStore<O,ObjectStoreHeader> {
     
-    var header: NSData
-    var deleteHeader: NSData
-
-    var  endOfFile: CUnsignedLongLong = 0;
-    
-    var unusedDataSegments =  Dictionary<CUnsignedLongLong,Bool>()
+    //var header: NSData
+    //var deleteHeader: NSData
 
     init(url: NSURL) {
     
-        var header = HEADER()
+        //var header: ObjectStoreHeader  = ObjectStoreHeader(used:true)
         
-        self.header = NSData(bytes:&header, length:sizeof(HEADER));
-        header.used = false;
-        self.deleteHeader = NSData(bytes:&header, length:sizeof(HEADER));
+        //self.header = NSData(bytes:&header, length:sizeof(ObjectStoreHeader));
+        //header.used = false;
+        //self.deleteHeader = NSData(bytes:&header, length:sizeof(ObjectStoreHeader));
         
         super.init(url: url)
         
         // set virtual file end to offSet because initStore use the register methode
         //self.endOfFile = CUnsignedLongLong(self.fileOffset)
         
-        self.dataSize = sizeof(HEADER) + sizeof(O)
+        //self.dataSize = sizeof(HEADER) + sizeof(O)
         
-        self.endOfFile = self.fileHandle.seekToEndOfFile()
+        //self.endOfFile = self.fileHandle.seekToEndOfFile()
         
-        self.readUnusedDataSegments()
-        self.initStore()
+        //self.readUnusedDataSegments()
+        //self.initStore()
     }
+     /**
     
     func readUnusedDataSegments() {
         
-        let headerSize = sizeof(HEADER)
+        let headerSize = sizeof(ObjectStoreHeader)
+        let dataSize = self.blockSize - headerSize
         
         var pos = CUnsignedLongLong(self.fileOffset)
         
         self.fileHandle.seekToFileOffset(pos)
-    
-        var header = HEADER()
-        var headerData : NSData? = nil
-        
+ 
         while (pos < self.endOfFile) {
             // reade the complete file
             
-            headerData = readHeader()
-            headerData?.getBytes(&header, length:headerSize)
+            let header = readHeader()
             
-            self.fileHandle.readDataOfLength(self.dataSize)
+            self.fileHandle.readDataOfLength(dataSize)
             
             if !header.used {
                 // add pos into the special dictionary

            // store SampleData as ID:0 in the file
            // ID:0 is a reserved ID and should not be availabled for public access

            let sampleObject = O()
            let sampleData = sampleObject.encodeData()
            
            self.create(sampleData)
            
        }
        

        
        return nil;
    }    
*/
}
