Copy link to clipboard
Copied
As the title states--
Are there any caveats or considerations to using std::vectors vs AEGP Collection suites?
I've written a `LayerCollection` class that uses std::vectors, and for all intents and purposes, functions pretty much the same as the extendscript `LayerCollection`. (C++, of course.)
This works just fine, I just happened to start thinking about scalability, and if there might be any reason to use the collectionSuites vs my current approach?
I can push back, remove, pop, append, iterate over, etc.
Is this just semantics at this point, or is there a definite difference? I can't seem to find anything concrete.
Thanks!
Copy link to clipboard
Copied
well, collections are used to transfer selection sets to and from AE. (as in, which layers are selected in the timline, and which keyframes are currently highlighted)
you COULD use collections as a replacement for a vector, but it's intended to pass item selection sets back and forth with AE.
as for using an std vector, there's a general problem with that, because then you're drawing ram directly fromt he system and not from AE. it's not forbidden, but if you do so, then you don't let AE prioritize it's ram handling. with a ram preview rendering, ram is higly likely to run out so asking AE for ram allows AE to choose whther to free up some cached images to give your plug-in what it needs, while drawing directly from the system won't.
i personally use a custom allocator for the std vector so it would draw memory from AE, and then i use it freely.
Copy link to clipboard
Copied
Ahhh okay, thanks!
So if I understand correctly, I'd write a custom allocator for whatever std lib thing I'm using (vector in this case), and fill it out with logic that uses (I'd assume) the memory/handle suites?
Copy link to clipboard
Copied
indeed. same goes for any allocation. you can override the "new" operator for that purpose.
i opted for a class with overridden "new" and "delete" operators which i use as a base class for all others.