From c2645dc4003b1391aba9b387a79a66cff1e63d3e Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Tue, 22 Oct 2002 23:16:30 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r189, which included commits to RCS files with non-trunk default branches. svn path=/trunk/; revision=190 --- externals/grill/pool/pool.h | 124 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 externals/grill/pool/pool.h (limited to 'externals/grill/pool/pool.h') diff --git a/externals/grill/pool/pool.h b/externals/grill/pool/pool.h new file mode 100644 index 00000000..21fe4eb3 --- /dev/null +++ b/externals/grill/pool/pool.h @@ -0,0 +1,124 @@ +/* + +pool - hierarchical storage object for PD and Max/MSP + +Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. + +*/ + +#ifndef __POOL_H +#define __POOL_H + +#include + +#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 400) +#error You need at least flext version 0.4.0 +#endif + +#define POOL_VERSION "0.0.5" + +#include + +typedef void V; +typedef int I; +typedef float F; +typedef char C; +typedef bool BL; +typedef t_atom A; +typedef t_symbol S; + +class poolval: + public flext +{ +public: + poolval(const A &key,AtomList *data); + ~poolval(); + + poolval &Set(AtomList *data); + poolval *Dup() const; + + A key; + AtomList *data; + poolval *nxt; +}; + + class pooldir: + public flext +{ +public: + pooldir(const A &dir); + ~pooldir(); + + V Clear(BL rec,BL dironly = false); + + pooldir *GetDir(I argc,const A *argv,BL cut = false); + pooldir *GetDir(const AtomList &d,BL cut = false) { return GetDir(d.Count(),d.Atoms(),cut); } + BL DelDir(const AtomList &d); + pooldir *AddDir(I argc,const A *argv); + pooldir *AddDir(const AtomList &d) { return AddDir(d.Count(),d.Atoms()); } + + V SetVal(const A &key,AtomList *data,BL over = true); + V ClrVal(const A &key) { SetVal(key,NULL); } + AtomList *GetVal(const A &key,BL cut = false); + I CntAll(); + I GetAll(A *&keys,AtomList *&lst,BL cut = false); + I GetSub(const t_atom **&dirs); + + BL Paste(const pooldir *p,I depth,BL repl,BL mkdir); + BL Copy(pooldir *p,I depth,BL cur); + + BL LdDir(istream &is,I depth,BL mkdir); + BL SvDir(ostream &os,I depth,const AtomList &dir = AtomList()); + + A dir; + pooldir *nxt; + + pooldir *dirs; + poolval *vals; +}; + + class pooldata: + public flext +{ +public: + pooldata(const S *s = NULL); + ~pooldata(); + + V Push() { ++refs; } + BL Pop() { return --refs > 0; } + + V Reset(); + BL MkDir(const AtomList &d); + BL ChkDir(const AtomList &d); + BL RmDir(const AtomList &d); + + BL Set(const AtomList &d,const A &key,AtomList *data,BL over = true); + BL Clr(const AtomList &d,const A &key); + BL ClrAll(const AtomList &d,BL rec,BL dironly = false); + AtomList *Get(const AtomList &d,const A &key); + I CntAll(const AtomList &d); + I GetAll(const AtomList &d,A *&keys,AtomList *&lst); + I GetSub(const AtomList &d,const t_atom **&dirs); + + BL Paste(const AtomList &d,const pooldir *clip,I depth = -1,BL repl = true,BL mkdir = true); + pooldir *Copy(const AtomList &d,const A &key,BL cut); + pooldir *CopyAll(const AtomList &d,I depth,BL cut); + + BL LdDir(const AtomList &d,const C *flnm,I depth,BL mkdir = true); + BL SvDir(const AtomList &d,const C *flnm,I depth,BL absdir); + BL Load(const C *flnm) { return LdDir(AtomList(),flnm,-1); } + BL Save(const C *flnm) { return SvDir(AtomList(),flnm,-1,true); } + + I refs; + const S *sym; + pooldata *nxt; + + pooldir root; + +private: + static t_atom nullatom; +}; + +#endif -- cgit v1.2.1