home *** CD-ROM | disk | FTP | other *** search
/ OpenStep (Enterprise) / OpenStepENTCD.toast / OEDEV / DEV.Z / DBController.m < prev    next >
Encoding:
Text File  |  1995-11-03  |  1.8 KB  |  66 lines

  1. /* DBController.m
  2.  * A utility class used to communicate with EOF.
  3.  * 
  4.  * You may freely copy, distribute, and reuse the code in this example.
  5.  * NeXT disclaims any warranty of any kind, expressed or  implied, as to its
  6.  * fitness for any particular use.
  7.  *
  8.  * Written by Paul Marcos, NeXT Software Engineer
  9.  */
  10.  
  11. #import "dbcontroller.h"
  12. #import <EOAccess/EOAccess.h>
  13.  
  14. // When the DLL is loaded, this function will be called. We
  15. // simply return an instance of DBController which is nothing more
  16. // than a utility class.
  17. id NSGetDllObject (NSString *obj)
  18. {
  19.     return [[DBController alloc] init];
  20. }
  21.  
  22. // DBController only has two methods.  The first exposes the 
  23. // EODatabaseDataSource class since classes aren't directly
  24. // accessible from OLE.  The second simply passes arguments
  25. // through to a varargs Objective C method.  This is needed 
  26. // since there is no varargs support in OLE.
  27. @implementation DBController
  28. - init
  29. {
  30.     [super init];
  31.     return [self autorelease];
  32. }
  33.  
  34. - eoDatabaseDataSource
  35. {
  36.     return [EODatabaseDataSource class];
  37. }
  38.  
  39. - (EOQualifier*)qualifierWithEntity: (EOEntity*)entity format: (NSString*)format arg1: (NSString*)arg1 arg2: (NSString*)arg2
  40. {
  41.     return [[EOQualifier alloc] initWithEntity: entity qualifierFormat: format, arg1, arg2];
  42. }
  43.  
  44. @end
  45.  
  46.  
  47. // This category of EOGenericRecord lets the EO attributes 
  48. // be treated as OLE Properties.  
  49. @interface EOGenericRecord (OLEProperty)
  50. @end
  51.  
  52.  
  53. @implementation EOGenericRecord (OLEProperty)
  54. - (NSValue*)getOLEPropertyNamed:(NSString*)str
  55. {
  56.     id value = [self objectForKey:str];
  57.     if (value)
  58.         return [NSValue value:&value withObjCType:@encode(id)];
  59.     else if ([str caseInsensitiveCompare:@"value"] == NSOrderedSame)
  60.         return [NSValue value:&self withObjCType:@encode(id)];
  61.     else
  62.         return nil;
  63. }
  64. @end
  65.  
  66.