//
//  Database.h
//  DrivoMeter
//
//  Created by Triin Uudam on 8/31/11.
//

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>

@interface Database : NSObject {
@private
  NSManagedObjectContext *managedObjectContext_;
  NSManagedObjectModel *managedObjectModel_;
  NSPersistentStoreCoordinator *persistentStoreCoordinator_;
  NSString *storeType_;
  NSURL *storeURL_;
}

- (id)initWithPersistentStoreCoordinator:(NSPersistentStoreCoordinator *)pCoordinator;
- (id)initWithStoreURL:(NSURL *)storeURL storeType:(NSString *)storeType_;

- (NSPersistentStoreCoordinator *)persistentStoreCoordinator;
- (void)saveContext;
- (NSManagedObjectContext *)managedObjectContext;
- (int)countCoreObjectsNamed:(NSString *)modelName;
- (int)countCoreObjectsNamed:(NSString *)modelName withPredicate:(NSPredicate *)predicate;
- (id)findCoreObjectNamed:(NSString *)modelName withPredicate:(NSPredicate *)predicate;
- (NSArray *)listCoreObjectsNamed:(NSString *)modelName;
- (NSArray *)listCoreObjectsNamed:(NSString *)modelName withPredicate:(NSPredicate *)predicate;
- (NSArray *)listCoreObjectsNamed:(NSString *)modelName withPredicate:(NSPredicate *)predicate usingSortDescriptors:(NSArray *)sortDescriptors;
- (void)deleteObject:(NSManagedObject *)object;
- (void)deleteObject:(NSManagedObject *)object saveAfter:(BOOL)saveAfter;
- (NSFetchedResultsController *)fetchedResultsControllerUsingFetchRequest:(NSFetchRequest *)request;
- (NSExpressionDescription *)descriptionWithPath:(NSString *)keyPath function:(NSString *)function resultName:(NSString *)name type:(NSAttributeType)type;

@end