/*
  Copyright (C) 2000-2003 SKYRIX Software AG

  This file is part of OGo

  OGo is free software; you can redistribute it and/or modify it under
  the terms of the GNU Lesser General Public License as published by the
  Free Software Foundation; either version 2, or (at your option) any
  later version.

  OGo 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 Lesser General Public
  License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with OGo; see the file COPYING.  If not, write to the
  Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
  02111-1307, USA.
*/
// $Id$

#include <EOControl/EODataSource.h>
#include <EOControl/EOClassDescription.h>
#include "common.h"

@implementation EODataSource

+ (int)version {
  return 1;
}

/* reflection */

- (EOClassDescription *)classDescriptionForObjects {
  return nil;
}

/* master-detail */

- (EODataSource *)dataSourceQualifiedByKey:(NSString *)_relKey {
  [NSException raise:@"NSInvalidArgumentException"
               format:@"datasource %@ can't return a ds qualified by key '%@'",
                 self, _relKey];
  return nil;
}

- (void)qualifyWithRelationshipKey:(NSString *)_relKey ofObject:(id)_object {
  [NSException raise:@"NSInvalidArgumentException"
               format:@"datasource %@ can't qualify by key '%@' of object %@",
                 self, _relKey, _object];
}

/* operations */

- (NSArray *)fetchObjects {
  return nil;
}
- (NSEnumerator *)fetchEnumerator {
  return [[self fetchObjects] objectEnumerator];
}

- (void)deleteObject:(id)_object {
  [NSException raise:@"NSInvalidArgumentException"
               format:@"datasource %@ can't delete object %@",
                 self, _object];
}

- (void)insertObject:(id)_object {
  [NSException raise:@"NSInvalidArgumentException"
               format:@"datasource %@ can't insert object %@",
                 self, _object];
}

- (id)createObject {
  EOClassDescription *cd;
  
  if ((cd = [self classDescriptionForObjects]) == nil)
    return nil;
  
  return [cd createInstanceWithEditingContext:nil globalID:nil zone:NULL];
}

@end /* EODataSource */
