Repository: realm/realm-swift
File: src/tightdb/objc/TDBContext.h (C/C++)

Code before:
/*************************************************************************
 *
 * TIGHTDB CONFIDENTIAL
 * __________________
 *
 *  [2011] - [2014] TightDB Inc
 *  All Rights Reserved.
 *
 * NOTICE:  All information contained herein is, and remains
 * the property of TightDB Incorporated and its suppliers,
 * if any.  The intellectual and technical concepts contained
 * herein are proprietary to TightDB Incorporated
 * and its suppliers and may be covered by U.S. and Foreign Patents,
 * patents in process, and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from TightDB Incorporated.
 *
 **************************************************************************/

#import <Foundation/Foundation.h>
#import <tightdb/objc/TDBTransaction.h>

typedef void(^TDBReadBlock)(TDBTransaction *transaction);
typedef BOOL(^TDBWriteBlock)(TDBTransaction *transaction);
typedef void(^TDBTableReadBlock)(TDBTable *table);
typedef BOOL(^TDBTableWriteBlock)(TDBTable *table);

/****************	  TDBContext	****************/

@interface TDBContext: NSObject

+(NSString *) defaultPath;

// Initializers
+(TDBContext *)contextPersistedAtDefaultPathWithError:(NSError **)error;
+(TDBContext *)contextPersistedAtPath:(NSString *)path error:(NSError **)error;

// Transactions
-(void)readUsingBlock:(TDBReadBlock)block;
-(BOOL)writeUsingBlock:(TDBWriteBlock)block error:(NSError **)error;

// Shortcuts for transactions on a single table
-(void)readTable:(NSString*)tablename usingBlock:(TDBTableReadBlock)block;
-(BOOL)writeTable:(NSString*)tablename usingBlock:(TDBTableWriteBlock)block error:(NSError **)error;

// Context state info
-(BOOL)hasChangedSinceLastTransaction;


@end


Review comment (bug):
but it should start with "context" according to other standards (even if MR doesn't follow that)?
I also think it should mention that it's persisted - as opposed to in memory only.
That makes "contextPersisted" - that just doesn't sound too good?
We could skip the error, and just return nil - then you won't know what happened. But likelyhood is high that nothing will actually go wrong. 


Code after:
/*************************************************************************
 *
 * TIGHTDB CONFIDENTIAL
 * __________________
 *
 *  [2011] - [2014] TightDB Inc
 *  All Rights Reserved.
 *
 * NOTICE:  All information contained herein is, and remains
 * the property of TightDB Incorporated and its suppliers,
 * if any.  The intellectual and technical concepts contained
 * herein are proprietary to TightDB Incorporated
 * and its suppliers and may be covered by U.S. and Foreign Patents,
 * patents in process, and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from TightDB Incorporated.
 *
 **************************************************************************/

#import <Foundation/Foundation.h>

#import "TDBTransaction.h"


typedef void(^TDBReadBlock)(TDBTransaction *transaction);
typedef BOOL(^TDBWriteBlock)(TDBTransaction *transaction);
typedef void(^TDBTableReadBlock)(TDBTable *table);
typedef BOOL(^TDBTableWriteBlock)(TDBTable *table);

/****************	  TDBContext	****************/

@interface TDBContext: NSObject

+(NSString *) defaultPath;

// Initializers
+(TDBContext *)contextWithDefaultPersistence;
+(TDBContext *)contextPersistedAtPath:(NSString *)path error:(NSError **)error;

// Transactions
-(void)readUsingBlock:(TDBReadBlock)block;
-(BOOL)writeUsingBlock:(TDBWriteBlock)block error:(NSError **)error;

// Shortcuts for transactions on a single table
-(void)readTable:(NSString*)tablename usingBlock:(TDBTableReadBlock)block;
-(BOOL)writeTable:(NSString*)tablename usingBlock:(TDBTableWriteBlock)block error:(NSError **)error;

// Context state info
-(BOOL)hasChangedSinceLastTransaction;


@end