aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/absattr
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2006-05-24 12:21:20 +0000
committerThomas Grill <xovo@users.sourceforge.net>2006-05-24 12:21:20 +0000
commit85f3f1cf0612e9da72fac48656893d3ca4e89669 (patch)
treed79917c04188f066fc906a61b696b68fd2117cd4 /externals/grill/absattr
parent576b21b58cced4bb319131114fca3590d58a3f6b (diff)
small fixes
small ad added loadbang prioritization svn path=/trunk/; revision=5114
Diffstat (limited to 'externals/grill/absattr')
-rw-r--r--externals/grill/absattr/absattr-help.pd24
-rw-r--r--externals/grill/absattr/absattr-no.pd21
-rw-r--r--externals/grill/absattr/absattr-sub.pd34
-rw-r--r--externals/grill/absattr/absattr.cpp138
-rw-r--r--externals/grill/absattr/absattr.vcproj125
-rw-r--r--externals/grill/absattr/license.txt4
-rw-r--r--externals/grill/absattr/readme.txt6
7 files changed, 306 insertions, 46 deletions
diff --git a/externals/grill/absattr/absattr-help.pd b/externals/grill/absattr/absattr-help.pd
index 309f0a12..ee7c4f21 100644
--- a/externals/grill/absattr/absattr-help.pd
+++ b/externals/grill/absattr/absattr-help.pd
@@ -1,13 +1,23 @@
-#N canvas 858 421 470 238 12;
+#N canvas 762 129 502 531 12;
#X obj 32 186 print EXT;
#X msg 33 20 getattributes;
#X text 228 102 delete attribute;
#X msg 148 72 set attr1 huhu haha;
#X msg 149 99 set attr1;
#X msg 63 72 get attr1;
-#X obj 32 143 absattr-sub 1 2 3 @attr1 hey ho;
-#X connect 1 0 6 0;
-#X connect 3 0 6 0;
-#X connect 4 0 6 0;
-#X connect 5 0 6 0;
-#X connect 6 0 0 0;
+#X text 152 174 loadbang priority 3 ... comes later;
+#X text 135 304 loadbang priority 1 ... comes sooner;
+#X text 116 379 no loadbang priority given... default = 0;
+#X text 154 200 \$0 represents the parent patch;
+#X text 155 217 (used for grouping loadbang priorities);
+#X text 231 360 internal attr2 is deleted;
+#X obj 29 359 absattr-sub abs1 @attr2;
+#X obj 31 447 absattr-no arg1 arg2;
+#X text 112 471 loadbang disabled inside;
+#X obj 32 143 absattr-sub 1 2 3 @loadbang \$0 3 @attr1 hey ho;
+#X obj 32 277 absattr-sub a b c @loadbang \$0 1 @me and you;
+#X connect 1 0 15 0;
+#X connect 3 0 15 0;
+#X connect 4 0 15 0;
+#X connect 5 0 15 0;
+#X connect 15 0 0 0;
diff --git a/externals/grill/absattr/absattr-no.pd b/externals/grill/absattr/absattr-no.pd
new file mode 100644
index 00000000..faaaa369
--- /dev/null
+++ b/externals/grill/absattr/absattr-no.pd
@@ -0,0 +1,21 @@
+#N canvas 307 422 585 525 12;
+#X obj 405 38 inlet;
+#X obj 32 187 print ARGS;
+#X obj 224 190 print ATTR;
+#X obj 377 189 outlet;
+#X text 453 38 extern;
+#X text 446 191 extern;
+#X obj 84 146 t a b;
+#X obj 95 112 absattr @loadbang 0;
+#X text 274 111 loadbang disabled;
+#X obj 82 49 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X text 109 48 dump manually;
+#X obj 31 225 print -----------------------;
+#X connect 0 0 7 1;
+#X connect 6 0 1 0;
+#X connect 6 1 11 0;
+#X connect 7 0 6 0;
+#X connect 7 1 2 0;
+#X connect 7 2 3 0;
+#X connect 9 0 7 0;
diff --git a/externals/grill/absattr/absattr-sub.pd b/externals/grill/absattr/absattr-sub.pd
index cff3f945..e82dc054 100644
--- a/externals/grill/absattr/absattr-sub.pd
+++ b/externals/grill/absattr/absattr-sub.pd
@@ -1,7 +1,7 @@
-#N canvas 307 422 557 497 12;
+#N canvas 307 422 577 517 12;
#X obj 405 38 inlet;
-#X obj 80 418 print ARGS;
-#X obj 174 418 print ATTR;
+#X obj 47 420 print ARGS;
+#X obj 239 423 print ATTR;
#X obj 392 422 outlet;
#X obj 72 21 bng 15 250 50 0 empty empty empty 0 -6 0 8 -260818 -1
-1;
@@ -12,7 +12,6 @@
#X msg 149 263 set attr1 tick tack;
#X msg 149 153 set newattr \$1;
#X text 68 36 bang to dump;
-#X obj 70 57 loadbang;
#X obj 110 345 absattr @attr2 default;
#X text 453 38 extern;
#X text 446 426 extern;
@@ -25,16 +24,19 @@
#X text 293 353 (only for attributes);
#X msg 71 91 getattributes;
#X text 186 93 list attributes;
-#X connect 0 0 13 1;
-#X connect 4 0 13 0;
+#X obj 99 379 t a b;
+#X obj 126 450 print -----------------------;
+#X connect 0 0 12 1;
+#X connect 4 0 12 0;
#X connect 5 0 10 0;
-#X connect 6 0 13 0;
-#X connect 7 0 13 0;
-#X connect 8 0 13 0;
-#X connect 9 0 13 0;
-#X connect 10 0 13 0;
-#X connect 12 0 13 0;
-#X connect 13 0 1 0;
-#X connect 13 1 2 0;
-#X connect 13 2 3 0;
-#X connect 23 0 13 0;
+#X connect 6 0 12 0;
+#X connect 7 0 12 0;
+#X connect 8 0 12 0;
+#X connect 9 0 12 0;
+#X connect 10 0 12 0;
+#X connect 12 0 24 0;
+#X connect 12 1 2 0;
+#X connect 12 2 3 0;
+#X connect 22 0 12 0;
+#X connect 24 0 1 0;
+#X connect 24 1 25 0;
diff --git a/externals/grill/absattr/absattr.cpp b/externals/grill/absattr/absattr.cpp
index 1194dea9..1ee0e895 100644
--- a/externals/grill/absattr/absattr.cpp
+++ b/externals/grill/absattr/absattr.cpp
@@ -2,13 +2,13 @@
absattr - patcher attributes
-Copyright (c) 2002-2005 Thomas Grill (gr@grrrr.org)
+Copyright (c) 2002-2006 Thomas Grill (gr@grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
*/
-#define VERSION "0.1.0"
+#define VERSION "0.2.0"
#include <flext.h>
@@ -17,6 +17,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#endif
#include <map>
+#include <set>
class absattr
: public flext_base
@@ -25,7 +26,8 @@ class absattr
public:
absattr(int argc,const t_atom *argv)
-// : loadbang(lb)
+ : parent(0),prior(0)
+ , loadbang(true)
{
AddInAnything("bang/get/set");
AddInAnything("external attribute messages");
@@ -34,24 +36,43 @@ public:
AddOutAnything("external attribute outlet");
// process default values (only attributes can have default values)
- Process(argc,argv);
+ Process(argc,argv,false);
// process canvas arguments
AtomListStatic<20> args;
GetCanvasArgs(args);
- Process(args.Count(),args.Atoms());
+ Process(args.Count(),args.Atoms(),true);
+
+ // add to loadbang registry
+ Objects &o = loadbangs[parent].obj;
+ o.insert(this);
}
- //! dump parameters
- void m_bang()
+ ~absattr()
{
- ToOutList(0,args);
- for(AttrMap::const_iterator it = attrs.begin(); it != attrs.end(); ++it) {
- const AtomList &lst = it->second;
- ToOutAnything(1,it->first,lst.Count(),lst.Atoms());
+ // remove from loadbang registry
+ Loadbangs::iterator it = loadbangs.find(parent);
+ if(it != loadbangs.end()) {
+ Objects &o = it->second.obj;
+ for(Objects::iterator oit = o.begin(); oit != o.end(); ++oit) {
+ if(*oit == this) {
+ // found
+ o.erase(oit);
+ break;
+ }
+ }
+ FLEXT_ASSERT(oit != o.end());
+ if(o.empty()) loadbangs.erase(it);
}
+ else
+ error("%s - not found in loadbang registry");
}
+ //! dump parameters
+ void m_bang() { BangAttr(0); }
+
+ void m_bangx() { BangAttr(1); }
+
void m_dump() { DumpAttr(0); }
void m_get(const t_symbol *s) { OutAttr(0,s); }
@@ -75,11 +96,66 @@ protected:
typedef std::map<const t_symbol *,AtomList> AttrMap;
-// bool loadbang;
+ int parent; // don't change after inserting into registry
+ float prior; // don't change after inserting into registry
+ bool loadbang;
+
AtomList args;
AttrMap attrs;
-// virtual void CbLoadbang() { if(loadbang) m_bang(); }
+ class Compare
+ {
+ public:
+ bool operator()(const absattr *a,const absattr *b) const { return a->prior == b->prior?a < b:a->prior < b->prior; }
+ };
+
+ typedef std::set<absattr *,Compare> Objects;
+
+ struct Loadbang
+ {
+ double lasttime;
+ Objects obj;
+ };
+
+ typedef std::map<int,Loadbang> Loadbangs;
+
+ static Loadbangs loadbangs;
+
+ virtual void CbLoadbang()
+ {
+ // all loadbangs have the same logical time
+ double time = GetTime();
+
+ Loadbangs::iterator it = loadbangs.find(parent);
+ if(it != loadbangs.end()) {
+ Loadbang &lb = it->second;
+ // found
+ if(lb.lasttime < time) {
+ // bang all objects with the same parent in the prioritized order
+ for(Objects::iterator oit = lb.obj.begin(); oit != lb.obj.end(); ++oit) {
+ absattr *o = *oit;
+ FLEXT_ASSERT(o);
+ if(o->loadbang) o->m_bang();
+ }
+
+ // set timestamp
+ lb.lasttime = time;
+ }
+ }
+ else
+ error("%s - not found in database");
+ }
+
+ void BangAttr(int ix)
+ {
+ if(ix == 0)
+ ToOutList(ix,args);
+
+ for(AttrMap::const_iterator it = attrs.begin(); it != attrs.end(); ++it) {
+ const AtomList &lst = it->second;
+ ToOutAnything(1+ix,it->first,lst.Count(),lst.Atoms());
+ }
+ }
void DumpAttr(int ix)
{
@@ -116,10 +192,9 @@ protected:
static bool IsAttr(const t_atom &at) { return IsSymbol(at) && *GetString(at) == '@'; }
- void Process(int argc,const t_atom *argv)
+ void Process(int argc,const t_atom *argv,bool ext)
{
- int cnt;
- for(cnt = 0; cnt < argc && !IsAttr(argv[cnt]); ++cnt) {}
+ int cnt = CheckAttrib(argc,argv);
args.Set(cnt,argv,0,true);
argc -= cnt,argv += cnt;
@@ -129,11 +204,28 @@ protected:
const t_symbol *attr = MakeSymbol(GetString(*argv)+1);
--argc,++argv;
- for(cnt = 0; cnt < argc && !IsAttr(argv[cnt]); ++cnt) {}
-
+ cnt = CheckAttrib(argc,argv);
if(cnt) {
- AtomList &lst = attrs[attr];
- lst.Set(cnt,argv,0,true);
+ if(attr == sym_loadbang) {
+ if(ext) {
+ if(cnt == 2 && CanbeInt(argv[0]) && CanbeFloat(argv[1])) {
+ parent = GetAInt(argv[0]);
+ prior = GetAFloat(argv[1]);
+ }
+ else
+ post("%s - expected: @loadbang [parent-id ($0)] priority",thisName());
+ }
+ else {
+ if(cnt == 1 && CanbeBool(*argv))
+ loadbang = GetABool(*argv);
+ else
+ post("%s - expected: @loadbang 0/1",thisName());
+ }
+ }
+ else {
+ AtomList &lst = attrs[attr];
+ lst.Set(cnt,argv,0,true);
+ }
argc -= cnt,argv += cnt;
}
else
@@ -144,10 +236,12 @@ protected:
private:
static const t_symbol *sym_attributes;
+ static const t_symbol *sym_loadbang;
FLEXT_CALLBACK(m_bang);
FLEXT_CALLBACK_S(m_get);
FLEXT_CALLBACK(m_dump);
+ FLEXT_CALLBACK(m_bangx);
FLEXT_CALLBACK_S(m_getx);
FLEXT_CALLBACK(m_dumpx);
FLEXT_CALLBACK_V(m_set);
@@ -155,11 +249,13 @@ private:
static void Setup(t_classid cl)
{
sym_attributes = MakeSymbol("attributes");
+ sym_loadbang = MakeSymbol("loadbang");
FLEXT_CADDBANG(cl,0,m_bang);
FLEXT_CADDMETHOD_(cl,0,"get",m_get);
FLEXT_CADDMETHOD_(cl,0,"getattributes",m_dump);
FLEXT_CADDMETHOD_(cl,0,"set",m_set);
+ FLEXT_CADDBANG(cl,1,m_bangx);
FLEXT_CADDMETHOD_(cl,1,"get",m_getx);
FLEXT_CADDMETHOD_(cl,1,"getattributes",m_dumpx);
FLEXT_CADDMETHOD_(cl,1,"set",m_set);
@@ -167,6 +263,8 @@ private:
};
const t_symbol *absattr::sym_attributes;
+const t_symbol *absattr::sym_loadbang;
+absattr::Loadbangs absattr::loadbangs;
FLEXT_NEW_V("absattr",absattr)
diff --git a/externals/grill/absattr/absattr.vcproj b/externals/grill/absattr/absattr.vcproj
new file mode 100644
index 00000000..ee6e75d7
--- /dev/null
+++ b/externals/grill/absattr/absattr.vcproj
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="absattr"
+ ProjectGUID="{FE64A824-6DA0-423F-BCAD-91C220DA6F96}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="PD Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="c:\data\pd\pd-cvs\src;..\flext\source"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;FLEXT_SYS=2"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="pd.lib"
+ OutputFile="$(OutDir)/absattr.dll"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="c:\data\pd\pd-cvs\bin"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/absattr.pdb"
+ SubSystem="2"
+ ImportLibrary="$(OutDir)/absattr.lib"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="PD Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="c:\programme\audio\pd\src;..\flext\source"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;FLEXT_SYS=2"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="pd.lib"
+ OutputFile="$(OutDir)/absattr.dll"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="c:\programme\audio\pd\bin"
+ GenerateDebugInformation="TRUE"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ ImportLibrary="$(OutDir)/absattr.lib"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath=".\absattr.cpp">
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/externals/grill/absattr/license.txt b/externals/grill/absattr/license.txt
index cb271f95..90e187cd 100644
--- a/externals/grill/absattr/license.txt
+++ b/externals/grill/absattr/license.txt
@@ -1,5 +1,5 @@
-pdattr - patcher attributes
-Copyright (C) 2005 Thomas Grill
+absattr - patcher attributes
+Copyright (C) 2005-2006 Thomas Grill
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
diff --git a/externals/grill/absattr/readme.txt b/externals/grill/absattr/readme.txt
index bb16fac7..aef3d066 100644
--- a/externals/grill/absattr/readme.txt
+++ b/externals/grill/absattr/readme.txt
@@ -1,6 +1,6 @@
absattr - patcher attributes
-Copyright (c)2005 Thomas Grill (gr@grrrr.org)
+Copyright (c)2005-2006 Thomas Grill (gr@grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
@@ -42,5 +42,9 @@ bash ../flext/build.sh
Version history:
+0.2.0:
+- added loadbang prioritization
+
+
0.1.0:
- first public version