Difference between revisions of "ChucK/Patterns/ExternalDataLoader"

From CSWiki
Jump to: navigation, search
 
Line 1: Line 1:
 
I have been experimenting with a pattern for loading external data, such that once the data is loaded into the ChucK VM, an event is triggered and a consumer of the data is informed that the data is ready for loadinginng
 
I have been experimenting with a pattern for loading external data, such that once the data is loaded into the ChucK VM, an event is triggered and a consumer of the data is informed that the data is ready for loadinginng
 +
 +
<pre>
 +
//GlobalSpace - All public class that holds globally accessible
 +
// Objects (in this case a user defined event class
 +
//However you cannot (in v. 1.2.1.1) use a straightforward
 +
//approach to capturing non-primative types in a static variable
 +
//So we do a bare declare of e...
 +
 +
public class GlobalSpace {
 +
    static TheEvent @ e;
 +
    //static int data[200];
 +
    static DataObj  @ callback;
 +
 +
}
 +
// ...then use the following to do the assignment
 +
 +
new TheEvent @=> GlobalSpace.e;
 +
//This seems to be a necessary hack to allow us to
 +
//use a non-primitive in a static variable space
 +
//
 +
</pre>
  
  
 
Michael Nardell
 
Michael Nardell

Revision as of 23:18, 2 December 2007

I have been experimenting with a pattern for loading external data, such that once the data is loaded into the ChucK VM, an event is triggered and a consumer of the data is informed that the data is ready for loadinginng

//GlobalSpace - All public class that holds globally accessible 
// Objects (in this case a user defined event class
//However you cannot (in v. 1.2.1.1) use a straightforward
//approach to capturing non-primative types in a static variable
//So we do a bare declare of e...

public class GlobalSpace {
    static TheEvent @ e;
    //static int data[200];
    static DataObj  @ callback;	
	
}
// ...then use the following to do the assignment

new TheEvent @=> GlobalSpace.e;
//This seems to be a necessary hack to allow us to 
//use a non-primitive in a static variable space 
//


Michael Nardell