//
//  FBClusterHandler.h
//  Client
//
//  Created by Peter Haff on Tue Jun 29 2004.
//  Copyright (c) 2004 FrontBase, Inc. All rights reserved.
//

#import <Foundation/NSString.h>
#import <Foundation/NSArray.h>
#import "FBClusterMember.h"

@interface FBClusterHandler : NSObject {

   // Default database (retained NSString, and the contained cString)
   NSString* dbId;
   NSString* hostId;
   NSString* dbPW;
   NSString* sysPW;
   NSString* execPW;

   // Get the contained cString
   #define dbIdC   (char*)[dbId UTF8String]
   #define hostIdC (char*)[hostId UTF8String]
   #define dbPWC   (char*)[dbPW UTF8String]
   #define sysPWC  (char*)[sysPW UTF8String ]
   #define execPWC (char*)[execPW UTF8String]

   // Dynamic properties (results of operations)
   NSArray* memberList;
   NSArray* messages;
}

+ (FBClusterHandler*) initWithDatabase : (NSString*) aDbId
                                hostId : (NSString*) aHostId
                                dbPW   : (NSString*) aDbPW
                                sysPW  : (NSString*) aSysPW
                                execPW : (NSString*) aExecPW;

+ (FBClusterHandler*) createClusterWithHost : (NSString*) aDbId
                                     hostId : (NSString*) aHostId
                                     dbPW   : (NSString*) aDbPW
                                     sysPW  : (NSString*) aSysPW
                                     execPW : (NSString*) aExecPW;

- (unsigned) numberOfMembers;
- (NSArray*) memberList;
- (NSArray*) messages;
+ (NSString*) messageCombined;
- (NSString*) messageCombined;

- (NSArray*) refresh;
- (NSArray*) synchronizeCluster;
- (NSArray*) startCluster;
- (NSArray*) stopCluster;

- (NSArray*) addMemberWithHost   :(NSString*)aHostName databaseName:(NSString*)aDatabaseName;
- (NSArray*) removeMemberWithHost:(NSString*)aHostName databaseName:(NSString*)aDatabaseName;
- (NSArray*) addMember   :(FBClusterMember*)aMember;
- (NSArray*) removeMember:(FBClusterMember*)aMember;

- (FBClusterMember*) startMemberWithHost:(NSString*)aHostName databaseName:(NSString*)aDatabaseName;
- (FBClusterMember*) stopMemberWithHost:(NSString*)aHostName databaseName:(NSString*)aDatabaseName;
- (FBClusterMember*) setMemberMajorityWithHost:(NSString*)aHostName databaseName:(NSString*)aDatabaseName majority:(BOOL)aFlag;
- (FBClusterMember*) setMemberReadonlyWithHost:(NSString*)aHostName databaseName:(NSString*)aDatabaseName readonly:(BOOL)aFlag;
- (FBClusterMember*) startMember:(FBClusterMember*)aMember;
- (FBClusterMember*) stopMember :(FBClusterMember*)aMember;
- (FBClusterMember*) setMemberMajority:(FBClusterMember*)aMember majority:(BOOL)aFlag;
- (FBClusterMember*) setMemberReadonly:(FBClusterMember*)aMember readonly:(BOOL)aFlag;

@end
