Attributes – Setting Defaults + getstate

May 4, 2011 at 6:03pm

Attributes – Setting Defaults + getstate

I have a couple of queries on using attributes.

1. What is the easiest way to set default values for attributes that will be applied on creation of a new object? Does this have to be done manually by setting the appropriate variable to a value in the new object function, or is there an automated way?

2. The getstate and getfoo messages used to query attributes- must these be implemented manually as functions or is there an automated way?

#56866
May 5, 2011 at 6:13am

Hello David Butler,

1. I do something like that :

void *flop_new (t_symbol *s, long argc, t_atom *argv)
{
	t_flop *x = NULL;

	if (x = (t_flop *)object_alloc (flop_class))
		{
			x->toto	= DEF_TOTO;

			if (argc)
				{
					if (atom_gettype (argv) == A_LONG)
						{
							x->toto = atom_getlong (argv);
						}
				}

			attr_args_process (x, argc, argv);

			x->m_out = intout ((t_object *)x);
		}

	return x;
}

2. IMHO : i don’t know in jitter objects but in a max or msp object i think you have to implement a method manually to query attributes from patcher ; my 2 cents ; anybody ?

#203841

You must be logged in to reply to this topic.