Jamoma API  0.6.0.a19
j.savebang.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup implementationMaxExternals
4  *
5  * @brief j.savebang : Send a bang when a user saves the patcher
6  *
7  * @details
8  *
9  * @authors Tim Place, Trond Lossius
10  *
11  * @copyright © 2009 by Tim Place @n
12  * This code is licensed under the terms of the "New BSD License" @n
13  * http://creativecommons.org/licenses/BSD/
14  */
15 
16 
17 #include "JamomaForMax.h"
18 
19 
20 typedef struct _savebang{
21  t_object obj;
22  void* outlet;
23 } t_savebang;
24 
25 
26 void *savebang_new(void);
27 void savebang_free(t_savebang *x);
28 void savebang_assist(t_savebang *x, void *b, long m, long a, char *s);
29 void savebang_save(t_savebang *x, t_symbol *s, long argc, t_atom *argv);
30 
31 
32 static t_class* s_savebang_class;
33 
34 
35 /************************************************************************************/
36 int JAMOMA_EXPORT_MAXOBJ main(void)
37 {
38  t_class *c;
39 
40  common_symbols_init();
41 
42  // Define our class
43  c = class_new("j.savebang",(method)savebang_new, (method)savebang_free, sizeof(t_savebang), (method)0L, 0L, 0);
44 
45  // Make methods accessible for our class:
46  class_addmethod(c, (method)savebang_save, "save", A_CANT, 0L);
47  class_addmethod(c, (method)savebang_assist, "assist", A_CANT, 0L);
48 
49  // Finalize our class
50  class_register(_sym_box, c);
51  s_savebang_class = c;
52  return 0;
53 }
54 
55 
56 /************************************************************************************/
57 void *savebang_new(void)
58 {
59  t_savebang *x;
60 
61  x = (t_savebang *)object_alloc(s_savebang_class); // Create object, store pointer to it (get 1 inlet free)
62 
63  if (x) {
64  x->outlet = outlet_new(x, NULL);
65  }
66  return (x);
67 }
68 
69 
70 void savebang_free(t_savebang *x)
71 {
72  ;
73 }
74 
75 
76 /************************************************************************************/
77 void savebang_assist(t_savebang *x, void *b, long m, long a, char *dst)
78 {
79  strcpy(dst, "sends a bang when the containing patcher is saved");
80 }
81 
82 
83 void savebang_save(t_savebang *x, t_symbol *s, long argc, t_atom *argv)
84 {
85  outlet_bang(x->outlet);
86 }
87 
Various utilities for interfacing with Max that are not specific to JamomaModular as such...
int JAMOMA_EXPORT_MAXOBJ main(void)
Set up this class as a Max external the first time an object of this kind is instantiated.
Definition: j.savebang.cpp:36