blob: abf19d7303493028fd7df7f9a8666320117d7d9c [file] [log] [blame]
Constantin Ziesche857c7ab2020-02-25 11:24:51 +01001/*******************************************************************************
2* Copyright (c) 2020 Robert Bosch GmbH
3* Author: Constantin Ziesche (constantin.ziesche@bosch.com)
4*
5* This program and the accompanying materials are made available under the
6* terms of the Eclipse Public License 2.0 which is available at
7* http://www.eclipse.org/legal/epl-2.0
8*
9* SPDX-License-Identifier: EPL-2.0
10*******************************************************************************/
11using BaSyx.Models.Core.AssetAdministrationShell.Identification;
12using BaSyx.Models.Extensions;
13using BaSyx.Utils.ResultHandling;
14using Newtonsoft.Json;
15using System;
16using System.Collections.Generic;
Constantin Ziesche7b6d4792020-08-18 17:15:11 +020017using System.Linq;
Constantin Ziesche857c7ab2020-02-25 11:24:51 +010018
19namespace BaSyx.Models.Core.Common
20{
21 public interface IGenericElementContainer<TIdentifier, TElement> : IList<TElement>
22 {
23 TElement this[TIdentifier id] { get; }
24
25 IResult<TElement> Create(TElement element);
26
27 IResult<T> Create<T>(T element) where T : class, TElement;
28
29 IResult<TElement> Retrieve(TIdentifier id);
30
31 IResult<T> Retrieve<T>(TIdentifier id) where T : class, TElement;
32
Constantin Ziesche7b6d4792020-08-18 17:15:11 +020033 IResult<IQueryableElementContainer<T>> RetrieveAll<T>() where T : class, TElement;
Constantin Ziesche857c7ab2020-02-25 11:24:51 +010034
Constantin Ziesche7b6d4792020-08-18 17:15:11 +020035 IResult<IQueryableElementContainer<T>> RetrieveAll<T>(Predicate<T> predicate) where T : class, TElement;
36
37 IResult<TElement> CreateOrUpdate(TIdentifier id, TElement element);
Constantin Ziesche857c7ab2020-02-25 11:24:51 +010038
39 IResult<TElement> Update(TIdentifier id, TElement element);
40
41 IResult Delete(TIdentifier id);
42
43 void AddRange(IEnumerable<TElement> collection);
44 }
Constantin Ziesche7b6d4792020-08-18 17:15:11 +020045
46 public interface IQueryableElementContainer<TElement> : IElementContainer<TElement>, IQueryable<TElement>
47 {
48
49 }
50
Constantin Ziesche857c7ab2020-02-25 11:24:51 +010051 [JsonConverter(typeof(ElementContainerConverter))]
52 public interface IElementContainer<TElement> : IGenericElementContainer<string, TElement>
53 {
Constantin Ziesche7b6d4792020-08-18 17:15:11 +020054 IResult<IQueryableElementContainer<TElement>> RetrieveAll();
55 IResult<IQueryableElementContainer<TElement>> RetrieveAll(Predicate<TElement> predicate);
Constantin Ziesche857c7ab2020-02-25 11:24:51 +010056
57 IElementContainer<TOutput> ConvertAll<TOutput>(Converter<TElement, TOutput> converter) where TOutput : IReferable, IModelElement;
Constantin Ziesche857c7ab2020-02-25 11:24:51 +010058 IElementContainer<TModelElementType> Filter<TModelElementType>(ModelType modelType) where TModelElementType : IReferable, IModelElement, TElement;
59 IEnumerable<TModelElementType> FilterAsReference<TModelElementType>(ModelType modelType) where TModelElementType : IReferable, IModelElement, TElement;
60 }
61}