void ComposeOverloaded(INodeInfo nodeInfo, IInternalPluginHost nodeHost, Type baseType) { //dispose previous plugin var plugin = nodeHost.Plugin; nodeHost.Plugin = null; //delete delphi side ((plugin as PluginContainer)?.PluginBase as IStructIO)?.IOManager.Dispose(); if (plugin != null) { DisposePlugin(plugin); } //now create new var emitType = EmitOverloaded(baseType); var container = CreatePluginContainer(nodeInfo, nodeHost, emitType); nodeHost.Plugin = container; var mgr = (container.PluginBase as IStructIO).IOManager as IOManager; mgr.IsInput = baseType.GetInterface("IStructFieldGetter") == null; mgr.IOFactory = (container.PluginBase as IStructEmit).IOFactory; FHDEHost.MainLoop.OnResetCache += (o, e) => { mgr.ResetCache(); }; //clears sync flag var declareEmit = container.PluginBase as IStructDeclareEmit; if (declareEmit != null) { InitializeDeclarer(nodeHost, declareEmit); } FInstances.Add(nodeHost); }
public PluginContainer( IInternalPluginHost pluginHost, IORegistry ioRegistry, CompositionContainer parentContainer, Type pluginType, INodeInfo nodeInfo ) { FIOFactory = new IOFactory(pluginHost, ioRegistry); var catalog = new TypeCatalog(pluginType); var ioExportProvider = new IOExportProvider(FIOFactory); var hostExportProvider = new HostExportProvider() { PluginHost = pluginHost }; var exportProviders = new ExportProvider[] { hostExportProvider, ioExportProvider, parentContainer }; FContainer = new CompositionContainer(catalog, exportProviders); FContainer.ComposeParts(this); FPlugin = PluginBase as IPluginEvaluate; FAutoEvaluate = nodeInfo.AutoEvaluate; FIOFactory.OnCreated(EventArgs.Empty); }
protected override bool CreateNode(INodeInfo nodeInfo, IInternalPluginHost nodeHost) { var baseType = GetPluginType(nodeInfo); //nothing special to do, node doesn't carry any of our interfaces if (baseType.GetInterface("IStructIO") == null) { if (nodeInfo.Username.Contains("Struct") || nodeInfo.Filename.Contains(FBasePath)) { return(base.CreateNode(nodeInfo, nodeHost)); } else { //this actually shouldn't happen. vvvv thinks this factory should handle the plugin. //throw; return(false); } } else { ComposeOverloaded(nodeInfo, nodeHost, baseType); return(true); } }
public static bool IsNodeAssignableFrom <T>(this INode2 node) { if (node.NodeInfo.Type == NodeType.Dynamic || node.NodeInfo.Type == NodeType.Plugin) { IPluginHost host = (IPluginHost)node.InternalCOMInterf; IInternalPluginHost iip = (IInternalPluginHost)host; try { if (iip.Plugin is PluginContainer) { PluginContainer plugin = (PluginContainer)iip.Plugin; return(typeof(T).IsAssignableFrom(plugin.PluginBase.GetType())); } else { return(typeof(T).IsAssignableFrom(iip.Plugin.GetType())); } } catch { #if DEBUG System.Diagnostics.Debug.WriteLine("Error checking node:" + node.NodeInfo.Name); #endif return(false); } } else { return(false); } }
public static bool IsNodeAssignableFrom <T>(this INode node) { if (node.GetNodeInfo().Type == NodeType.Dynamic || node.GetNodeInfo().Type == NodeType.Plugin) { IPluginHost host = (IPluginHost)node; IInternalPluginHost iip = (IInternalPluginHost)host; if (iip.Plugin != null) { if (iip.Plugin is PluginContainer) { PluginContainer plugin = (PluginContainer)iip.Plugin; return(typeof(T).IsAssignableFrom(plugin.PluginBase.GetType())); } else { return(typeof(T).IsAssignableFrom(iip.Plugin.GetType())); } } else { return(false); } } else { return(false); } }
public MeshOutStream(IInternalPluginHost host, OutputAttribute attribute) { FInternalMeshOut = host.CreateMeshOutput2( this, attribute.Name, (TSliceMode)attribute.SliceMode, (TPinVisibility)attribute.Visibility ); }
public IOFactory(IInternalPluginHost pluginHost, IIORegistry streamRegistry) { FPluginHost = pluginHost; FIORegistry = streamRegistry; // HACK if (FPluginHost != null) { FPluginHost.Subscribe(this); } }
public DX11NodeInterfaces(IInternalPluginHost hoster) { this.hoster = hoster; this.resourceProvider = this.IsAssignable <IDX11ResourceProvider>() ? this.Instance <IDX11ResourceProvider>() : null; this.rendererProvider = this.IsAssignable <IDX11RendererProvider>() ? this.Instance <IDX11RendererProvider>() : null; this.renderWindow = this.IsAssignable <IDX11RenderWindow>() ? this.Instance <IDX11RenderWindow>() : null; this.multiResourceProvider = this.IsAssignable <IDX11MultiResourceProvider>() ? this.Instance <IDX11MultiResourceProvider>() : null; this.layerProvider = this.IsAssignable <IDX11LayerProvider>() ? this.Instance <IDX11LayerProvider>() : null; this.dataRetriever = this.IsAssignable <IDX11ResourceDataRetriever>() ? this.Instance <IDX11ResourceDataRetriever>() : null; this.updateBlocker = this.IsAssignable <IDX11UpdateBlocker>() ? this.Instance <IDX11UpdateBlocker>() : null; }
public DX11Node(INode hdeNode, IPluginHost hoster) { this.InputPins = new List <DX11InputPin>(); this.OutputPins = new List <DX11OutputPin>(); this.HdeNode = hdeNode; this.Name = hdeNode.GetNodeInfo().Systemname; this.Hoster = hoster; IInternalPluginHost iip = (IInternalPluginHost)this.Hoster; this.Interfaces = new DX11NodeInterfaces(iip); }
private T Instance <T>() { IInternalPluginHost iip = (IInternalPluginHost)this.hoster; if (iip.Plugin is PluginContainer) { PluginContainer plugin = (PluginContainer)iip.Plugin; return((T)plugin.PluginBase); } else { return((T)iip.Plugin); } }
private bool IsAssignable <T>() { IInternalPluginHost iip = (IInternalPluginHost)this.hoster; if (iip.Plugin is PluginContainer) { PluginContainer plugin = (PluginContainer)iip.Plugin; return(typeof(T).IsAssignableFrom(plugin.PluginBase.GetType())); } else { return(typeof(T).IsAssignableFrom(iip.Plugin.GetType())); } }
public DX11Node(INode2 hdeNode, IPluginHost hoster) { this.InputPins = new List <DX11InputPin>(); this.OutputPins = new List <DX11OutputPin>(); this.HdeNode2 = hdeNode; this.HdeNode = hdeNode.InternalCOMInterf; this.Name = hdeNode.NodeInfo.Systemname; this.Hoster = hoster; IInternalPluginHost iip = (IInternalPluginHost)this.Hoster; this.Interfaces = new DX11NodeInterfaces(iip); this.VirtualConnections = new List <DX11VirtualConnection>(); }
protected override bool DeleteNode(INodeInfo nodeInfo, IInternalPluginHost pluginHost) { var plugin = pluginHost.Plugin; if (plugin is IDisposable) { var disposablePlugin = plugin as IDisposable; disposablePlugin.Dispose(); } if (this.PluginDeleted != null) { this.PluginDeleted(pluginHost.Plugin); } return(true); }
protected override bool DeleteNode(INodeInfo nodeInfo, IInternalPluginHost host) { var plugin = host.Plugin; var disposablePlugin = plugin as IDisposable; if (FPluginContainers.ContainsKey(plugin)) { FPluginContainers[plugin].Dispose(); FPluginContainers.Remove(plugin); } if (this.PluginDeleted != null) { this.PluginDeleted(host.Plugin); } return true; }
public IOFactory( IInternalPluginHost pluginHost, IIORegistry ioRegistry, CompositionContainer container, INodeInfoFactory nodeInfoFactory, DotNetPluginFactory pluginFactory) { FPluginHost = pluginHost; FIORegistry = ioRegistry; FContainer = container; FNodeInfoFactory = nodeInfoFactory; FPluginFactory = pluginFactory; // HACK if (FPluginHost != null) { FPluginHost.Subscribe(this); } }
protected override bool CreateNode(INodeInfo nodeInfo, IInternalPluginHost pluginHost) { if (nodeInfo.Type != NodeType.Plugin) { return(false); } //get the code of the FXProject associated with the nodeinfos filename //effectHost.SetEffect(nodeInfo.Filename, project.Code); //compile shader var shader = DX11Effect.FromByteCode(nodeInfo.Filename); //create or update plugin if (pluginHost.Plugin == null) { //IPluginBase plug = this.FDotNetFactory.CreatePluginCustom(nodeInfo, pluginHost as IPluginHost2, typeof(DX11ShaderNode)); nodeInfo.AutoEvaluate = false; nodeInfo.Arguments = typeof(T).ToString(); var pluginContainer = new PluginContainer(pluginHost, FIORegistry, FParentContainer, FNodeInfoFactory, FDotNetFactory, typeof(T), nodeInfo); pluginHost.Plugin = pluginContainer; FPluginContainers[pluginContainer.PluginBase] = pluginContainer; IDX11ShaderNodeWrapper shaderNode = pluginContainer.PluginBase as IDX11ShaderNodeWrapper; shaderNode.SetShader(shader, true, nodeInfo.Filename); if (this.PluginCreated != null) { this.PluginCreated(pluginContainer, pluginHost); } } else { PluginContainer container = pluginHost.Plugin as PluginContainer; var shaderNode = container.PluginBase as IDX11ShaderNodeWrapper; shaderNode.SetShader(shader, false, nodeInfo.Filename); } return(true); }
void InitializeDeclarer(IInternalPluginHost nodeHost, IStructDeclareEmit declareEmit) { var declarer = declareEmit as IStructDeclarer; var editor = new DeclarationUI(nodeHost, FHDEHost, FDeclarationFactory.FBindingList); editor.SelectionChanged += (o, e) => EditorDeclarationSelectionChanged(declarer, e); editor.CreateDeclaration += (o, e) => EditorCreateDeclaration(o as DeclarationUI, declarer, e.Name, e.Fields); editor.UpdateDeclaration += (o, e) => EditorUpdateDeclaration(o as DeclarationUI, declarer, e.Name, e.Fields); nodeHost.Win32Window = editor; declareEmit.InputWindowHandle = editor.Handle; declarer.IOManager.IOsChanged += (o, e) => { var d = declarer.Declaration; editor.SetByDeclaration(d); if ((o as Declaration) != null) { var text = d.ToString(); if (text != declareEmit.Cache[0]) { declareEmit.Cache[0] = text; } } }; declareEmit.Cache.Changed += (s) => LoadDeclaration(nodeHost, declarer, s[0]); //only for startup if (string.IsNullOrWhiteSpace(declareEmit.Cache[0])) { declareEmit.Cache[0] = FDeclarationFactory.Get("Template").ToString(); LoadDeclaration(nodeHost, declarer, declareEmit.Cache[0]); } //else // declareEmit.Cache[0] = declareEmit.Cache[0]; //HACK! making sure to get a callback once vvvv is configuring for the first time }
protected override bool CreateNode(INodeInfo nodeInfo, IInternalPluginHost pluginHost) { if (nodeInfo.Type != NodeType.Dynamic) { return(false); } var project = nodeInfo.UserData as FXProject; /*if (!project.IsLoaded) * project.Load();*/ //compile shader FIncludeHandler.ParentPath = Path.GetDirectoryName(nodeInfo.Filename); string code = File.ReadAllText(nodeInfo.Filename); DX11Effect shader; //create or update plugin if (pluginHost.Plugin == null) { nodeInfo.AutoEvaluate = false; nodeInfo.Arguments = typeof(T).ToString(); var pluginContainer = new PluginContainer(pluginHost, FIORegistry, FParentContainer, FNodeInfoFactory, FDotNetFactory, typeof(T), nodeInfo); pluginHost.Plugin = pluginContainer; FPluginContainers[pluginContainer.PluginBase] = pluginContainer; IDX11ShaderNodeWrapper shaderNode = pluginContainer.PluginBase as IDX11ShaderNodeWrapper; shaderNode.Source = nodeInfo; shaderNode.WantRecompile += new EventHandler(shadernode_WantRecompile); shader = DX11Effect.FromString(code, FIncludeHandler, shaderNode.Macros); shaderNode.SetShader(shader, true, nodeInfo.Filename); if (this.PluginCreated != null) { this.PluginCreated(pluginContainer, pluginHost); } } else { PluginContainer container = pluginHost.Plugin as PluginContainer; var shaderNode = container.PluginBase as IDX11ShaderNodeWrapper; shader = DX11Effect.FromString(code, FIncludeHandler, shaderNode.Macros); shaderNode.SetShader(shader, false, nodeInfo.Filename); } //now the effect is compiled in vvvv and we can access the errors string e = shader.ErrorMessage;//effectHost.GetErrors(); if (string.IsNullOrEmpty(e)) { e = ""; } this.ParseErrors(e, project, shader); //and the input pins string f = "";// effectHost.GetParameterDescription(); if (string.IsNullOrEmpty(f)) { f = ""; } project.ParameterDescription = f; return(true); }
public void Init() { FPluginHost = new PluginHost(); FFactory = new IOFactory(FPluginHost, new IORegistry()); }
PluginContainer CreatePluginContainer(INodeInfo nodeInfo, IInternalPluginHost nodeHost, Type emitType) { return(new PluginContainer(nodeHost, FIORegistry, FParentContainer, FNodeInfoFactory, this, emitType, nodeInfo)); }
protected override bool DeleteNode(INodeInfo nodeInfo, IInternalPluginHost pluginHost) { FInstances.Remove(pluginHost); ((pluginHost.Plugin as PluginContainer)?.PluginBase as IStructIO)?.IOManager.Dispose(); return(base.DeleteNode(nodeInfo, pluginHost)); }