Tuukka Norri avatar Tuukka Norri committed db7a3fc

Fixed problems with GC, thread safety
- Replaced C++ collections with Foundation collections.
- Removed unneeded C++ classes.
- Changed metadata classes so that they no longer need locking.
- Fixed race conditions in PGTSConnection.
- Removed synchronization from PGTSResultSet where it wasn't needed.
- Rewrote SQL queries that required joins as views.
- Removed an unneeded OSMemoryBarrier.

Comments (0)

Files changed (55)

BaseTen.xcodeproj/project.pbxproj

 		533BAACB0F2C000A0030CD05 /* PGTSDatabaseDescription.mm in Sources */ = {isa = PBXBuildFile; fileRef = 533BAAC90F2C000A0030CD05 /* PGTSDatabaseDescription.mm */; };
 		533BAACC0F2C000A0030CD05 /* PGTSTableDescription.mm in Sources */ = {isa = PBXBuildFile; fileRef = 533BAACA0F2C000A0030CD05 /* PGTSTableDescription.mm */; };
 		533F88410F35482000041C02 /* BXForeignKey.m in Sources */ = {isa = PBXBuildFile; fileRef = 536892570F30B9E800AAC65D /* BXForeignKey.m */; };
+		534369C811AFEF8700ADD6C1 /* BXCollectionFunctions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 534369C711AFEF8700ADD6C1 /* BXCollectionFunctions.mm */; };
 		5348B7110F575A3C00B2655E /* BXKeyPathParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 53680C0D0E59922C00A53B26 /* BXKeyPathParser.m */; };
 		5348B7130F575A3F00B2655E /* BXURLEncoding.m in Sources */ = {isa = PBXBuildFile; fileRef = 5354F7DD0F00417400422613 /* BXURLEncoding.m */; };
 		5348B7150F575A4300B2655E /* PGTSInvocationRecorder.m in Sources */ = {isa = PBXBuildFile; fileRef = 53937B660EFD097700510DBD /* PGTSInvocationRecorder.m */; };
-		5348B71E0F575AA800B2655E /* PGTSOids.m in Sources */ = {isa = PBXBuildFile; fileRef = 5354F8820F004F9300422613 /* PGTSOids.m */; };
 		5348B7270F575AE500B2655E /* NSURL+BaseTenAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 535661CB0F025DD800920008 /* NSURL+BaseTenAdditions.m */; };
 		5348B7290F575AE900B2655E /* PGTSDeleteRule.m in Sources */ = {isa = PBXBuildFile; fileRef = 5354F91D0F00511100422613 /* PGTSDeleteRule.m */; };
 		5348B72E0F575B1300B2655E /* NSString+PGTSAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 538334C40F03F4DF0040368E /* NSString+PGTSAdditions.m */; };
 		5348B7C90F575CCF00B2655E /* PGTSTableDescription.mm in Sources */ = {isa = PBXBuildFile; fileRef = 533BAACA0F2C000A0030CD05 /* PGTSTableDescription.mm */; };
 		5348B7D60F575D3400B2655E /* PGTSConnection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 53666CAB0E1CD8D20028DBEA /* PGTSConnection.mm */; };
 		5348B7E00F575DCD00B2655E /* PGTSMetadataStorage.m in Sources */ = {isa = PBXBuildFile; fileRef = 539FB3EB0F2BF20600717F71 /* PGTSMetadataStorage.m */; };
-		5348B7E10F575DCE00B2655E /* PGTSMetadataContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = 539FB3EE0F2BF20600717F71 /* PGTSMetadataContainer.m */; };
+		5348B7E10F575DCE00B2655E /* PGTSMetadataContainer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 539FB3EE0F2BF20600717F71 /* PGTSMetadataContainer.mm */; };
 		5348B7FE0F575E2100B2655E /* PGTSAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 53666CA50E1CD8D20028DBEA /* PGTSAdditions.m */; };
 		5348B8160F575E4A00B2655E /* PGTSResultSet.mm in Sources */ = {isa = PBXBuildFile; fileRef = 53666CCE0E1CD8D20028DBEA /* PGTSResultSet.mm */; };
 		5348B81E0F575E8700B2655E /* BXPGVisitor.m in Sources */ = {isa = PBXBuildFile; fileRef = 53B143E50E65A7F80043B75D /* BXPGVisitor.m */; };
 		534BE4680F34F7130098951C /* BXForeignKey.h in Headers */ = {isa = PBXBuildFile; fileRef = 5328FBD40C4580CD006DE171 /* BXForeignKey.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		534E3C7D11A77088002D49C8 /* BXSocketReachabilityObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 534E3C7B11A77088002D49C8 /* BXSocketReachabilityObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		534E3C7E11A77088002D49C8 /* BXSocketReachabilityObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = 534E3C7C11A77088002D49C8 /* BXSocketReachabilityObserver.m */; };
-		5350CC380EFBE66500EBC328 /* BXCollections.h in Headers */ = {isa = PBXBuildFile; fileRef = 5350CC360EFBE66500EBC328 /* BXCollections.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		53526E0A0E5D70EB00B67550 /* BXPredicateVisitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 53526E080E5D70EB00B67550 /* BXPredicateVisitor.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		53526E0E0E5D909B00B67550 /* BXPGFromItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 539A84DA0E5B3AFF00A2625C /* BXPGFromItem.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		53526E0F0E5D909B00B67550 /* BXPGFromItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 539A84DB0E5B3AFF00A2625C /* BXPGFromItem.m */; };
 		5354F7DE0F00417400422613 /* BXURLEncoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 5354F7DC0F00417400422613 /* BXURLEncoding.h */; };
 		5354F7DF0F00417400422613 /* BXURLEncoding.m in Sources */ = {isa = PBXBuildFile; fileRef = 5354F7DD0F00417400422613 /* BXURLEncoding.m */; };
 		5354F87B0F004A6600422613 /* BXExport.h in Headers */ = {isa = PBXBuildFile; fileRef = 5354F87A0F004A6600422613 /* BXExport.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		5354F8830F004F9300422613 /* PGTSOids.h in Headers */ = {isa = PBXBuildFile; fileRef = 5354F8810F004F9300422613 /* PGTSOids.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		5354F8840F004F9300422613 /* PGTSOids.m in Sources */ = {isa = PBXBuildFile; fileRef = 5354F8820F004F9300422613 /* PGTSOids.m */; };
 		5354F91E0F00511100422613 /* PGTSDeleteRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 5354F91C0F00511100422613 /* PGTSDeleteRule.h */; };
 		5354F91F0F00511100422613 /* PGTSDeleteRule.m in Sources */ = {isa = PBXBuildFile; fileRef = 5354F91D0F00511100422613 /* PGTSDeleteRule.m */; };
 		5355C08911A8725700C5DEAF /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5355C08811A8725700C5DEAF /* CoreServices.framework */; };
 		53666D0D0E1CD8D20028DBEA /* PGTSResultSet.mm in Sources */ = {isa = PBXBuildFile; fileRef = 53666CCE0E1CD8D20028DBEA /* PGTSResultSet.mm */; };
 		53666D0F0E1CD8D20028DBEA /* PGTSRoleDescription.h in Headers */ = {isa = PBXBuildFile; fileRef = 53666CD00E1CD8D20028DBEA /* PGTSRoleDescription.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		53666D100E1CD8D20028DBEA /* PGTSRoleDescription.mm in Sources */ = {isa = PBXBuildFile; fileRef = 53666CD10E1CD8D20028DBEA /* PGTSRoleDescription.mm */; };
-		53666D110E1CD8D20028DBEA /* BXScannedMemoryAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 53666CD20E1CD8D20028DBEA /* BXScannedMemoryAllocator.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		53666D120E1CD8D20028DBEA /* PGTSSchemaDescription.h in Headers */ = {isa = PBXBuildFile; fileRef = 53666CD30E1CD8D20028DBEA /* PGTSSchemaDescription.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		53666D130E1CD8D20028DBEA /* PGTSSchemaDescription.mm in Sources */ = {isa = PBXBuildFile; fileRef = 53666CD40E1CD8D20028DBEA /* PGTSSchemaDescription.mm */; };
 		53666D140E1CD8D20028DBEA /* PGTSTableDescription.h in Headers */ = {isa = PBXBuildFile; fileRef = 53666CD50E1CD8D20028DBEA /* PGTSTableDescription.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		538579CD119219B900426CEA /* NSArray+BaseTenAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 535661CD0F025DD800920008 /* NSArray+BaseTenAdditions.h */; };
 		538579CE119219BA00426CEA /* NSURL+BaseTenAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 535661CC0F025DD800920008 /* NSURL+BaseTenAdditions.h */; };
 		538579CF119219BB00426CEA /* PGTSDeleteRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 5354F91C0F00511100422613 /* PGTSDeleteRule.h */; };
-		538579D0119219BD00426CEA /* PGTSOids.h in Headers */ = {isa = PBXBuildFile; fileRef = 5354F8810F004F9300422613 /* PGTSOids.h */; };
 		538579D1119219BF00426CEA /* PGTSInvocationRecorder.h in Headers */ = {isa = PBXBuildFile; fileRef = 53937B650EFD097700510DBD /* PGTSInvocationRecorder.h */; };
 		538579D2119219C000426CEA /* BXHOM.h in Headers */ = {isa = PBXBuildFile; fileRef = 53666CC20E1CD8D20028DBEA /* BXHOM.h */; };
 		538579D4119219C200426CEA /* BXException.h in Headers */ = {isa = PBXBuildFile; fileRef = 5339AB910A7542EC00994B1A /* BXException.h */; };
 		539204DA11AECE07000E2BEC /* BXDictionaryFunctions.m in Sources */ = {isa = PBXBuildFile; fileRef = 539204D811AECE07000E2BEC /* BXDictionaryFunctions.m */; };
 		539204DD11AECEAF000E2BEC /* BXArrayFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = 539204DB11AECEAF000E2BEC /* BXArrayFunctions.h */; };
 		539204DE11AECEAF000E2BEC /* BXDictionaryFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = 539204DC11AECEAF000E2BEC /* BXDictionaryFunctions.h */; };
-		5392052B11AED850000E2BEC /* BXObjCPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 5392052911AED850000E2BEC /* BXObjCPtr.h */; };
-		5392052C11AED850000E2BEC /* BXObjCPtr.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5392052A11AED850000E2BEC /* BXObjCPtr.mm */; };
 		5392053D11AEDB4F000E2BEC /* BXCollectionFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = 5392053C11AEDB4F000E2BEC /* BXCollectionFunctions.h */; };
-		5392053F11AEDC88000E2BEC /* BXObjCPair.h in Headers */ = {isa = PBXBuildFile; fileRef = 5392053E11AEDC88000E2BEC /* BXObjCPair.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		5392086111AF3EEC000E2BEC /* BXScannedMemoryObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 5392085F11AF3EEC000E2BEC /* BXScannedMemoryObject.h */; };
-		5392086211AF3EEC000E2BEC /* BXScannedMemoryObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5392086011AF3EEC000E2BEC /* BXScannedMemoryObject.mm */; };
 		53937B670EFD097700510DBD /* PGTSInvocationRecorder.h in Headers */ = {isa = PBXBuildFile; fileRef = 53937B650EFD097700510DBD /* PGTSInvocationRecorder.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		53937B680EFD097700510DBD /* PGTSInvocationRecorder.m in Sources */ = {isa = PBXBuildFile; fileRef = 53937B660EFD097700510DBD /* PGTSInvocationRecorder.m */; };
 		5395E7260E2F77DF006E8441 /* BXPGEntityImporter.h in Headers */ = {isa = PBXBuildFile; fileRef = 5395E7240E2F77DF006E8441 /* BXPGEntityImporter.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		539FB3EF0F2BF20600717F71 /* PGTSMetadataStorage.m in Sources */ = {isa = PBXBuildFile; fileRef = 539FB3EB0F2BF20600717F71 /* PGTSMetadataStorage.m */; };
 		539FB3F00F2BF20600717F71 /* PGTSMetadataStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = 539FB3EC0F2BF20600717F71 /* PGTSMetadataStorage.h */; };
 		539FB3F10F2BF20600717F71 /* PGTSMetadataContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 539FB3ED0F2BF20600717F71 /* PGTSMetadataContainer.h */; };
-		539FB3F20F2BF20600717F71 /* PGTSMetadataContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = 539FB3EE0F2BF20600717F71 /* PGTSMetadataContainer.m */; };
+		539FB3F20F2BF20600717F71 /* PGTSMetadataContainer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 539FB3EE0F2BF20600717F71 /* PGTSMetadataContainer.mm */; };
 		53AA8BF30E6B65B7007A64FC /* BXPGFunctionExpressionEvaluator.h in Headers */ = {isa = PBXBuildFile; fileRef = 53AA8BF10E6B65B7007A64FC /* BXPGFunctionExpressionEvaluator.h */; };
 		53AA8BF40E6B65B7007A64FC /* BXPGFunctionExpressionEvaluator.mm in Sources */ = {isa = PBXBuildFile; fileRef = 53AA8BF20E6B65B7007A64FC /* BXPGFunctionExpressionEvaluator.mm */; };
 		53B143DE0E65A5D80043B75D /* BXPGRelationAliasMapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 53B143DC0E65A5D80043B75D /* BXPGRelationAliasMapper.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		53E3B1EB0E55C8D8001A99B5 /* PGTSConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 53666CB50E1CD8D20028DBEA /* PGTSConstants.m */; };
 		53E8985E1035B97D0062AA4D /* psqlscan.l in Sources */ = {isa = PBXBuildFile; fileRef = 53617F6B1035B89D003CE4F5 /* psqlscan.l */; };
 		53ED2E8E0E1AB7CB0095BE8B /* BXLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 53ED2E8C0E1AB7CB0095BE8B /* BXLogger.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		53F0BD9A0EC523A200773BE7 /* BXScannedMemoryAllocator.mm in Sources */ = {isa = PBXBuildFile; fileRef = 53F0BD990EC523A200773BE7 /* BXScannedMemoryAllocator.mm */; };
+		53F9D04C11B0828900600413 /* PGTSOids.h in Headers */ = {isa = PBXBuildFile; fileRef = 53F9D04A11B0828900600413 /* PGTSOids.h */; };
+		53F9D04D11B0828900600413 /* PGTSOids.mm in Sources */ = {isa = PBXBuildFile; fileRef = 53F9D04B11B0828900600413 /* PGTSOids.mm */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXBuildRule section */
 		5339AB920A7542EC00994B1A /* BXException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BXException.m; path = Sources/BXException.m; sourceTree = "<group>"; };
 		533BAAC90F2C000A0030CD05 /* PGTSDatabaseDescription.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PGTSDatabaseDescription.mm; path = Sources/PGTSDatabaseDescription.mm; sourceTree = "<group>"; };
 		533BAACA0F2C000A0030CD05 /* PGTSTableDescription.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PGTSTableDescription.mm; path = Sources/PGTSTableDescription.mm; sourceTree = "<group>"; };
+		534369C711AFEF8700ADD6C1 /* BXCollectionFunctions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = BXCollectionFunctions.mm; path = Sources/BXCollectionFunctions.mm; sourceTree = "<group>"; };
 		5347BB510B37F78000D963E7 /* BXDatabaseObjectIDPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = BXDatabaseObjectIDPrivate.h; path = Sources/BXDatabaseObjectIDPrivate.h; sourceTree = "<group>"; };
 		534A14AE0F0FBBE6002A9F68 /* BaseTenModifications.sql.m4 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = BaseTenModifications.sql.m4; path = Resources/BaseTenModifications.sql.m4; sourceTree = "<group>"; };
 		534E3C7B11A77088002D49C8 /* BXSocketReachabilityObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BXSocketReachabilityObserver.h; path = Sources/BXSocketReachabilityObserver.h; sourceTree = "<group>"; };
 		534E3C7C11A77088002D49C8 /* BXSocketReachabilityObserver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BXSocketReachabilityObserver.m; path = Sources/BXSocketReachabilityObserver.m; sourceTree = "<group>"; };
 		534EE22F0E53213300B079B0 /* libBaseTen.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libBaseTen.a; sourceTree = BUILT_PRODUCTS_DIR; };
-		5350CC360EFBE66500EBC328 /* BXCollections.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BXCollections.h; path = Sources/BXCollections.h; sourceTree = "<group>"; };
 		53526E080E5D70EB00B67550 /* BXPredicateVisitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BXPredicateVisitor.h; path = Sources/BXPredicateVisitor.h; sourceTree = "<group>"; };
 		53526E090E5D70EB00B67550 /* BXPredicateVisitor.m */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; name = BXPredicateVisitor.m; path = Sources/BXPredicateVisitor.m; sourceTree = "<group>"; };
 		535444130D634A47002A6C47 /* BaseTen.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = BaseTen.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 		5354F7DC0F00417400422613 /* BXURLEncoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BXURLEncoding.h; path = Sources/BXURLEncoding.h; sourceTree = "<group>"; };
 		5354F7DD0F00417400422613 /* BXURLEncoding.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BXURLEncoding.m; path = Sources/BXURLEncoding.m; sourceTree = "<group>"; };
 		5354F87A0F004A6600422613 /* BXExport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BXExport.h; path = Sources/BXExport.h; sourceTree = "<group>"; };
-		5354F8810F004F9300422613 /* PGTSOids.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PGTSOids.h; path = Sources/PGTSOids.h; sourceTree = "<group>"; };
-		5354F8820F004F9300422613 /* PGTSOids.m */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; name = PGTSOids.m; path = Sources/PGTSOids.m; sourceTree = "<group>"; };
 		5354F91C0F00511100422613 /* PGTSDeleteRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PGTSDeleteRule.h; path = Sources/PGTSDeleteRule.h; sourceTree = "<group>"; };
 		5354F91D0F00511100422613 /* PGTSDeleteRule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PGTSDeleteRule.m; path = Sources/PGTSDeleteRule.m; sourceTree = "<group>"; };
 		5355C08811A8725700C5DEAF /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = /System/Library/Frameworks/CoreServices.framework; sourceTree = "<absolute>"; };
 		53666CCF0E1CD8D20028DBEA /* PGTSResultSetPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PGTSResultSetPrivate.h; path = Sources/PGTSResultSetPrivate.h; sourceTree = "<group>"; };
 		53666CD00E1CD8D20028DBEA /* PGTSRoleDescription.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PGTSRoleDescription.h; path = Sources/PGTSRoleDescription.h; sourceTree = "<group>"; };
 		53666CD10E1CD8D20028DBEA /* PGTSRoleDescription.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; name = PGTSRoleDescription.mm; path = Sources/PGTSRoleDescription.mm; sourceTree = "<group>"; };
-		53666CD20E1CD8D20028DBEA /* BXScannedMemoryAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BXScannedMemoryAllocator.h; path = Sources/BXScannedMemoryAllocator.h; sourceTree = "<group>"; };
 		53666CD30E1CD8D20028DBEA /* PGTSSchemaDescription.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PGTSSchemaDescription.h; path = Sources/PGTSSchemaDescription.h; sourceTree = "<group>"; };
 		53666CD40E1CD8D20028DBEA /* PGTSSchemaDescription.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; name = PGTSSchemaDescription.mm; path = Sources/PGTSSchemaDescription.mm; sourceTree = "<group>"; };
 		53666CD50E1CD8D20028DBEA /* PGTSTableDescription.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PGTSTableDescription.h; path = Sources/PGTSTableDescription.h; sourceTree = "<group>"; };
 		539204D811AECE07000E2BEC /* BXDictionaryFunctions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BXDictionaryFunctions.m; path = Sources/BXDictionaryFunctions.m; sourceTree = "<group>"; };
 		539204DB11AECEAF000E2BEC /* BXArrayFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BXArrayFunctions.h; path = Sources/BXArrayFunctions.h; sourceTree = "<group>"; };
 		539204DC11AECEAF000E2BEC /* BXDictionaryFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BXDictionaryFunctions.h; path = Sources/BXDictionaryFunctions.h; sourceTree = "<group>"; };
-		5392052911AED850000E2BEC /* BXObjCPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BXObjCPtr.h; path = Sources/BXObjCPtr.h; sourceTree = "<group>"; };
-		5392052A11AED850000E2BEC /* BXObjCPtr.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = BXObjCPtr.mm; path = Sources/BXObjCPtr.mm; sourceTree = "<group>"; };
 		5392053C11AEDB4F000E2BEC /* BXCollectionFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BXCollectionFunctions.h; path = Sources/BXCollectionFunctions.h; sourceTree = "<group>"; };
-		5392053E11AEDC88000E2BEC /* BXObjCPair.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BXObjCPair.h; path = Sources/BXObjCPair.h; sourceTree = "<group>"; };
-		5392085F11AF3EEC000E2BEC /* BXScannedMemoryObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BXScannedMemoryObject.h; path = Sources/BXScannedMemoryObject.h; sourceTree = "<group>"; };
-		5392086011AF3EEC000E2BEC /* BXScannedMemoryObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = BXScannedMemoryObject.mm; path = Sources/BXScannedMemoryObject.mm; sourceTree = "<group>"; };
 		53933EF409EBD082001D00BB /* BXInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = BXInterface.h; path = Sources/BXInterface.h; sourceTree = "<group>"; };
 		53937B650EFD097700510DBD /* PGTSInvocationRecorder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PGTSInvocationRecorder.h; path = Sources/PGTSInvocationRecorder.h; sourceTree = "<group>"; };
 		53937B660EFD097700510DBD /* PGTSInvocationRecorder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PGTSInvocationRecorder.m; path = Sources/PGTSInvocationRecorder.m; sourceTree = "<group>"; };
 		539FB3EB0F2BF20600717F71 /* PGTSMetadataStorage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PGTSMetadataStorage.m; path = Sources/PGTSMetadataStorage.m; sourceTree = "<group>"; };
 		539FB3EC0F2BF20600717F71 /* PGTSMetadataStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PGTSMetadataStorage.h; path = Sources/PGTSMetadataStorage.h; sourceTree = "<group>"; };
 		539FB3ED0F2BF20600717F71 /* PGTSMetadataContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PGTSMetadataContainer.h; path = Sources/PGTSMetadataContainer.h; sourceTree = "<group>"; };
-		539FB3EE0F2BF20600717F71 /* PGTSMetadataContainer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PGTSMetadataContainer.m; path = Sources/PGTSMetadataContainer.m; sourceTree = "<group>"; };
+		539FB3EE0F2BF20600717F71 /* PGTSMetadataContainer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PGTSMetadataContainer.mm; path = Sources/PGTSMetadataContainer.mm; sourceTree = "<group>"; };
 		53A59B230E34EB570026D7E1 /* BXWeakNotification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BXWeakNotification.h; path = Sources/BXWeakNotification.h; sourceTree = "<group>"; };
 		53A59B240E34EB570026D7E1 /* BXWeakNotification.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BXWeakNotification.m; path = Sources/BXWeakNotification.m; sourceTree = "<group>"; };
 		53A75FEE0B032ECF0032A99C /* BXDatabaseContextPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = BXDatabaseContextPrivate.h; path = Sources/BXDatabaseContextPrivate.h; sourceTree = "<group>"; };
 		53ED2E8C0E1AB7CB0095BE8B /* BXLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BXLogger.h; path = Sources/BXLogger.h; sourceTree = "<group>"; };
 		53EFE9E00BA96444008666B7 /* BaseTenAppKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = BaseTenAppKit.xcodeproj; path = BaseTenAppKit/BaseTenAppKit.xcodeproj; sourceTree = "<group>"; };
 		53EFEA950BA98028008666B7 /* BXDatabaseObjectPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = BXDatabaseObjectPrivate.h; path = Sources/BXDatabaseObjectPrivate.h; sourceTree = "<group>"; };
-		53F0BD990EC523A200773BE7 /* BXScannedMemoryAllocator.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = BXScannedMemoryAllocator.mm; path = Sources/BXScannedMemoryAllocator.mm; sourceTree = "<group>"; };
+		53F9D04A11B0828900600413 /* PGTSOids.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PGTSOids.h; path = Sources/PGTSOids.h; sourceTree = "<group>"; };
+		53F9D04B11B0828900600413 /* PGTSOids.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PGTSOids.mm; path = Sources/PGTSOids.mm; sourceTree = "<group>"; };
 		8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Resources/Info.plist; sourceTree = "<group>"; };
 		98A6CD650F45C8420029B2C4 /* coverage-gc.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "coverage-gc.xcconfig"; sourceTree = "<group>"; };
 		98A6CD660F45C8420029B2C4 /* coverage-non-gc.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "coverage-non-gc.xcconfig"; sourceTree = "<group>"; };
 				53C4C3F31192EC10003FB842 /* BXCFHostCompatibility.h */,
 				5354F87A0F004A6600422613 /* BXExport.h */,
 				535661D70F02603600920008 /* BXLocalizedString.h */,
-				5392053E11AEDC88000E2BEC /* BXObjCPair.h */,
 				538FA0240F576278005EBFAC /* BXOpenSSLCompatibility.h */,
 				535661D80F02603600920008 /* BXSafetyMacros.h */,
 				539ACEC60E3B3FF7006602B5 /* BXDelegateProxy.h */,
 				53680C0D0E59922C00A53B26 /* BXKeyPathParser.m */,
 				53ED2E8C0E1AB7CB0095BE8B /* BXLogger.h */,
 				5364EF5B0E1B940A003D3DB6 /* BXLogger.m */,
-				5392052911AED850000E2BEC /* BXObjCPtr.h */,
-				5392052A11AED850000E2BEC /* BXObjCPtr.mm */,
 				5329E7F7119F4878000EC6ED /* BXRegularExpressions.h */,
 				5329E7F5119F4845000EC6ED /* BXRegularExpressions.m */,
-				53666CD20E1CD8D20028DBEA /* BXScannedMemoryAllocator.h */,
-				53F0BD990EC523A200773BE7 /* BXScannedMemoryAllocator.mm */,
-				5392085F11AF3EEC000E2BEC /* BXScannedMemoryObject.h */,
-				5392086011AF3EEC000E2BEC /* BXScannedMemoryObject.mm */,
 				5392034011AEA108000E2BEC /* BXValidationLock.h */,
 				5392034111AEA108000E2BEC /* BXValidationLock.m */,
 				53937B650EFD097700510DBD /* PGTSInvocationRecorder.h */,
 				53666CA80E1CD8D20028DBEA /* PGTSCertificateVerificationDelegateProtocol.h */,
 				53666CB40E1CD8D20028DBEA /* PGTSConstants.h */,
 				53666CB50E1CD8D20028DBEA /* PGTSConstants.m */,
+				5354F91C0F00511100422613 /* PGTSDeleteRule.h */,
+				5354F91D0F00511100422613 /* PGTSDeleteRule.m */,
 				53666CC60E1CD8D20028DBEA /* PGTSNotification.h */,
 				53666CC70E1CD8D20028DBEA /* PGTSNotification.m */,
-				5354F8810F004F9300422613 /* PGTSOids.h */,
-				5354F8820F004F9300422613 /* PGTSOids.m */,
-				5354F91C0F00511100422613 /* PGTSDeleteRule.h */,
-				5354F91D0F00511100422613 /* PGTSDeleteRule.m */,
+				53F9D04A11B0828900600413 /* PGTSOids.h */,
+				53F9D04B11B0828900600413 /* PGTSOids.mm */,
 				53915F9C0E3FD22D0098B419 /* libpq_additions.h */,
 				53915F9D0E3FD22D0098B419 /* libpq_additions.c */,
 			);
 			isa = PBXGroup;
 			children = (
 				536C9D5F0EFD94D10041422F /* BXEnumerate.h */,
-				5350CC360EFBE66500EBC328 /* BXCollections.h */,
 				5392053C11AEDB4F000E2BEC /* BXCollectionFunctions.h */,
+				534369C711AFEF8700ADD6C1 /* BXCollectionFunctions.mm */,
 				539204CC11AEC88E000E2BEC /* BXSetFunctions.h */,
 				539204CD11AEC88E000E2BEC /* BXSetFunctions.m */,
 				539204DB11AECEAF000E2BEC /* BXArrayFunctions.h */,
 				539FB3EC0F2BF20600717F71 /* PGTSMetadataStorage.h */,
 				539FB3EB0F2BF20600717F71 /* PGTSMetadataStorage.m */,
 				539FB3ED0F2BF20600717F71 /* PGTSMetadataContainer.h */,
-				539FB3EE0F2BF20600717F71 /* PGTSMetadataContainer.m */,
+				539FB3EE0F2BF20600717F71 /* PGTSMetadataContainer.mm */,
 			);
 			name = Fetching;
 			sourceTree = "<group>";
 				53666D0A0E1CD8D20028DBEA /* PGTSQueryDescription.h in Headers */,
 				53666D0C0E1CD8D20028DBEA /* PGTSResultSet.h in Headers */,
 				53666D0F0E1CD8D20028DBEA /* PGTSRoleDescription.h in Headers */,
-				53666D110E1CD8D20028DBEA /* BXScannedMemoryAllocator.h in Headers */,
 				53666D120E1CD8D20028DBEA /* PGTSSchemaDescription.h in Headers */,
 				53666D140E1CD8D20028DBEA /* PGTSTableDescription.h in Headers */,
 				53666D160E1CD8D20028DBEA /* PGTSTypeDescription.h in Headers */,
 				535F235B0E8A8D5900311CB5 /* BXPGRelationshipExpressionValueType.h in Headers */,
 				535F24C00E8AA62800311CB5 /* BXPGObjectExpressionValueType.h in Headers */,
 				535F24EE0E8AA96B00311CB5 /* BXPGIdentityExpressionValueType.h in Headers */,
-				5350CC380EFBE66500EBC328 /* BXCollections.h in Headers */,
 				53937B670EFD097700510DBD /* PGTSInvocationRecorder.h in Headers */,
 				536C9D600EFD94D10041422F /* BXEnumerate.h in Headers */,
 				5354F7DE0F00417400422613 /* BXURLEncoding.h in Headers */,
 				5354F87B0F004A6600422613 /* BXExport.h in Headers */,
-				5354F8830F004F9300422613 /* PGTSOids.h in Headers */,
 				5354F91E0F00511100422613 /* PGTSDeleteRule.h in Headers */,
 				535661D20F025DD800920008 /* NSURL+BaseTenAdditions.h in Headers */,
 				535661D30F025DD800920008 /* NSArray+BaseTenAdditions.h in Headers */,
 				539204D211AEC944000E2BEC /* NSObject+BaseTenAdditions.h in Headers */,
 				539204DD11AECEAF000E2BEC /* BXArrayFunctions.h in Headers */,
 				539204DE11AECEAF000E2BEC /* BXDictionaryFunctions.h in Headers */,
-				5392052B11AED850000E2BEC /* BXObjCPtr.h in Headers */,
 				5392053D11AEDB4F000E2BEC /* BXCollectionFunctions.h in Headers */,
-				5392053F11AEDC88000E2BEC /* BXObjCPair.h in Headers */,
-				5392086111AF3EEC000E2BEC /* BXScannedMemoryObject.h in Headers */,
+				53F9D04C11B0828900600413 /* PGTSOids.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
 				538579CD119219B900426CEA /* NSArray+BaseTenAdditions.h in Headers */,
 				538579CE119219BA00426CEA /* NSURL+BaseTenAdditions.h in Headers */,
 				538579CF119219BB00426CEA /* PGTSDeleteRule.h in Headers */,
-				538579D0119219BD00426CEA /* PGTSOids.h in Headers */,
 				538579D1119219BF00426CEA /* PGTSInvocationRecorder.h in Headers */,
 				538579D2119219C000426CEA /* BXHOM.h in Headers */,
 				538579D4119219C200426CEA /* BXException.h in Headers */,
 				5348B7110F575A3C00B2655E /* BXKeyPathParser.m in Sources */,
 				5348B7130F575A3F00B2655E /* BXURLEncoding.m in Sources */,
 				5348B7150F575A4300B2655E /* PGTSInvocationRecorder.m in Sources */,
-				5348B71E0F575AA800B2655E /* PGTSOids.m in Sources */,
 				5348B7270F575AE500B2655E /* NSURL+BaseTenAdditions.m in Sources */,
 				5348B7290F575AE900B2655E /* PGTSDeleteRule.m in Sources */,
 				5348B72E0F575B1300B2655E /* NSString+PGTSAdditions.m in Sources */,
 				5348B7C90F575CCF00B2655E /* PGTSTableDescription.mm in Sources */,
 				5348B7D60F575D3400B2655E /* PGTSConnection.mm in Sources */,
 				5348B7E00F575DCD00B2655E /* PGTSMetadataStorage.m in Sources */,
-				5348B7E10F575DCE00B2655E /* PGTSMetadataContainer.m in Sources */,
+				5348B7E10F575DCE00B2655E /* PGTSMetadataContainer.mm in Sources */,
 				5348B7FE0F575E2100B2655E /* PGTSAdditions.m in Sources */,
 				5348B8160F575E4A00B2655E /* PGTSResultSet.mm in Sources */,
 				5348B81E0F575E8700B2655E /* BXPGVisitor.m in Sources */,
 				535F235C0E8A8D5900311CB5 /* BXPGRelationshipExpressionValueType.m in Sources */,
 				535F24C10E8AA62800311CB5 /* BXPGObjectExpressionValueType.m in Sources */,
 				535F24EF0E8AA96B00311CB5 /* BXPGIdentityExpressionValueType.m in Sources */,
-				53F0BD9A0EC523A200773BE7 /* BXScannedMemoryAllocator.mm in Sources */,
 				53937B680EFD097700510DBD /* PGTSInvocationRecorder.m in Sources */,
 				5354F7DF0F00417400422613 /* BXURLEncoding.m in Sources */,
-				5354F8840F004F9300422613 /* PGTSOids.m in Sources */,
 				5354F91F0F00511100422613 /* PGTSDeleteRule.m in Sources */,
 				535661D10F025DD800920008 /* NSURL+BaseTenAdditions.m in Sources */,
 				535661D40F025DD800920008 /* NSArray+BaseTenAdditions.m in Sources */,
 				539FB3AF0F2BEFC400717F71 /* PGTSColumnDescription.m in Sources */,
 				539FB3E50F2BF10500717F71 /* PGTSSchemaObjectDescription.m in Sources */,
 				539FB3EF0F2BF20600717F71 /* PGTSMetadataStorage.m in Sources */,
-				539FB3F20F2BF20600717F71 /* PGTSMetadataContainer.m in Sources */,
+				539FB3F20F2BF20600717F71 /* PGTSMetadataContainer.mm in Sources */,
 				533BAACB0F2C000A0030CD05 /* PGTSDatabaseDescription.mm in Sources */,
 				533BAACC0F2C000A0030CD05 /* PGTSTableDescription.mm in Sources */,
 				53688DEE0F2F64F200AAC65D /* BXPGEFMetadataContainer.m in Sources */,
 				539204D311AEC944000E2BEC /* NSObject+BaseTenAdditions.m in Sources */,
 				539204D911AECE07000E2BEC /* BXArrayFunctions.m in Sources */,
 				539204DA11AECE07000E2BEC /* BXDictionaryFunctions.m in Sources */,
-				5392052C11AED850000E2BEC /* BXObjCPtr.mm in Sources */,
-				5392086211AF3EEC000E2BEC /* BXScannedMemoryObject.mm in Sources */,
+				534369C811AFEF8700ADD6C1 /* BXCollectionFunctions.mm in Sources */,
+				53F9D04D11B0828900600413 /* PGTSOids.mm in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Resources/BaseTenModifications.sql.m4

 
 changequote(`{{', `}}')
 -- ' -- Fix for syntax coloring in SQL mode.
-define({{_bx_version_}}, {{0.939}})dnl
-define({{_bx_compat_version_}}, {{0.24}})dnl
+define({{_bx_version_}}, {{0.940}})dnl
+define({{_bx_compat_version_}}, {{0.25}})dnl
 
 
 \unset ON_ERROR_ROLLBACK
 GRANT SELECT ON "baseten"._primary_key TO basetenread;
 
 
+CREATE VIEW "baseten".relation_oids AS
+    SELECT c.oid, r.enabled
+    FROM "baseten".relation r
+    INNER JOIN pg_class c ON (c.relname = r.relname)
+    INNER JOIN pg_namespace n ON (n.nspname = r.nspname AND n.oid = c.relnamespace);
+REVOKE ALL PRIVILEGES ON "baseten".relation_oids FROM PUBLIC;
+GRANT SELECT ON "baseten".relation_oids TO basetenread;
+
+
+CREATE VIEW "baseten".view_pkey_oids AS
+    SELECT c.oid, "baseten".array_accum (v.attname) AS attnames
+    FROM "baseten".view_pkey v
+    INNER JOIN pg_class c ON (c.relname = v.relname)
+    INNER JOIN pg_namespace n ON (n.nspname = v.nspname AND n.oid = c.relnamespace)
+    GROUP BY c.oid;
+REVOKE ALL PRIVILEGES ON "baseten".view_pkey_oids FROM PUBLIC;
+GRANT SELECT ON "baseten".view_pkey_oids TO basetenread;
+
+
 CREATE FUNCTION "baseten"._fkey_columns_max () RETURNS INTEGER AS $$
 	SELECT max (array_upper (conkey, 1)) FROM pg_constraint c WHERE c.contype = 'f';
 $$ STABLE LANGUAGE SQL;

Sources/BXCollectionFunctions.h

 //
 
 #import <Foundation/Foundation.h>
+#import <BaseTen/BXExport.h>
+
+
+BX_INTERNAL BOOL FindElement (id collection, id key, void *outValue);
+
 
 
 #if defined(__cplusplus)
 namespace BaseTen {
 	
-	namespace CollectionFunctions {
+	template <typename T>
+	inline id ObjectValue (T value)
+	{
+		return [NSValue valueWithBytes: &value objCType: @encode (T)];
+	}
+	
+	template <> id ObjectValue (float value);
+	template <> id ObjectValue (double value);
+	template <> id ObjectValue (char value);
+	template <> id ObjectValue (short value);
+	template <> id ObjectValue (int value);
+	template <> id ObjectValue (long value);
+	template <> id ObjectValue (long long value);
+	template <> id ObjectValue (unsigned char value);
+	template <> id ObjectValue (unsigned short value);
+	template <> id ObjectValue (unsigned int value);
+	template <> id ObjectValue (unsigned long value);
+	template <> id ObjectValue (unsigned long long value);
+	
+	
+	template <typename T>
+	inline id FindObject (NSDictionary *collection, T *key)
+	{
+		return [collection objectForKey: key];
+	}
 
-		template <typename T>
-		BOOL ContainsKey (T *container, typename T::key_type key)
-		{
-			BOOL retval = NO;
-			if (container)
-			{
-				typename T::const_iterator it = container->find (key);
-				if (container->end () != it)
-					retval = YES;
-			}
-			return retval;
-		}
-		
-		
-		template <typename T>
-		BOOL ContainsKey (T *container, typename T::key_type::element_type key)
-		{
-			BOOL retval = NO;
-			if (container)
-			{
-				BaseTen::ObjCPtr <typename T::key_type::element_type> keyPtr (key);
-				typename T::const_iterator it = container->find (keyPtr);
-				if (container->end () != it)
-					retval = YES;
-			}
-			return retval;
-		}		
-		
-		
-		template <typename T>
-		BOOL FindElement (T *container, typename T::key_type key, typename T::mapped_type *outVal)
-		{
-			BOOL retval = NO;
-			if (container && outVal)
-			{
-				typename T::const_iterator it = container->find (key);
-				if (container->end () != it)
-				{
-					*outVal = it->second;
-					retval = YES;
-				}
-			}
-			return retval;
-		}
-		
-		
-		template <typename T>
-		BOOL FindElement (T *container, typename T::key_type::element_type key, typename T::mapped_type *outVal)
-		{
-			BOOL retval = NO;
-			if (container && outVal)
-			{
-				BaseTen::ObjCPtr <typename T::key_type::element_type> keyPtr (key);
-				typename T::const_iterator it = container->find (keyPtr);
-				if (container->end () != it)
-				{
-					*outVal = it->second;
-					retval = YES;
-				}
-			}
-			return retval;
-		}		
-		
-		
-		template <typename T>
-		typename T::mapped_type::element_type FindObject (T *container, typename T::key_type key)
-		{
-			typename T::mapped_type::element_type retval = nil;
-			if (container)
-			{
-				typename T::const_iterator it = container->find (key);
-				if (container->end () != it)
-					retval = *it->second;
-			}
-			return retval;
-		}
-		
-		
-		template <typename T>
-		typename T::mapped_type::element_type FindObject (T *container, typename T::key_type::element_type key)
-		{
-			typename T::mapped_type::element_type retval = nil;
-			if (container)
-			{
-				BaseTen::ObjCPtr <typename T::key_type::element_type> keyPtr (key);
-				typename T::const_iterator it = container->find (keyPtr);
-				if (container->end () != it)
-					retval = *it->second;
-			}
-			return retval;
-		}		
-		
-		
-		template <typename T>
-		void Insert (T *container, typename T::key_type key, typename T::mapped_type val)
-		{
-			container->insert (std::make_pair (key, val));
-		}
-		
-		
-		template <typename T>
-		void Insert (T *container, typename T::key_type::element_type key, typename T::mapped_type val)
-		{
-			typename T::key_type keyPtr (key);
-			container->insert (std::make_pair (keyPtr, val));
-		}
-		
-		
-		template <typename T>
-		void Insert (T *container, typename T::key_type key, typename T::mapped_type::element_type val)
-		{
-			typename T::mapped_type valPtr (val);
-			container->insert (std::make_pair (key, valPtr));
-		}
-		
-		
-		template <typename T>
-		void Insert (T *container, typename T::key_type::element_type key, typename T::mapped_type::element_type val)
-		{
-			typename T::key_type keyPtr (key);
-			typename T::mapped_type valPtr (val);
-			container->insert (std::make_pair (keyPtr, valPtr));
-		}		
-		
-		
-		template <typename T>
-		void InsertConditionally (T *container, typename T::key_type key, typename T::mapped_type val)
-		{
-			if (! ContainsKey (container, key))
-				Insert (container, key, val);
-		}
-		
-		
-		template <typename T>
-		void InsertConditionally (T *container, typename T::key_type::element_type key, typename T::mapped_type val)
-		{
-			if (! ContainsKey (container, key))
-				Insert (container, key, val);
-		}		
-		
-		
-		template <typename T>
-		void InsertConditionally (T *container, typename T::key_type key, typename T::mapped_type::element_type val)
-		{
-			if (! ContainsKey (container, key))
-				Insert (container, key, val);
-		}
-		
-		
-		template <typename T>
-		void InsertConditionally (T *container, typename T::key_type::element_type key, typename T::mapped_type::element_type val)
-		{
-			if (! ContainsKey (container, key))
-				Insert (container, key, val);
-		}
-		
-		
-		template <typename T>
-		void PushBack (T *container, typename T::value_type::element_type val)
-		{
-			if (container)
-			{
-				typename T::value_type valPtr (val);
-				container->push_back (valPtr);
-			}
-		}
+	
+	template <typename T>
+	inline id FindObject (NSDictionary *collection, T key)
+	{
+		NSValue *keyObject = ObjectValue (key);
+		return FindObject (collection, keyObject);
+	}
+	
+	
+	template <typename T, typename U>
+	inline void Insert (NSMutableDictionary *collection, T key, U value)
+	{
+		NSValue *keyObject = ObjectValue (key);
+		NSValue *valueObject = ObjectValue (value);
+		Insert (collection, keyObject, valueObject);
+	}
+	
+	
+	template <typename T, typename U>
+	inline void Insert (NSMutableDictionary *collection, T *key, U *value)
+	{
+		[collection setObject: value forKey: key];
+	}	
+	
+	
+	template <typename T, typename U>
+	inline void Insert (NSMutableDictionary *collection, T *key, U value)
+	{
+		NSValue *valueObject = ObjectValue (value);
+		Insert (collection, key, valueObject);
+	}
+	
+	
+	template <typename T, typename U>
+	inline void Insert (NSMutableDictionary *collection, T key, U *value)
+	{
+		NSValue *keyObject = ObjectValue (key);
+		Insert (collection, keyObject, value);
+	}
+	
+	
+	template <typename T, typename U>
+	inline void InsertConditionally (NSMutableDictionary *collection, T key, U value)
+	{
+		NSValue *keyObject = ObjectValue (key);
+		if (! [collection objectForKey: keyObject])
+			Insert (collection, keyObject, value);
+	}
+	
+	
+	template <typename T, typename U>
+	inline void InsertConditionally (NSMutableDictionary *collection, T *key, U value)
+	{
+		if (! [collection objectForKey: key])
+			Insert (collection, key, value);
 	}
 }
 #endif

Sources/BXCollections.h

-//
-// BXCollections.h
-// BaseTen
-//
-// Copyright (C) 2008-2010 Marko Karppinen & Co. LLC.
-//
-// Before using this software, please review the available licensing options
-// by visiting http://www.karppinen.fi/baseten/licensing/ or by contacting
-// us at sales@karppinen.fi. Without an additional license, this software
-// may be distributed only in compliance with the GNU General Public License.
-//
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License, version 2.0,
-// as published by the Free Software Foundation.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-//
-// $Id$
-//
-
-#import <Foundation/Foundation.h>
-
-
-#if defined(__cplusplus)
-#import <BaseTen/BXScannedMemoryAllocator.h>
-#import <BaseTen/BXScannedMemoryObject.h>
-#import <BaseTen/BXObjCPtr.h>
-#import <BaseTen/BXObjCPair.h>
-#import <list>
-#import <tr1/unordered_set>
-#import <tr1/unordered_map>
-namespace BaseTen
-{
-	namespace internal {
-		
-		template <typename T>
-		class list :
-			public std::list <T, BaseTen::ScannedMemoryAllocator <T> >,
-			public BaseTen::ScannedMemoryObject
-		{
-		public:
-			typedef std::list <T, BaseTen::ScannedMemoryAllocator <T> > _Base;
-			
-			explicit list () : _Base () {};
-			explicit list (typename _Base::size_type size) : _Base (size) {};
-		};
-		
-		
-		template <typename T>
-		class unordered_set : 
-			public std::tr1::unordered_set <
-				T,
-				std::tr1::hash <T>,
-				std::equal_to <T>,
-				BaseTen::ScannedMemoryAllocator <T>
-			>,
-			public BaseTen::ScannedMemoryObject
-		{
-		public:
-			typedef std::tr1::unordered_set <
-				T,
-				std::tr1::hash <T>,
-				std::equal_to <T>,
-				BaseTen::ScannedMemoryAllocator <T>
-			> _Base;
-
-			explicit unordered_set (typename _Base::size_type size = 10) : _Base (size) {};
-		};
-		
-		
-		template <typename T, typename U>
-		class unordered_map :
-			public std::tr1::unordered_map <
-				T,
-				U,
-				std::tr1::hash <T>,
-				std::equal_to <T>,
-				BaseTen::ScannedMemoryAllocator <std::pair <
-					const T, U
-				> >
-			>,
-			public BaseTen::ScannedMemoryObject
-		{
-		public:
-			typedef std::tr1::unordered_map <
-				T,
-				U,
-				std::tr1::hash <T>,
-				std::equal_to <T>,
-				BaseTen::ScannedMemoryAllocator <std::pair <
-					const T, U
-				> >
-			> _Base;
-			
-			explicit unordered_map (typename _Base::size_type size = 10) : _Base (size) {};
-		};
-	}
-	
-	
-	typedef ObjCPtr <id> IdPtr;
-	typedef ObjCPair <id, id> IdPair;
-
-	
-	typedef BaseTen::internal::list <IdPtr> IdList;
-	typedef BaseTen::internal::unordered_set <IdPair> IdPairSet;
-	typedef BaseTen::internal::unordered_map <IdPtr, IdPtr> IdMap;
-	typedef BaseTen::internal::unordered_map <NSInteger, IdPtr> IndexMap;
-}
-
-#define BX_IdList    __strong BaseTen::IdList
-#define BX_IdMap     __strong BaseTen::IdMap
-#define BX_IndexMap  __strong BaseTen::IndexMap
-#define BX_IdPairSet __strong BaseTen::IdPairSet
-
-#else
-#define BX_IdList    __strong void
-#define BX_IdMap     __strong void
-#define BX_IndexMap  __strong void
-#define BX_IdPairSet __strong void
-#endif

Sources/BXConnectionMonitor.m

 		[mMonitorThread setName: @"org.basetenframework.ConnectionMonitorThread"];
 		[mMonitorThread start];
 		
-		OSMemoryBarrier (); // Make sure that the variables get written.
 		[self performSelector: @selector (_scheduleSystemEventNotifier:)
 					 onThread: mMonitorThread 
 				   withObject: mSystemEventNotifier

Sources/BXDatabaseObjectModelMOMSerialization.mm

 #import <CoreData/CoreData.h>
 #import <tr1/unordered_map>
 #import "BXDatabaseObjectModel.h"
-#import "BXCollections.h"
 #import "BXEnumerate.h"
 #import "BXEntityDescription.h"
 #import "BXAttributeDescription.h"
 
 
 using namespace BaseTen;
-using namespace BaseTen::CollectionFunctions;
 
 
-typedef std::tr1::unordered_map <
-	IdPtr,
-	NSAttributeType,
-	std::tr1::hash <IdPtr>,
-	std::equal_to <IdPtr>,
-	BaseTen::ScannedMemoryAllocator <std::pair <
-		const IdPtr, NSAttributeType
-	> > 
-> IdentifierMap;
-
-
-static IdentifierMap gTypeMapping;
-__strong static NSDictionary* gNameMapping;
+__strong static NSDictionary *gTypeMapping;
+__strong static NSDictionary *gNameMapping;
 
 
 @implementation BXDatabaseObjectModelMOMSerialization
 	{
 		tooLate = YES;
 		
-		gTypeMapping [IdPtr (@"bit")]         = NSStringAttributeType;
-		gTypeMapping [IdPtr (@"bool")]        = NSBooleanAttributeType;
-		gTypeMapping [IdPtr (@"bytea")]       = NSBinaryDataAttributeType;
-		gTypeMapping [IdPtr (@"char")]        = NSStringAttributeType;
-		gTypeMapping [IdPtr (@"date")]        = NSDateAttributeType;
-		gTypeMapping [IdPtr (@"float4")]      = NSFloatAttributeType;
-		gTypeMapping [IdPtr (@"float8")]      = NSDoubleAttributeType;
-		gTypeMapping [IdPtr (@"int2")]        = NSInteger16AttributeType;
-		gTypeMapping [IdPtr (@"int4")]        = NSInteger32AttributeType;
-		gTypeMapping [IdPtr (@"int8")]        = NSInteger64AttributeType;
-		gTypeMapping [IdPtr (@"name")]        = NSStringAttributeType;
-		gTypeMapping [IdPtr (@"numeric")]     = NSDecimalAttributeType;
-		gTypeMapping [IdPtr (@"oid")]         = NSInteger32AttributeType;
-		gTypeMapping [IdPtr (@"text")]        = NSStringAttributeType;
-		gTypeMapping [IdPtr (@"timestamp")]   = NSDateAttributeType;
-		gTypeMapping [IdPtr (@"timestamptz")] = NSDateAttributeType;
-		gTypeMapping [IdPtr (@"time")]        = NSDateAttributeType;
-		gTypeMapping [IdPtr (@"timetz")]      = NSDateAttributeType;
-		gTypeMapping [IdPtr (@"varbit")]      = NSStringAttributeType;
-		gTypeMapping [IdPtr (@"varchar")]     = NSStringAttributeType;
-		gTypeMapping [IdPtr (@"bpchar")]      = NSStringAttributeType;
-		gTypeMapping [IdPtr (@"uuid")]        = NSStringAttributeType;
-		
+		gTypeMapping = [[NSDictionary alloc] initWithObjectsAndKeys:
+						ObjectValue <NSAttributeType> (NSStringAttributeType),		@"bit",
+						ObjectValue <NSAttributeType> (NSBooleanAttributeType),		@"bool",
+						ObjectValue <NSAttributeType> (NSBinaryDataAttributeType),	@"bytea",
+						ObjectValue <NSAttributeType> (NSStringAttributeType),		@"char",
+						ObjectValue <NSAttributeType> (NSDateAttributeType),		@"date",
+						ObjectValue <NSAttributeType> (NSFloatAttributeType),		@"float4",
+						ObjectValue <NSAttributeType> (NSDoubleAttributeType),		@"float8",
+						ObjectValue <NSAttributeType> (NSInteger16AttributeType),	@"int2",
+						ObjectValue <NSAttributeType> (NSInteger32AttributeType),	@"int4",
+						ObjectValue <NSAttributeType> (NSInteger64AttributeType),	@"int8",
+						ObjectValue <NSAttributeType> (NSStringAttributeType),		@"name",
+						ObjectValue <NSAttributeType> (NSDecimalAttributeType),		@"numeric",
+						ObjectValue <NSAttributeType> (NSInteger32AttributeType),	@"oid",
+						ObjectValue <NSAttributeType> (NSStringAttributeType),		@"text",
+						ObjectValue <NSAttributeType> (NSDateAttributeType),		@"timestamp",
+						ObjectValue <NSAttributeType> (NSDateAttributeType),		@"timestamptz",
+						ObjectValue <NSAttributeType> (NSDateAttributeType),		@"time",
+						ObjectValue <NSAttributeType> (NSDateAttributeType),		@"timetz",
+						ObjectValue <NSAttributeType> (NSStringAttributeType),		@"varbit",
+						ObjectValue <NSAttributeType> (NSStringAttributeType),		@"varchar",
+						ObjectValue <NSAttributeType> (NSStringAttributeType),		@"bpchar",
+						ObjectValue <NSAttributeType> (NSStringAttributeType),		@"uuid",
+						nil];
 		gNameMapping = [[NSDictionary alloc] initWithObjectsAndKeys:
 						@"modelDescription", @"description",
 						@"modelObjectID", @"objectID",
 				[attr setOptional: [bxAttr isOptional]];
 				
 				NSAttributeType attributeType = NSUndefinedAttributeType;
-				FindElement (&gTypeMapping, [bxAttr databaseTypeName], &attributeType);
+				FindElement (gTypeMapping, [bxAttr databaseTypeName], &attributeType);
 				[attr setAttributeType: attributeType];
 				
 				NSDictionary* userInfo = [NSDictionary dictionaryWithObject: [bxAttr databaseTypeName] forKey: @"Database type"];

Sources/BXDispatchSocketDescriptor.m

 {
 	[userInfo retain];
 	dispatch_async (mQueue, ^{
-		[mDelegate socketLocked: mSocket userInfo: userInfo];
+		[[self delegate] socketDescriptor: self lockedSocket: mSocket userInfo: userInfo];
 		[userInfo release];
 	});
 }
 - (void) lockAndWait: (id) userInfo
 {
 	if ([self isLocked])
-		[mDelegate socketLocked: mSocket userInfo: userInfo];
+		[[self delegate] socketDescriptor: self lockedSocket: mSocket userInfo: userInfo];
 	else
 	{
 		dispatch_sync (mQueue, ^{
-			[mDelegate socketLocked: mSocket userInfo: userInfo];
+			[[self delegate] socketDescriptor: self lockedSocket: mSocket userInfo: userInfo];
 		});
 	}
 }

Sources/BXLogger.m

 	NSString *message = [[[NSString alloc] initWithFormat: messageFmt arguments: args] autorelease];
 		
 	const char isMain = ([NSThread isMainThread] ? 'm' : 's');
-	fprintf (stderr, "%23s  %s (%s) [%d]  %s:%d  %s [%p%c] \t%8s %s\n", 
-		[date UTF8String], executable, library ?: "???", getpid (), file, line, functionName, [NSThread currentThread], isMain, LogLevel (level), [message UTF8String]);
+	fprintf (stderr, "%23s  %s (%s) [%d %p%c]  %s:%d  %s \t%8s %s\n", 
+		[date UTF8String], executable, library ?: "???", getpid (), [NSThread currentThread], isMain, file, line, functionName, LogLevel (level), [message UTF8String]);
 	fflush (stderr);
 	
 	//For GC.

Sources/BXObjCPair.h

-//
-// BXObjCPair.h
-// BaseTen
-//
-// Copyright (C) 2008-2010 Marko Karppinen & Co. LLC.
-//
-// Before using this software, please review the available licensing options
-// by visiting http://www.karppinen.fi/baseten/licensing/ or by contacting
-// us at sales@karppinen.fi. Without an additional license, this software
-// may be distributed only in compliance with the GNU General Public License.
-//
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License, version 2.0,
-// as published by the Free Software Foundation.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-//
-// $Id$
-//
-
-#import <Foundation/Foundation.h>
-
-
-#if defined(__cplusplus)
-#import <BaseTen/BXObjCPtr.h>
-
-namespace BaseTen
-{
-	template <typename T, typename U>
-	struct ObjCPair
-	{
-		ObjCPtr <T> first;
-		ObjCPtr <U> second;
-		
-		explicit ObjCPair (T a, U b):
-			first (a), second (b) {}
-		
-		ObjCPair (const ObjCPair& p):
-			first (* p.first), second (* p.second) {}
-		
-		bool operator== (const ObjCPair <T, U> &other) const
-		{
-			return (first == other.first && second == other.second);
-		}		
-	};	
-}
-
-
-namespace std {
-	
-	namespace tr1 {
-		
-		template <typename T, typename U>
-		struct hash <BaseTen::ObjCPair <T, U> > {
-			
-			std::size_t
-			operator() (BaseTen::ObjCPair <T, U> const &val) const
-			{
-				return (val.first.hash () ^ val.second.hash ());
-			}
-		};
-	}
-}
-#endif

Sources/BXObjCPtr.h

-//
-// BXObjCPtr.h
-// BaseTen
-//
-// Copyright (C) 2010 Marko Karppinen & Co. LLC.
-//
-// Before using this software, please review the available licensing options
-// by visiting http://basetenframework.org/licensing/ or by contacting
-// us at sales@karppinen.fi. Without an additional license, this software
-// may be distributed only in compliance with the GNU General Public License.
-//
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License, version 2.0,
-// as published by the Free Software Foundation.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-//
-// $Id$
-//
-
-#import <Foundation/Foundation.h>
-
-
-#if defined(__cplusplus)
-#import <cstddef>
-#import <tr1/functional>
-
-
-namespace BaseTen {
-	
-	class ObjCPtrBase {
-		
-	protected:
-		__strong id mPtr;
-		
-	private:
-		ObjCPtrBase (ObjCPtrBase const &);
-		ObjCPtrBase &operator= (ObjCPtrBase const &);
-		
-	public:
-		explicit ObjCPtrBase (): mPtr (nil) {}
-		~ObjCPtrBase () { assign (nil); }
-		
-		void assign (id ptr);
-		
-		std::size_t hash () const { return [mPtr hash]; }
-	};
-	
-
-	template <typename T>
-	class ObjCPtr : public ObjCPtrBase {
-		
-	private:
-		ObjCPtr &operator= (ObjCPtr const &);
-		
-	public:
-		typedef T element_type;
-		
-		explicit ObjCPtr (T ptr = nil) { assign (ptr); }
-		ObjCPtr (ObjCPtr const &other) { assign (other.mPtr); }
-		T operator() () const { return mPtr; }
-		T operator*  () const { return mPtr; }
-		
-		bool operator== (ObjCPtr <T> const &other) const { 
-			std::equal_to <T> eq;
-			return (mPtr == other.mPtr || eq (mPtr, other.mPtr));
-		}
-	};
-}
-
-
-
-namespace std {
-	
-	template <>
-    struct equal_to <NSString *>
-    {
-		bool
-		operator() (NSString const * const &a, NSString const * const &b) const
-		{
-			return [a isEqualToString: b];
-		}
-    };
-	
-	
-	template <>
-	struct equal_to <id>
-	{
-		bool
-		operator() (id const &a, id const &b) const
-		{
-			return [a isEqual: b];
-		}
-	};
-	
-	
-	
-	namespace tr1 {
-		
-		template <typename T>
-		struct hash <BaseTen::ObjCPtr <T> > {
-			
-			std::size_t
-			operator() (const BaseTen::ObjCPtr <T> &val) const
-			{
-				return val.hash ();
-			}
-		};
-	}
-}
-#endif

Sources/BXObjCPtr.mm

-//
-// BXObjCPtr.mm
-// BaseTen
-//
-// Copyright (C) 2010 Marko Karppinen & Co. LLC.
-//
-// Before using this software, please review the available licensing options
-// by visiting http://basetenframework.org/licensing/ or by contacting
-// us at sales@karppinen.fi. Without an additional license, this software
-// may be distributed only in compliance with the GNU General Public License.
-//
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License, version 2.0,
-// as published by the Free Software Foundation.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-//
-// $Id$
-//
-
-#import "BXObjCPtr.h"
-#import "BXScannedMemoryAllocator.h"
-#import <objc/objc-auto.h>
-
-
-void
-BaseTen::ObjCPtrBase::assign (id ptr)
-{
-	if (BaseTen::ScannedMemoryAllocatorBase::collection_enabled)
-	{
-		// To make sure we manually set the write barrier.
-		objc_assign_strongCast (ptr, &mPtr);
-	}
-	else
-	{
-		// Use RR instead.
-		if (mPtr != ptr)
-		{
-			[mPtr release];
-			mPtr = [ptr retain];
-		}
-	}
-}

Sources/BXPGClearLocksHandler.m

 #import "BXLogger.h"
 #import "PGTSAdditions.h"
 #import "BXHOM.h"
-#import "PGTSOids.h"
 
 
 static void

Sources/BXPGDatabaseDescription.h

 
 #import <Foundation/Foundation.h>
 #import <BaseTen/PGTSDatabaseDescription.h>
-#import <BaseTen/BXCollections.h>
 
 
 @class BXPGForeignKeyDescription;
 
 @interface BXPGDatabaseDescription : PGTSDatabaseDescription
 {
-	NSNumber* mSchemaVersion;
-	NSNumber* mSchemaCompatibilityVersion;
+	NSNumber *mSchemaVersion;
+	NSNumber *mSchemaCompatibilityVersion;
+	NSDictionary *mForeignKeysByIdentifier;
 	BOOL mHasBaseTenSchema;
-	BX_IndexMap* mForeignKeysByIdentifier;
+	BOOL mHasCompatibleBaseTenSchemaVersion;
 }
 - (BOOL) hasBaseTenSchema;
+- (BOOL) hasCompatibleBaseTenSchemaVersion;
 - (NSNumber *) schemaVersion;
 - (NSNumber *) schemaCompatibilityVersion;
 - (BXPGForeignKeyDescription *) foreignKeyWithIdentifier: (NSInteger) identifier;
 - (void) setSchemaVersion: (NSNumber *) number;
 - (void) setSchemaCompatibilityVersion: (NSNumber *) number;
 - (void) setHasBaseTenSchema: (BOOL) aBool;
-- (void) addForeignKey: (BXPGForeignKeyDescription *) fkey;
+- (void) setHasCompatibleBaseTenSchemaVersion: (BOOL) flag;
+- (void) setForeignKeys: (id <NSFastEnumeration>) foreignKeys;
 @end

Sources/BXPGDatabaseDescription.m

 #import "BXCollectionFunctions.h"
 
 
-using namespace BaseTen::CollectionFunctions;
+using namespace BaseTen;
 
 
 @implementation BXPGDatabaseDescription
-- (id) init
-{
-	if ((self = [super init]))
-	{
-		mForeignKeysByIdentifier = new BaseTen::IndexMap ();
-	}
-	return self;
-}
-
 - (void) dealloc
 {
 	[mSchemaVersion release];
 	[mSchemaCompatibilityVersion release];
-	delete mForeignKeysByIdentifier;
+	[mForeignKeysByIdentifier release];
 	[super dealloc];
 }
 
 	return mHasBaseTenSchema;
 }
 
+
+- (BOOL) hasCompatibleBaseTenSchemaVersion
+{
+	return mHasCompatibleBaseTenSchemaVersion;
+}
+
+
 - (NSNumber *) schemaVersion
 {
 	return mSchemaVersion;
 	mHasBaseTenSchema = aBool;
 }
 
-- (void) addForeignKey: (BXPGForeignKeyDescription *) fkey
+
+- (void) setHasCompatibleBaseTenSchemaVersion: (BOOL) flag
 {
-	InsertConditionally (mForeignKeysByIdentifier, [fkey identifier], fkey);
+	mHasCompatibleBaseTenSchemaVersion = flag;
 }
 
+
+- (void) setForeignKeys: (id <NSFastEnumeration>) foreignKeys
+{
+	NSMutableDictionary *foreignKeysByIdentifier = [NSMutableDictionary dictionary];
+	for (BXPGForeignKeyDescription *fkey in foreignKeys)
+		Insert (foreignKeysByIdentifier, [fkey identifier], fkey);
+	
+	[mForeignKeysByIdentifier release];
+	mForeignKeysByIdentifier = [foreignKeysByIdentifier copy];
+}
+
+
 - (BXPGForeignKeyDescription *) foreignKeyWithIdentifier: (NSInteger) identifier
 {
 	return FindObject (mForeignKeysByIdentifier, identifier);

Sources/BXPGEFMetadataContainer.m

 	return [BXPGDatabaseDescription class];
 }
 
+
 - (Class) tableDescriptionClass
 {
 	return [BXPGTableDescription class];
 }
 
-- (void) fetchSchemaVersion: (PGTSConnection *) connection
+
+- (void) fetchSchemaVersion: (PGTSConnection *) connection loadState: (PGTSMetadataContainerLoadState *) loadState
 {
 	NSString* query =
 	@"SELECT baseten.version () AS version "
 	[mDatabase setSchemaCompatibilityVersion: [res valueForKey: @"version"]];	
 }
 
-- (void) fetchPreparedRelations: (PGTSConnection *) connection
+
+- (void) fetchPreparedRelations: (PGTSConnection *) connection loadState: (PGTSMetadataContainerLoadState *) loadState
 {
-	NSString* query = @"SELECT nspname, relname FROM baseten.relation WHERE enabled = true";
+	NSString* query = @"SELECT oid FROM baseten.relation_oids WHERE enabled = true";
 	PGTSResultSet* res = [connection executeQuery: query];
 	ExpectV ([res querySucceeded]);
 	
 	while ([res advanceRow])
 	{
-		NSString* nspname = [res valueForKey: @"nspname"];
-		NSString* relname = [res valueForKey: @"relname"];
-		id table = [mDatabase table: relname inSchema: nspname];
+		Oid oid = [[res valueForKey: @"oid"] PGTSOidValue];
+		id table = [loadState tableWithOid: oid];
 		[table setEnabled: YES];
 	}	
 }
 
-- (void) fetchViewPrimaryKeys: (PGTSConnection *) connection
+
+- (void) fetchViewPrimaryKeys: (PGTSConnection *) connection loadState: (PGTSMetadataContainerLoadState *) loadState
 {
-	NSString* query =
-	@"SELECT nspname, relname, baseten.array_accum (attname) AS attnames "
-	@" FROM baseten.view_pkey "
-	@" GROUP BY nspname, relname";
+	NSString* query = @"SELECT oid, attnames FROM baseten.view_pkey_oids";
 	PGTSResultSet* res = [connection executeQuery: query];
 	ExpectV ([res querySucceeded]);
 	
-	while ([res advanceRow])
 	{
-		NSString* nspname = [res valueForKey: @"nspname"];
-		NSString* relname = [res valueForKey: @"relname"];
-		PGTSTableDescription* view = [mDatabase table: relname inSchema: nspname];
-		PGTSIndexDescription* index = [[[PGTSIndexDescription alloc] init] autorelease];
-		
-		NSDictionary* columns = [view columns];
-		NSMutableSet* indexFields = [NSMutableSet set];
-		BXEnumerate (currentCol, e, [[res valueForKey: @"attnames"] objectEnumerator])
-			[indexFields addObject: [columns objectForKey: currentCol]];
-		
-		[index setPrimaryKey: YES];
-		[index setColumns: indexFields];
-		[view addIndex: index];
+		while ([res advanceRow])
+		{
+			Oid oid = [[res valueForKey: @"oid"] PGTSOidValue];
+			PGTSTableDescription *view = [loadState tableWithOid: oid];
+			PGTSIndexDescription *index = [loadState addIndexForRelation: oid];
+			ExpectV (view);
+			ExpectV (index);
+			
+			NSDictionary* columns = [view columns];
+			NSMutableSet* indexFields = [NSMutableSet set];
+			BXEnumerate (currentCol, e, [[res valueForKey: @"attnames"] objectEnumerator])
+				[indexFields addObject: [columns objectForKey: currentCol]];
+			
+			[index setPrimaryKey: YES];
+			[index setColumns: indexFields];
+		}
 	}
 }
 
-- (void) fetchForeignKeys: (PGTSConnection *) connection
+
+- (void) fetchForeignKeys: (PGTSConnection *) connection loadState: (PGTSMetadataContainerLoadState *) loadState
 {
 	NSString* query = 
 	@"SELECT conid, conname, conkey, confkey, confdeltype "
 	PGTSResultSet* res = [connection executeQuery: query];
 	ExpectV ([res querySucceeded]);
 	
+	NSMutableArray *foreignKeys = [NSMutableArray arrayWithCapacity: [res count]];
 	while ([res advanceRow])
 	{
 		BXPGForeignKeyDescription* fkey = [[[BXPGForeignKeyDescription alloc] init] autorelease];
 		
 		NSArray* srcfnames = [res valueForKey: @"conkey"];
 		NSArray* dstfnames = [res valueForKey: @"confkey"];
-		for (NSUInteger i = 0, count = [srcfnames count]; i < count; i++)
-			[fkey addSrcFieldName: [srcfnames objectAtIndex: i] dstFieldName: [dstfnames objectAtIndex: i]];
+		[fkey setSrcFieldNames: srcfnames dstFieldNames: dstfnames];
 		
 		NSDeleteRule deleteRule = NSDenyDeleteRule;
 		enum PGTSDeleteRule pgDeleteRule = PGTSDeleteRule ([[res valueForKey: @"confdeltype"] characterAtIndex: 0]);
 		}
 		[fkey setDeleteRule: deleteRule];
 		
-		[mDatabase addForeignKey: fkey];
+		[foreignKeys addObject: fkey];
 	}
+	[mDatabase setForeignKeys: foreignKeys];
 }
 
-- (void) fetchBXSpecific: (PGTSConnection *) connection
+
+- (void) fetchBXSpecific: (PGTSConnection *) connection loadState: (PGTSMetadataContainerLoadState *) loadState
 {
 	NSString* query = @"SELECT EXISTS (SELECT n.oid FROM pg_namespace n WHERE nspname = 'baseten') AS exists";
 	PGTSResultSet* res = [connection executeQuery: query];
 	
 	if (hasSchema)
 	{
-		[self fetchSchemaVersion: connection];
+		[self fetchSchemaVersion: connection loadState: loadState];
 		
 		NSNumber* currentCompatVersion = [BXPGVersion currentCompatibilityVersionNumber];
 		if ([currentCompatVersion isEqualToNumber: [mDatabase schemaCompatibilityVersion]])
 		{
-			[self fetchPreparedRelations: connection];
-			[self fetchViewPrimaryKeys: connection];
-			[self fetchForeignKeys: connection];
+			[mDatabase setHasCompatibleBaseTenSchemaVersion: YES];
+			[self fetchPreparedRelations: connection loadState: loadState];
+			[self fetchViewPrimaryKeys: connection loadState: loadState];
+			[self fetchForeignKeys: connection loadState: loadState];
 		}
 		else
 		{
 	}
 }
 
-- (void) loadUsing: (PGTSConnection *) connection
+
+- (void) loadUsing: (PGTSConnection *) connection loadState: (PGTSMetadataContainerLoadState *) loadState
 {
-	[super loadUsing: connection];
-	[self fetchBXSpecific: connection];
+	[super loadUsing: connection loadState: loadState];
+	[self fetchBXSpecific: connection loadState: loadState];
 }
 @end

Sources/BXPGForeignKeyDescription.h

 
 @interface BXPGForeignKeyDescription : PGTSAbstractDescription <BXForeignKey>
 {
+	NSArray *mFieldNames;
 	NSInteger mIdentifier;
-	BX_IdPairSet* mFieldNames;
-	pthread_rwlock_t mFieldNameLock;
 	NSDeleteRule mDeleteRule;
 }
 - (NSInteger) identifier;
 - (NSDeleteRule) deleteRule;
-- (void) addSrcFieldName: (NSString *) srcFName dstFieldName: (NSString *) dstFName;
 
 //Thread-unsafe methods
 - (void) setIdentifier: (NSInteger) identifier;
 - (void) setDeleteRule: (NSDeleteRule) aRule;
+- (void) setSrcFieldNames: (NSArray *) srcFields dstFieldNames: (NSArray *) dstFields;
 @end

Sources/BXPGForeignKeyDescription.mm

 
 #import "BXPGForeignKeyDescription.h"
 #import "BXLogger.h"
-#import "BXCollections.h"
 #import "BXCollectionFunctions.h"
-#import <iterator>
 
 
-using namespace BaseTen;
-using namespace BaseTen::CollectionFunctions;
+@interface BXPGForeignKeyDescriptionKeyPair : NSObject
+{
+	NSString *mSrcKey;
+	NSString *mDstKey;
+}
+- (NSString *) srcKey;
+- (NSString *) dstKey;
+- (void) setSrcKey: (NSString *) key;
+- (void) setDstKey: (NSString *) key;
+@end
 
 
-@implementation BXPGForeignKeyDescription
-- (id) init
-{
-	if ((self = [super init]))
-	{
-		mFieldNames = new IdPairSet ();
-		Expect (0 == pthread_rwlock_init (&mFieldNameLock, NULL));
-	}
-	return self;
-}
 
+@implementation BXPGForeignKeyDescriptionKeyPair
 - (void) dealloc
 {
-	delete mFieldNames;
-	pthread_rwlock_destroy (&mFieldNameLock);
+	[mSrcKey release];
+	[mDstKey release];
 	[super dealloc];
 }
 
-- (void) finalize
+
+- (NSString *) srcKey
 {
-	pthread_rwlock_destroy (&mFieldNameLock);
-	[super finalize];
+	return [[mSrcKey retain] autorelease];
 }
 
-- (void) addSrcFieldName: (NSString *) srcFName dstFieldName: (NSString *) dstFName
+
+- (NSString *) dstKey
 {
-	pthread_rwlock_wrlock (&mFieldNameLock);
-	mFieldNames->insert (IdPair (srcFName, dstFName));
-	pthread_rwlock_unlock (&mFieldNameLock);
+	return [[mDstKey retain] autorelease];
 }
 
+
+- (void) setSrcKey: (NSString *) srcKey
+{
+	if (mSrcKey != srcKey)
+	{
+		[mSrcKey release];
+		mSrcKey = [srcKey retain];
+	}
+}
+
+
+- (void) setDstKey: (NSString *) dstKey
+{
+	if (mDstKey != dstKey)
+	{
+		[mDstKey release];
+		mDstKey = [dstKey retain];
+	}
+}
+@end
+
+
+
+@implementation BXPGForeignKeyDescription
+- (void) dealloc
+{
+	[mFieldNames release];
+	[super dealloc];
+}
+
+
+- (void) setSrcFieldNames: (NSArray *) srcFields dstFieldNames: (NSArray *) dstFields
+{
+	NSUInteger count = [srcFields count];
+	ExpectV ([dstFields count] == count);
+	
+	NSMutableArray *keyPairs = [NSMutableArray arrayWithCapacity: count];
+	for (NSUInteger i = 0; i < count; i++)
+	{
+		BXPGForeignKeyDescriptionKeyPair *pair = [[BXPGForeignKeyDescriptionKeyPair alloc] init];
+		[pair setSrcKey: [srcFields objectAtIndex: i]];
+		[pair setDstKey: [dstFields objectAtIndex: i]];
+		[keyPairs addObject: pair];
+		[pair release];
+	}
+	
+	[mFieldNames release];
+	mFieldNames = [keyPairs copy];
+}
+
+
 - (NSDeleteRule) deleteRule
 {
 	return mDeleteRule;
 
 - (void) iterateColumnNames: (void (*)(NSString* srcName, NSString* dstName, void* context)) callback context: (void *) context
 {
-	pthread_rwlock_rdlock (&mFieldNameLock);
-	for (IdPairSet::const_iterator it = mFieldNames->begin (), end = mFieldNames->end ();
-		 it != end; it++)
-	{
-		callback (*it->first, *it->second, context);
-	}
-	pthread_rwlock_unlock (&mFieldNameLock);
+	for (BXPGForeignKeyDescriptionKeyPair *pair in mFieldNames)
+		callback ([pair srcKey], [pair dstKey], context);
 }
 
 - (void) iterateReversedColumnNames: (void (*)(NSString* dstName, NSString* srcName, void* context)) callback context: (void *) context
 {
-	pthread_rwlock_rdlock (&mFieldNameLock);
-	for (IdPairSet::const_iterator it = mFieldNames->begin (), end = mFieldNames->end ();
-		 it != end; it++)
-	{
-		callback (*it->second, *it->first, context);
-	}
-	pthread_rwlock_unlock (&mFieldNameLock);
+	for (BXPGForeignKeyDescriptionKeyPair *pair in mFieldNames)
+		callback ([pair dstKey], [pair srcKey], context);
 }
 
 - (NSUInteger) numberOfColumns
 {
-	NSUInteger retval = 0;
-	pthread_rwlock_rdlock (&mFieldNameLock);
-	retval = mFieldNames->size ();
-	pthread_rwlock_unlock (&mFieldNameLock);
-	return retval;
+	return [mFieldNames count];
 }
 @end

Sources/BXPGInterface.m

 #import "BXHOM.h"
 #import "PGTSDeleteRule.h"
 #import "PGTSConstants.h"
-#import "PGTSOids.h"
 #import "PGTSMetadataStorage.h"
 #import "BXArrayFunctions.h"
 
 #import "BXPGFromItem.h"
 #import "BXPGEFMetadataContainer.h"
 #import "BXPGForeignKeyDescription.h"
+#import "PGTSOids.h"
 
 #import "BXLocalizedString.h"
 #import "BXLogger.h"
 	NSMutableDictionary* currentRelationships = [NSMutableDictionary dictionary];
 	
 	BXPGDatabaseDescription* database = [mTransactionHandler databaseDescription];
-	NSNumber* currentCompatVersion = [BXPGVersion currentCompatibilityVersionNumber];
-	BOOL haveBaseTenSchema = ([currentCompatVersion isEqualToNumber: [database schemaCompatibilityVersion]]);
+	BOOL haveBaseTenSchema = [database hasCompatibleBaseTenSchemaVersion];
 	
 	BXEnumerate (entity, e, [entities objectEnumerator])
 	{

Sources/BXPGLockHandler.mm

 #import "BXDatabaseObjectIDPrivate.h"
 #import "BXLogger.h"
 #import "PGTSAdditions.h"
-#import "BXScannedMemoryAllocator.h"
-#import "BXScannedMemoryObject.h"
-#import "PGTSOids.h"
-#import <tr1/unordered_map>
 
 
-struct lock_st : public BaseTen::ScannedMemoryObject {
-	__strong NSMutableArray *l_for_update;
-	__strong NSMutableArray *l_for_delete;
-};
 
-typedef std::tr1::unordered_map <long, lock_st, 
-	std::tr1::hash <long>, 
-	std::equal_to <long>, 
-	BaseTen::ScannedMemoryAllocator <std::pair <const long, lock_st> > > 
-	LockMap;
+@interface BXPGLockHandlerList : NSObject
+{
+	NSMutableArray *mForUpdate;
+	NSMutableArray *mForDelete;
+}
+- (void) addForUpdate: (BXDatabaseObjectID *) objectID;
+- (void) addForDelete: (BXDatabaseObjectID *) objectID;
+@end
+
+
+
+@implementation BXPGLockHandlerList
+- (void) dealloc
+{
+	[mForUpdate release];
+	[mForDelete release];
+	[super dealloc];
+}
+
+
+- (void) addForUpdate: (BXDatabaseObjectID *) objectID
+{
+	if (! mForUpdate)
+		mForUpdate = [[NSMutableArray alloc] init];
+	
+	[mForUpdate addObject: objectID];
+}
+
+
+- (void) addForDelete: (BXDatabaseObjectID *) objectID
+{
+	if (! mForDelete)
+		mForDelete = [[NSMutableArray alloc] init];
+
+	[mForDelete addObject: objectID];
+}
+
+
+- (NSArray *) forUpdate
+{
+	return [[mForUpdate copy] autorelease];
+}
+
+
+- (NSArray *) forDelete
+{
+	return [[mForDelete copy] autorelease];
+}
+@end
+
 
 
 @implementation BXPGLockHandler
 			[self setLastCheck: [res valueForKey: @"baseten_lock_timestamp"]];
 		
 		//Sort the locks by relation.
-		LockMap locks ([res count]);
+		NSMutableDictionary *locksByRelation = [NSMutableDictionary dictionary];
 		while ([res advanceRow])
 		{
 			NSDictionary* row = [res currentRowAsDictionary];
 			unichar lockType = [[row valueForKey: @"baseten_lock_query_type"] characterAtIndex: 0];
-			long relid = [[row valueForKey: @"baseten_lock_relid"] longValue];
+			NSNumber *relid = [row valueForKey: @"baseten_lock_relid"];
 			
-			struct lock_st ls = locks [relid];
-			
-			NSMutableArray* ids = nil;
+			BXPGLockHandlerList *list = [locksByRelation objectForKey: relid];
+			if (! list)
+			{
+				list = [[BXPGLockHandlerList alloc] init];
+				[locksByRelation setObject: list forKey: relid];
+				[list release];
+			}
+						
+			BXDatabaseObjectID* objectID = [BXDatabaseObjectID IDWithEntity: mEntity primaryKeyFields: row];
 			switch (lockType) 
 			{
 				case 'U':
-					ids = ls.l_for_update;
+					[list addForUpdate: objectID];
 					break;
+					
 				case 'D':
-					ids = ls.l_for_delete;
+					[list addForDelete: objectID];
 					break;
 			}
-			
-			if (! ids)
-			{
-				ids = [NSMutableArray arrayWithCapacity: [res count]];
-				switch (lockType) 
-				{
-					case 'U':
-						ls.l_for_update = ids;
-						break;
-					case 'D':
-						ls.l_for_delete = ids;
-						break;
-				}
-			}
-			
-			BXDatabaseObjectID* objectID = [BXDatabaseObjectID IDWithEntity: mEntity primaryKeyFields: row];
-			[ids addObject: objectID];
 		}
 		
 		//Send changes.
-		LockMap::const_iterator iterator = locks.begin ();
 		BXDatabaseContext* ctx = [mInterface databaseContext];
-		while (locks.end () != iterator)
+		for (BXPGLockHandlerList *list in locksByRelation)
 		{
-			lock_st ls = iterator->second;
-			if (ls.l_for_update) [ctx lockedObjectsInDatabase: ls.l_for_update status: kBXObjectLockedStatus];
-			if (ls.l_for_delete) [ctx lockedObjectsInDatabase: ls.l_for_delete status: kBXObjectDeletedStatus];
+			NSArray *forUpdate = [list forUpdate];
+			NSArray *forDelete = [list forDelete];
+			
+			if ([forUpdate count])
+				[ctx lockedObjectsInDatabase: forUpdate status: kBXObjectLockedStatus];
+			
+			if ([forDelete count])
+				[ctx lockedObjectsInDatabase: forDelete status: kBXObjectDeletedStatus];
 		}
 	}
 }

Sources/BXPGModificationHandler.mm

 #import "BXPGModificationHandler.h"
 #import "BXEntityDescriptionPrivate.h"
 #import "BXDatabaseObjectIDPrivate.h"
-#import "BXScannedMemoryAllocator.h"
 #import "BXHOM.h"
 #import "BXEnumerate.h"
-#import <tr1/unordered_map>
+#import "BXCollectionFunctions.h"
 
-typedef std::tr1::unordered_map <unichar, NSMutableArray*,
-	std::tr1::hash <unichar>,
-	std::equal_to <unichar>,
-	BaseTen::ScannedMemoryAllocator <std::pair <
-		const unichar, BaseTen::ObjCPtr <NSMutableArray *>
-	> > 
-> ChangeMap;
+
+using namespace BaseTen;
+
 
 
 @interface PGTSColumnDescription (BXPGModificationHandlerAdditions)
 @end
 
 
+
 @implementation PGTSColumnDescription (BXPGModificationHandlerAdditions)
 - (NSString *) columnDefinition
 {
 @end
 
 
+
 @implementation BXPGModificationHandler
 - (void) dealloc
 {
 		[self setLastCheck: [res valueForKey: @"baseten_modification_timestamp"]];
 	
 	//Sort the changes by type.
-	ChangeMap changes = ChangeMap (3);
+	NSMutableDictionary *changes = [NSMutableDictionary dictionaryWithCapacity: 4];
 	NSMutableArray *changedAttrs = [NSMutableArray arrayWithCapacity: [res count]];
 	[res goBeforeFirstRow];
     while ([res advanceRow])
     {
 		unichar modificationType = [[res valueForKey: @"baseten_modification_type"] characterAtIndex: 0];                            
-		NSMutableArray *objectIDs = changes [modificationType];
+		NSMutableArray *objectIDs = FindObject (changes, modificationType);
 		if (! objectIDs)
 		{
 			objectIDs = [NSMutableArray arrayWithCapacity: [res count]];
-			changes [modificationType] = objectIDs;
+			Insert (changes, modificationType, objectIDs);
 		}
 		
 		BXDatabaseObjectID* objectID = [BXDatabaseObjectID IDWithEntity: mEntity primaryKeyFields: [res currentRowAsDictionary]];
 	}
 	
 	//Send changes.
-	ChangeMap::const_iterator iterator = changes.begin ();
-    while (changes.end () != iterator)
+	for (NSValue *key in [changes keyEnumerator])
     {
-		unichar type = iterator->first;
-		NSArray* objectIDs = iterator->second;
-		switch (type)
+		unichar changeType = '\0';
+		[key getValue: &changeType];		
+		NSArray* objectIDs = [changes objectForKey: key];
+		
+		switch (changeType)
 		{
 			case 'I':
 				[[mInterface databaseContext] addedObjectsToDatabase: objectIDs];
 			default:
 				break;
 		}
-        iterator++;
     }	
 }
 

Sources/BXPGTransactionHandler.m

 #import "PGTS.h"
 #import "PGTSAdditions.h"
 #import "BXHOM.h"
-#import "PGTSOids.h"
 
 #import "BXInterface.h"
 #import "BXLogger.h"
 #import "BXPGInterface.h"
 #import "BXPGCertificateVerificationDelegate.h"
 #import "BXLocalizedString.h"
+#import "PGTSOids.h"
 
 #import "BXEntityDescriptionPrivate.h"
 

Sources/BXRunLoopSocketDesciptor.m

 - (void) _dispatchLockCallout: (id) userInfo
 {
 	ExpectL ([NSThread currentThread] == mThread);
-	[mDelegate socketLocked: CFSocketGetNative (mSocket) userInfo: userInfo];
+	[[self delegate] socketDescriptor: self lockedSocket: CFSocketGetNative (mSocket) userInfo: userInfo];
 }
 
 

Sources/BXScannedMemoryAllocator.h

-//
-// BXScannedMemoryAllocator.h
-// BaseTen
-//
-// Copyright (C) 2008-2010 Marko Karppinen & Co. LLC.
-//
-// Before using this software, please review the available licensing options
-// by visiting http://www.karppinen.fi/baseten/licensing/ or by contacting
-// us at sales@karppinen.fi. Without an additional license, this software
-// may be distributed only in compliance with the GNU General Public License.
-//
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License, version 2.0,
-// as published by the Free Software Foundation.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-//
-// $Id$
-//
-
-
-#import <Foundation/Foundation.h>
-#import <objc/objc-auto.h>
-#import <new>
-#import <limits>
-
-
-namespace BaseTen {
-	class ScannedMemoryAllocatorBase {
-	public:
-		static BOOL collection_enabled;
-		static void *allocate (size_t);
-		static void deallocate (void *);
-	};	
-	
-	
-	template <typename T> 
-	class ScannedMemoryAllocator : private ScannedMemoryAllocatorBase {
-		
-	public:		
-		typedef T                 value_type;
-		typedef value_type*       pointer;
-		typedef const value_type* const_pointer;
-		typedef value_type&       reference;
-		typedef const value_type& const_reference;
-		typedef std::size_t       size_type;
-		typedef std::ptrdiff_t    difference_type;
-		
-		template <typename U> struct rebind { typedef ScannedMemoryAllocator <U> other; };
-		
-		explicit ScannedMemoryAllocator () {}
-		ScannedMemoryAllocator (const ScannedMemoryAllocator&) {}
-		
-		template <typename U> ScannedMemoryAllocator (const ScannedMemoryAllocator <U> &) {}
-		~ScannedMemoryAllocator () {}
-		
-		pointer address (reference x) const { return &x; }
-		const_pointer address (const_reference x) const { return x; }
-		
-		pointer allocate (size_type n, const_pointer = 0) 
-		{
-			return static_cast <pointer> (ScannedMemoryAllocatorBase::allocate (n * sizeof (T)));
-		}
-		
-		void deallocate (pointer p, size_type n) 
-		{
-			ScannedMemoryAllocatorBase::deallocate (p);
-		}
-		
-		size_type max_size () const 
-		{
-			return std::numeric_limits <size_type>::max () / sizeof (T);
-		}
-		
-		void construct (pointer p, const value_type& x) 
-		{ 
-			new (p) value_type (x); 
-		}
-		
-		void destroy (pointer p) 
-		{ 
-			p->~value_type (); 
-		}
-		
-	private:
-		void operator= (const ScannedMemoryAllocator&);
-	};
-	
-	
-	template <> class ScannedMemoryAllocator <void>
-	{
-	public:
-		typedef void			value_type;
-		typedef void*			pointer;
-		typedef const void*		const_pointer;
-		typedef std::size_t		size_type;
-		typedef std::ptrdiff_t	difference_type;
-		
-		template <typename U> 
-		struct rebind { typedef ScannedMemoryAllocator <U> other; };
-		
-		void *allocate (size_type n, const_pointer = 0)
-		{
-			return ScannedMemoryAllocatorBase::allocate (n);
-		}
-		
-		void deallocate (pointer p, size_type = 0)
-		{
-			ScannedMemoryAllocatorBase::deallocate (p);
-		}		
-	};
-	
-	
-	template <typename T> inline bool 
-	operator== (const ScannedMemoryAllocator <T> &, const ScannedMemoryAllocator <T> &)
-	{
-		return true;
-	}
-	
-	
-	template <typename T> inline bool 
-	operator!= (const ScannedMemoryAllocator <T> &, const ScannedMemoryAllocator <T> &) 
-	{
-		return false;
-	}
-}

Sources/BXScannedMemoryAllocator.mm

-//
-// BXScannedMemoryAllocator.mm
-// BaseTen
-//
-// Copyright (C) 2008-2010 Marko Karppinen & Co. LLC.
-//
-// Before using this software, please review the available licensing options
-// by visiting http://www.karppinen.fi/baseten/licensing/ or by contacting
-// us at sales@karppinen.fi. Without an additional license, this software
-// may be distributed only in compliance with the GNU General Public License.
-//
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License, version 2.0,
-// as published by the Free Software Foundation.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-//
-// $Id$
-//
-
-#import "BXScannedMemoryAllocator.h"
-
-
-static BOOL 
-IsCollectionEnabled ()