|
| 1 | +// Copyright (c) 2021 Terminus, Inc. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +package cptype |
| 16 | + |
| 17 | +// IDefaultComponent std component's default impl should implement this interface. |
| 18 | +type IDefaultComponent interface { |
| 19 | + CompStdStructuredPtrCreator |
| 20 | + CompStdOperationRegister |
| 21 | + CompFrameworkSteper |
| 22 | + CompEncoder |
| 23 | + CompDecoder |
| 24 | +} |
| 25 | + |
| 26 | +// CompStdStructuredPtrCreator return creator of StdStructuredPtr. |
| 27 | +type CompStdStructuredPtrCreator interface { |
| 28 | + StdStructuredPtrCreator() func() IStdStructuredPtr |
| 29 | +} |
| 30 | + |
| 31 | +// IStdStructuredPtr represents std structured pointer type. |
| 32 | +type IStdStructuredPtr interface { |
| 33 | + DataPtr() interface{} |
| 34 | + StatePtr() interface{} |
| 35 | + InParamsPtr() interface{} |
| 36 | +} |
| 37 | + |
| 38 | +// CompStdOperationRegister register a component's all custom operations to standard cptype.OperationFunc, |
| 39 | +// and then used by framework. |
| 40 | +type CompStdOperationRegister interface { |
| 41 | + RegisterCompStdOps() (opFuncs map[OperationKey]OperationFunc) |
| 42 | +} |
| 43 | + |
| 44 | +// CompFrameworkSteper represents all component steps played in framework. |
| 45 | +type CompFrameworkSteper interface { |
| 46 | + Initialize(sdk *SDK) |
| 47 | + Finalize(sdk *SDK) |
| 48 | + SkipOp(sdk *SDK) bool |
| 49 | + Visible(sdk *SDK) bool |
| 50 | + BeforeHandleOp(sdk *SDK) |
| 51 | + AfterHandleOp(sdk *SDK) |
| 52 | +} |
| 53 | + |
| 54 | +// CompEncoder is a protocol-level interface, convert structured-struct to raw-cp-result. |
| 55 | +// encode std-struct-ptr to raw-ptr. |
| 56 | +type CompEncoder interface { |
| 57 | + EncodeData(srcStdStructPtr interface{}, dstRawPtr *ComponentData) |
| 58 | + EncodeState(srcStdStructPtr interface{}, dstRawPtr *ComponentState) |
| 59 | + EncodeInParams(srcStdStructPtr interface{}, dstRawPtr *InParams) |
| 60 | +} |
| 61 | + |
| 62 | +// CompDecoder is a protocol-level interface, convert raw-cp-result to structured-struct. |
| 63 | +// decode raw-ptr to std-struct-ptr. |
| 64 | +type CompDecoder interface { |
| 65 | + DecodeData(srcRawPtr ComponentData, dstStdStructPtr interface{}) |
| 66 | + DecodeState(srcRawPtr ComponentState, dstStdStructPtr interface{}) |
| 67 | + DecodeInParams(srcRawPtr InParams, dstStdStructPtr interface{}) |
| 68 | +} |
0 commit comments