From e3e928fc5e974da358794f6a2bbe7a09febe163d Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Fri, 27 Jan 2006 22:51:15 +0000 Subject: Counter external class with new layout, usign virtual functions svn path=/trunk/externals/clr/; revision=4507 --- external/Counter.cs | 112 +++++++++++++++++++++++++------------------ external/External.cs | 120 ----------------------------------------------- external/external.csproj | 8 +--- 3 files changed, 69 insertions(+), 171 deletions(-) delete mode 100755 external/External.cs (limited to 'external') diff --git a/external/Counter.cs b/external/Counter.cs index 7dc8289..32f9409 100755 --- a/external/Counter.cs +++ b/external/Counter.cs @@ -1,52 +1,74 @@ using System; -namespace PureData +/// +/// Descrizione di riepilogo per Counter. +/// +public class Counter: + PureData.External { - /// - /// Descrizione di riepilogo per Counter. - /// - public class Counter + public Counter() { - private IntPtr x; - - int curr = 0; - - public Counter() - { - curr = 0; - } - - public Counter(float f) - { - curr = (int) f; - } - - // this function MUST exist - public void SetUp() - { - pd.AddSelector(x, "init", new pd.DelegateFloat(Init)); - pd.AddSelector(x, new pd.DelegateWithoutArguments(SendOut)); - pd.AddSelector(x, new pd.DelegateFloat(Sum)); - pd.AddInlet(x, "init", ParametersType.Float); - pd.AddOutlet(x, ParametersType.Float); - - } - - public void Init(float f) - { - curr = (int) f; - } - - public void SendOut() - { - pd.SendToOutlet(x, 0, new Atom(curr)); - } - - public void Sum(float f) - { - curr += (int) f; - pd.SendToOutlet(x, 0, new Atom(curr)); - } + Post("Count"); +// EventFloat += new MethodFloat(MyFloat); + } + + public Counter(PureData.Atom[] args) + { + Post("Count with args"); + +// pd.AddInlet(x, "init", ParametersType.Float); +// pd.AddOutlet(x, ParametersType.Float); + } + + // this function MUST exist + public static void Main() + { + Post("Count.Main"); } + +/* + public void MyBang() + { + Post("Count-BANG"); + } + + public void MyFloat(float f) + { + Post(String.Format("Count-FLOAT {0}",f)); + } +*/ + protected override void MethodBang() + { + Post("Count-BANG"); + } + + protected override void MethodFloat(float f) + { + Post("Count-FLOAT "+f.ToString()); + } + + protected override void MethodSymbol(PureData.Symbol s) + { + Post("Count-SYMBOL "+s.ToString()); + } + + /* + public void Init(float f) + { + curr = (int) f; + } + + public void SendOut() + { + pd.SendToOutlet(x, 0, new Atom(curr)); + } + + public void Sum(float f) + { + curr += (int) f; + pd.SendToOutlet(x, 0, new Atom(curr)); + } + +*/ } diff --git a/external/External.cs b/external/External.cs deleted file mode 100755 index 7e5a69c..0000000 --- a/external/External.cs +++ /dev/null @@ -1,120 +0,0 @@ -using System; - -namespace PureData -{ - - public class External - { - private IntPtr x; - - public External() - { - } - - // this function MUST exist - public void SetUp() - { - // now you can do what you like... - Console.WriteLine("pointer set!"); - Console.WriteLine("setting selectors.."); - pd.AddSelector(x, "sel1", new pd.DelegateWithoutArguments(Sel1)); - pd.AddSelector(x, "sel2", new pd.DelegateWithoutArguments(Sel2)); - pd.AddSelector(x, "selFloat", new pd.DelegateFloat(SelFloat)); - pd.AddSelector(x, "selString", new pd.DelegateString(SelString)); - pd.AddSelector(x, "selGenericList", new pd.DelegateArray(SelGenericList)); - pd.AddSelector(x, new pd.DelegateArray(SelGenericList)); - - pd.AddSelector(x, new pd.DelegateWithoutArguments(GetBang)); - pd.AddSelector(x, new pd.DelegateFloat(GetFloat)); - pd.AddSelector(x, new pd.DelegateString(GetSymbol)); - - Console.WriteLine("selectors set"); - pd.AddOutlet(x, ParametersType.Float); - pd.AddInlet(x, "selFloat", ParametersType.Float); - } - - public void GetBang() - { - pd.PostMessage("GetBang invoked!"); - } - - public void GetFloat(float f) - { - pd.PostMessage("GetFloat invoked with " + f); - } - - public void GetSymbol(ref string s) - { - pd.PostMessage("GetSymbol invoked with " + s); - } - - public void Sel1() - { - pd.PostMessage("Sel1 invoked!"); - Atom [] a= new Atom[2]; - - } - - public void Sel2() - { - pd.PostMessage("Sel2 invoked!"); - - // testing outlets - Atom[] atoms = new Atom[4]; - atoms[0] = new Atom(1.5f); - atoms[1] = new Atom("ciao"); - atoms[2] = new Atom(2.5f); - atoms[3] = new Atom("hello"); - pd.SendToOutlet(x, 0, atoms); - - } - - public void SelFloat(float f) - { - pd.PostMessage("SelFloat received " + f); - - - } - - public void SelString(ref string s) - { - pd.PostMessage("SelString received " + s); - } - - public void SelGenericList(Atom [] list) - { - Atom [] ret = new Atom[list.Length]; - for (int i = 0; i @@ -98,11 +99,6 @@ SubType = "Code" BuildAction = "Compile" /> - -- cgit v1.2.1