| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 | /* * EliasDB * * Copyright 2016 Matthias Ladkau. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */package graphstorageimport "devt.de/krotik/eliasdb/storage"/*MgsRetClose is the return value on successful close*/var MgsRetClose error/*MgsRetFlushAll is the return value on successful flush all*/var MgsRetFlushAll error/*MgsRetFlushMain is the return value on successful flush*/var MgsRetFlushMain error/*MgsRetRollbackMain is the return value on successful rollback*/var MgsRetRollbackMain error/*MemoryGraphStorage data structure*/type MemoryGraphStorage struct {	name            string                     // Name of the graph storage	mainDB          map[string]string          // Database storing names	storagemanagers map[string]storage.Manager // Map of StorageManagers}/*NewMemoryGraphStorage creates a new MemoryGraphStorage instance.*/func NewMemoryGraphStorage(name string) Storage {	return &MemoryGraphStorage{name, make(map[string]string),		make(map[string]storage.Manager)}}/*Name returns the name of the MemoryGraphStorage instance.*/func (mgs *MemoryGraphStorage) Name() string {	return mgs.name}/*MainDB returns the main database.*/func (mgs *MemoryGraphStorage) MainDB() map[string]string {	return mgs.mainDB}/*RollbackMain rollback th/e main database.*/func (mgs *MemoryGraphStorage) RollbackMain() error {	return MgsRetRollbackMain}/*FlushMain writes the main database to the storage.*/func (mgs *MemoryGraphStorage) FlushMain() error {	return MgsRetFlushMain}/*StorageManager gets a storage manager with a certain name. A non-existingStorageManager is created automatically if the create flag is set to true.*/func (mgs *MemoryGraphStorage) StorageManager(smname string, create bool) storage.Manager {	sm, ok := mgs.storagemanagers[smname]	if !ok && create {		sm = storage.NewMemoryStorageManager(mgs.name + "/" + smname)		mgs.storagemanagers[smname] = sm	}	return sm}/*FlushAll writes all pending changes to the storage.*/func (mgs *MemoryGraphStorage) FlushAll() error {	return MgsRetFlushAll}/*Close closes the storage.*/func (mgs *MemoryGraphStorage) Close() error {	return MgsRetClose}
 |