// In dbmanager/factory.go
package dbmanager

import (
	"fmt"

	"git.linuxforward.com/byop/byop-engine/models"
)

// DbManagerFactory creates type-safe database managers
type DbManagerFactory struct {
	dbType string
	// Add configuration params as needed
}

// NewDbManagerFactory creates a new factory
func NewDbManagerFactory(dbType string) *DbManagerFactory {
	return &DbManagerFactory{
		dbType: dbType,
	}
}

// CreateEntityManager creates a DbManager for the generic Entity interface
func (f *DbManagerFactory) CreateEntityManager() (DbManager[Entity], error) {
	switch f.dbType {
	case "memory":
		return NewMemoryDbManager[Entity](), nil
	case "sql":
		return nil, fmt.Errorf("SQL database type is not implemented yet")
	default:
		return nil, fmt.Errorf("unsupported database type: %s", f.dbType)
	}
}

// CreateClientManager creates a DbManager specifically for Client entities
func (f *DbManagerFactory) CreateClientManager() (DbManager[*models.Client], error) {
	switch f.dbType {
	case "memory":
		return NewMemoryDbManager[*models.Client](), nil
	case "sql":
		return nil, fmt.Errorf("SQL database type is not implemented yet")
	default:
		return nil, fmt.Errorf("unsupported database type: %s", f.dbType)
	}
}
