Working with max classes that are NOT objects

Sep 28, 2009 at 7:25pm

Working with max classes that are NOT objects

Hi all,

I’m working on something at the moment that requires me to get the user to pass in a name that will act as a reference to a particular data structure (as you type names into buffer~/sends/colls etc. etc.). In this case the data structure is the top node of a data hierarchy. The structure in question might be be owned by an object of one of a number of classes.

Therefore, in order to make this work safely, I want to check that the name I’m being handed is actually bound to one of these structures, and not something else (like a send or whatever), before I start examining the contents of its memory. If the structure is a max class I can use object_class or object_classname or whatever to determine that I have the right kind of object.

However, what I’m not clear on is where and how should I setup this data structure class. The problems being that this common class needs to be accessible to several other classes and should not be accessible by typing into an object box.

Any one done this and have any ideas, tips?

Many Thanks

Alex Harker

#45645
Sep 28, 2009 at 7:33pm

One way to approach this task is to create a ‘nobox’ object — that is to say an object that is not instantiated in a box like a normal Max object. Then you could create instances of your new object/struct to carry the data around.

In Max this is done for various kinds of data stores — t_linklist, t_hashtab, t_dictionary, etc. They are all nobox classes.

I also wrote a little bit about this here:
http://blog.74objects.com/2009/03/31/custom-data-types-2/

Hope this helps…

#164644
Sep 28, 2009 at 7:37pm

Thanks Timothy! That’s awesome. I knew this was possible, and how lots of data stroes in max are done, I’ve just never had to do it before. Your article seems to cover everything I need.

Thanks again,

Alex

#164645
Sep 29, 2009 at 12:49pm

OK. So everything is pretty much working nicely, except for one thing.

I’ve made my nobox object as a separate .mxo external. If I load it manually before instantiating any of the objects that depend on it then all goes well. However, if I load one of those objects without loading the external then it crashes (it doesn’t load the .mxo from disk, even though it’s in the searchpath). Any idea on how I can make this work better?

Thanks,

Alex

#164646
Sep 29, 2009 at 4:18pm

If you put your mxo in the Cycling ’74/extensions folder then Max will load it at launch so it will be available to the other objects when they need it.

You should probably also make sure that object_new(), or whichever variant you are using, is not returning NULL before you start calling methods on your instance.

Cheers

#164647
Sep 30, 2009 at 10:31am

Ok. Thanks Tim. Figured that there might be a better way, but this is fine if it’s the only way.

Thanks for your help thus far. I’m now using connection_client rather than directly binding to a symbol, as I realised two-way communication would be necessary, and I’ve run into a problem. If you have a moment could you check out my new post on this, as I’m guessing you might know the answer…

http://www.cycling74.com/forums/index.php?t=msg&goto=181993&rid=4015&S=73d9f13b8063255e691d57d65cfcb923#msg_181993

Thanks again,

Alex

#164648

You must be logged in to reply to this topic.