Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F126299
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/util/parameter.h b/util/parameter.h
index bc04ba4b..7359b351 100644
--- a/util/parameter.h
+++ b/util/parameter.h
@@ -1,63 +1,68 @@
#ifndef _paintown_parameter_h
#define _paintown_parameter_h
/* parameters are to be used to control the dynamic extent of values. values
* can be pushed onto the current extent and are automatically popped off
* upon function return.
* this is similar to 'parameters' in Racket.
*
* This class is not thread safe.
*/
#include <vector>
namespace Util{
/* the static variable `stack' has to be defined somewhere. use this syntax to define it
* template <> vector<int> Parameter<int>::stack;
*/
template <class Value>
class Parameter{
public:
/* push a new value on the stack */
Parameter(const Value & what):
items(0){
push(what);
}
Parameter():
items(0){
}
/* pop last value */
~Parameter(){
for (int i = 0; i < items; i++){
if (stack.size() > 0){
stack.pop_back();
}
}
}
void push(const Value & what){
items += 1;
stack.push_back(what);
}
/* get the current value */
static Value current(){
if (stack.size() > 0){
return stack.back();
}
return Value();
}
static std::vector<Value> stack;
protected:
- /* number of things pushed onto the stack by this object */
+ /* number of things pushed onto the stack by this object. note this is
+ * not the number of items on the stack because if there are multiple
+ * parameter objects then each one could have pushed 1 object on. thus
+ * the stack will have 2 things in it but each parameter will have an
+ * 'items' count of 1.
+ */
int items;
};
}
#endif
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Jun 11, 11:12 AM (3 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
68669
Default Alt Text
(1 KB)
Attached To
Mode
R75 R-Tech1
Attached
Detach File
Event Timeline