/*
**  AttributesSource.h
**
**  Copyright (c) 2004
**
**  Author: Yen-Ju Chen <yjchenx@hotmail.com>
**
**  This program is free software; you can redistribute it and/or modify
**  it under the terms of the GNU General Public License as published by
**  the Free Software Foundation; either version 2 of the License, or
**  (at your option) any later version.
**
**  This program 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 General Public License for more details.
**
**  You should have received a copy of the GNU General Public License
**  along with this program; if not, write to the Free Software
**  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

#ifndef __AttributesSource__
#define __AttributesSource__

#include "GeneralContainer.h"

@class NSSet;

/* Attributes */
  /* Attributes are dictionary.
   * Each key is in the form of "/order/category/name(unit)/type".
   * order is the number of the order of attribute.
   * category is category, name is name under this category.
   * unit is not necessary.
   * type is the type of value (see AttributeTypeKey)
   * use path methods of NSString to handle the name.
   * Attributes will be display based on category.
   */
/* attribute type */
static NSString *AttributeStringType = @"AttributeStringType"; // NSString
static NSString *AttributeFloatType = @"AttributeFloatType"; // NSNumber
static NSString *AttributeIntegerType = @"AttributeIntegerType"; // NSNumberstatic 
static NSString *AttributeCalendarDateType = @"AttributeCalendarDateType"; // NSString

/* Attributes use the path of item as title */

@interface AttributesSource: GeneralContainer
+ (AttributesSource *) sharedSource;

/* write accessory */
- (void) setAttributes: (NSDictionary *) attr atIndex: (unsigned int) index;
  /* key is in the form of "/xxx/yyy/type" */
- (void) setAttribute: (id) attr atIndex: (unsigned int) index 
                                  forKey: (id) key;
- (void) removeAttributeAtIndex: (unsigned int) index forKey: (id) key;

/* read accessory */
- (NSDictionary *) attributesAtIndex: (unsigned int) index;
  /* key is in the form of "/xxx/yyy/type" */
- (id) attributeAtIndex: (unsigned int) index forKey: (NSString *) key;
- (id) attributeAtIndex: (unsigned int) index forName: (NSString *) name;
- (NSSet *) namesOfAttributes;
- (NSSet *) keysOfAttributes;

@end

#endif /* __AttributesSource __ */
