github.com/erda-project/erda-infra@v1.0.9/providers/component-protocol/components/complexgraph/impl/default.go (about)

     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 impl
    16  
    17  import (
    18  	"github.com/erda-project/erda-infra/providers/component-protocol/components/complexgraph"
    19  	"github.com/erda-project/erda-infra/providers/component-protocol/components/defaults"
    20  	"github.com/erda-project/erda-infra/providers/component-protocol/cptype"
    21  )
    22  
    23  // DefaultComplexGraph default complex graph component
    24  type DefaultComplexGraph struct {
    25  	defaults.DefaultImpl
    26  	Impl complexgraph.IComplexGraph
    27  	*StdStructuredPtr
    28  }
    29  
    30  // Initialize .
    31  func (d *DefaultComplexGraph) Initialize(sdk *cptype.SDK) {
    32  }
    33  
    34  // Visible .
    35  func (d *DefaultComplexGraph) Visible(sdk *cptype.SDK) bool {
    36  	return true
    37  }
    38  
    39  // StdStructuredPtr .
    40  type StdStructuredPtr struct {
    41  	StdInParamsPtr *cptype.ExtraMap
    42  	StdDataPtr     *complexgraph.Data
    43  	StdStatePtr    *cptype.ExtraMap
    44  }
    45  
    46  // DataPtr .
    47  func (s *StdStructuredPtr) DataPtr() interface{} { return s.StdDataPtr }
    48  
    49  // StatePtr .
    50  func (s *StdStructuredPtr) StatePtr() interface{} { return s.StdStatePtr }
    51  
    52  // InParamsPtr .
    53  func (s *StdStructuredPtr) InParamsPtr() interface{} { return s.StdInParamsPtr }
    54  
    55  // RegisterCompStdOps .
    56  func (d *DefaultComplexGraph) RegisterCompStdOps() (opFuncs map[cptype.OperationKey]cptype.OperationFunc) {
    57  	return map[cptype.OperationKey]cptype.OperationFunc{}
    58  }
    59  
    60  // RegisterCompNonStdOps .
    61  func (d *DefaultComplexGraph) RegisterCompNonStdOps() (opFuncs map[cptype.OperationKey]cptype.OperationFunc) {
    62  	return nil
    63  }
    64  
    65  // Finalize .
    66  func (d *DefaultComplexGraph) Finalize(sdk *cptype.SDK) {}
    67  
    68  // SkipOp providers default impl for user.
    69  func (d *DefaultComplexGraph) SkipOp(sdk *cptype.SDK) bool { return !d.Impl.Visible(sdk) }
    70  
    71  // BeforeHandleOp providers default impl for user.
    72  func (d *DefaultComplexGraph) BeforeHandleOp(sdk *cptype.SDK) {}
    73  
    74  // AfterHandleOp providers default impl for user.
    75  func (d *DefaultComplexGraph) AfterHandleOp(sdk *cptype.SDK) {}
    76  
    77  // StdStructuredPtrCreator .
    78  func (d *DefaultComplexGraph) StdStructuredPtrCreator() func() cptype.IStdStructuredPtr {
    79  	return func() cptype.IStdStructuredPtr {
    80  		return &StdStructuredPtr{
    81  			StdInParamsPtr: &cptype.ExtraMap{},
    82  			StdStatePtr:    &cptype.ExtraMap{},
    83  			StdDataPtr:     &complexgraph.Data{},
    84  		}
    85  	}
    86  }