private VectorImp <TType> CreateVectorImp(Dlib.Native.VectorElementType types) { switch (types) { case Dlib.Native.VectorElementType.UInt8: return(new VectorUInt8Imp(this, types) as VectorImp <TType>); case Dlib.Native.VectorElementType.UInt16: return(new VectorUInt16Imp(this, types) as VectorImp <TType>); case Dlib.Native.VectorElementType.UInt32: return(new VectorUInt32Imp(this, types) as VectorImp <TType>); case Dlib.Native.VectorElementType.Int8: return(new VectorInt8Imp(this, types) as VectorImp <TType>); case Dlib.Native.VectorElementType.Int16: return(new VectorInt16Imp(this, types) as VectorImp <TType>); case Dlib.Native.VectorElementType.Int32: return(new VectorInt32Imp(this, types) as VectorImp <TType>); case Dlib.Native.VectorElementType.Float: return(new VectorFloatImp(this, types) as VectorImp <TType>); case Dlib.Native.VectorElementType.Double: return(new VectorDoubleImp(this, types) as VectorImp <TType>); default: throw new ArgumentOutOfRangeException(nameof(types), types, null); } }
public Vector() { if (!SupportTypes.TryGetValue(typeof(TType), out var type)) { throw new NotSupportedException($"{typeof(TType).Name} does not support"); } this._VectorElementTypes = type; this._ElementType = type.ToNativeVectorElementType(); this._Imp = this.CreateVectorImp(this._ElementType); this.NativePtr = Dlib.Native.vector_new(this._ElementType); }
internal Vector(IntPtr ptr, bool isEnabledDispose = true) : base(isEnabledDispose) { if (ptr == IntPtr.Zero) { throw new ArgumentException("Can not pass IntPtr.Zero", nameof(ptr)); } if (!SupportTypes.TryGetValue(typeof(TType), out var type)) { throw new NotSupportedException($"{typeof(TType).Name} does not support"); } this.NativePtr = ptr; this._VectorElementTypes = type; this._ElementType = type.ToNativeVectorElementType(); this._Imp = this.CreateVectorImp(this._ElementType); this.NativePtr = ptr; }
internal VectorDoubleImp(DlibObject parent, Dlib.Native.VectorElementType type) : base(parent, type) { }
internal VectorImp(DlibObject parent, Dlib.Native.VectorElementType type) { this._Parent = parent ?? throw new ArgumentNullException(nameof(parent)); this._Type = type; }