GDL2: the GNUstep Database Library
Listing 1. AppController.h
#include <AppKit/AppKit.h>
@interface AppController : NSObject
{
id window;
id tableView;
id items;
id editingContext;
}
- (void) update: (id)sender;
- (void) delete: (id)sender;
- (void) insert: (id)sender;
@end
Listing 2. AppController.m
#include <AppKit/AppKit.h>
#include "AppController.h"
#import <EOAccess/EOAccess.h>
#import <EOControl/EOControl.h>
@implementation AppController
- (id) init
{
self = [super init];
items = [[NSMutableArray alloc] init];
return self;
}
- (void) dealloc
{
[editingContext release];
[items release];
[super dealloc];
}
- (void) update: (id)sender
{
[items removeAllObjects];
[items addObjectsFromArray:
[editingContext objectsForEntityNamed:
@"Item"]];
[tableView reloadData];
}
- (void) delete: (id)sender
{
int row;
row = [tableView selectedRow];
if (row < 0 || row >= [items count])
{
NSBeep();
return;
}
[editingContext deleteObject:
[items objectAtIndex: row]];
[editingContext saveChanges];
[items removeObjectAtIndex: row];
[tableView reloadData];
}
- (void) insert: (id)sender
{
id aRecord;
aRecord = [[EOClassDescription
classDescriptionForEntityName:
@"Item"]
createInstanceWithEditingContext: nil
globalID: nil
zone: NULL];
[aRecord takeValue: @"<new item>"
forKey: @"name"];
[aRecord takeValue: [NSNumber numberWithInt: 0]
forKey: @"quantity"];
[aRecord takeValue: [NSCalendarDate date]
forKey: @"order_date"];
[editingContext insertObject: aRecord];
[editingContext saveChanges];
[items addObject: aRecord];
[tableView reloadData];
}
- (int) numberOfRowsInTableView: (id) aTableView
{
return [items count];
}
- (id) tableView: (id) aTableView
objectValueForTableColumn: (id) aTableColumn
row: (int) rowIndex
{
id aRecord;
aRecord = [items objectAtIndex: rowIndex];
return [aRecord valueForKey:
[aTableColumn identifier]];
}
- (void) tableView: (id) aTableView
setObjectValue: (id) anObject
forTableColumn: (id) aTableColumn
row: (int) rowIndex
{
id aRecord;
aRecord = [items objectAtIndex: rowIndex];
[aRecord takeValue: anObject
forKey: [aTableColumn identifier]];
[editingContext saveChanges];
}
- (void) applicationDidFinishLaunching: (id) not
{
EODatabaseContext *aDatabaseContext;
EOModelGroup *aModelGroup;
EODatabase *aDatabase;
EOModel *aModel;
aModelGroup = [[EOModelGroup alloc] init];
aModel = [aModelGroup
addModelWithFile:
@"tool/Inventory.eomodeld"];
[EOModelGroup setDefaultGroup: aModelGroup];
[aModelGroup autorelease];
aDatabase = [[EODatabase alloc] initWithModel:
aModel];
[aDatabase autorelease];
[[aDatabase adaptor] runLoginPanel];
aDatabaseContext = [[EODatabaseContext alloc]
initWithDatabase: aDatabase];
[[EOObjectStoreCoordinator defaultCoordinator]
addCooperatingObjectStore: aDatabaseContext];
[aDatabaseContext autorelease];
editingContext = [[EOEditingContext alloc]
init];
}
@end
int main(int argc, const char *argv[], char *env[])
{
[NSApplication sharedApplication];
NSApplicationMain(argc, argv);
return EXIT_SUCCESS;
}
Once the AppController files are modified, proceed with the creation of the GNUmakefile, used to compile our application, and the InventoryInfo.plist file, used to specify the application name, description and the name of the main Gorm file to load upon startup. Listings 3 and 4 show the content of those files.
Listing 3. GNUmakefile
include $(GNUSTEP_MAKEFILES)/common.make
include $(GNUSTEP_MAKEFILES)/Auxiliary/gdl2.make
APP_NAME = Inventory
Inventory_OBJC_FILES = AppController.m
Inventory_RESOURCE_FILES = MainMenu.gorm
ADDITIONAL_OBJCFLAGS = -Wall -Wno-import
include $(GNUSTEP_MAKEFILES)/application.make
Listing 4. InventoryInfo.plist
{
ApplicationName = "Inventory";
ApplicationDescription = "Inventory application.";
NSMainNibFile = "MainMenu";
}
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
| Trying to Tame the Tablet | May 08, 2013 |
| Dart: a New Web Programming Experience | May 07, 2013 |
- RSS Feeds
- New Products
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Home, My Backup Data Center
- New Products
- Paranoid Penguin - Building a Secure Squid Web Proxy, Part IV
- Trying to Tame the Tablet
- Developer Poll
- Looking Good
1 hour 43 min ago - Hey God - You may not be
5 hours 56 min ago - Reply to comment | Linux Journal
8 hours 29 min ago - Drupal is an Awesome CMS and a Crappy development framework
13 hours 8 min ago - IT industry leaders
15 hours 30 min ago - Reply to comment | Linux Journal
1 day 8 hours ago - Reply to comment | Linux Journal
1 day 10 hours ago - Reply to comment | Linux Journal
1 day 12 hours ago - great post
1 day 12 hours ago - Google Docs
1 day 13 hours ago
Enter to Win an Adafruit Prototyping Pi Plate Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Prototyping Pi Plate Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- Next winner announced on 5-21-13!
Free Webinar: Linux Backup and Recovery
Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.
In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.



Comments
Re: GDL2: the GNUstep Database Library
Interesting article.
At this moment, this site at this link doesn't seem to exist:
And for the Python-inclined, there is a EOF-inspired Object-Relational database bridge called "Modeling" at: