Line data Source code
1 : """ 2 : Abstract edge attributes. 3 : 4 : Edge attributes like [`VAttr`](@ref) are declared a a subtype. 5 : """ 6 : abstract type AbstractEAttr <: ManagedAttributes{EHnd}; end 7 : 8 : """ 9 : Edge attributes consisting of managed attributes `P` plus cached state. 10 : """ 11 : mutable struct EAttr{P} <: AbstractEAttr 12 : const attrs::P 13 : n_used::Int 14 124 : EAttr{P}(attrs::P, n = 0) where {P} = new(attrs, n) 15 : end 16 : 17 60 : _neweattr(ea::P) where {P} = EAttr{P}(ea) 18 : 19 : """ 20 : ea2 = similar(ea::EAttr) 21 : 22 : Create same attribute list as `va` but empty: without entries. 23 : """ 24 58 : Base.similar(ea::EAttr) = 25 : _neweattr(createattributes(attrspecs(attrs(ea)); htyp=EHnd)) 26 : 27 : const EdgeAttributesSpecs = (ManagedAttributesSpecs...,) 28 : 29 4 : createeattr(list...) = 30 : _neweattr(createattributes((EdgeAttributesSpecs..., list...); 31 : htyp=EHnd)) 32 : 33 2 : createeattr(list::Tuple) = createeattr(list...) 34 : 35 : """ 36 : createeattr(key => value, ...) 37 : createeattr((key => value, ...)) 38 : 39 : Create edge attribute list from `key => value` pairs, where `key` is a `Symbol` and 40 : `value` either a type or the result from `specifyattr`. 41 : 42 : Example: 43 : 44 : ea = createfattr(:locked => Bool) 45 : 46 : See also [`similar`](@ref) 47 : """ createeattr 48 : 49 : """ 50 : ec = clone(ea::EAttr) 51 : 52 : Deep copy of attribute list but don't copy disabled attributes. 53 : """ 54 4 : clone(ea::EAttr{P}) where {P} = EAttr{P}(clone(ea.attrs), ea.n_used)