summaryrefslogtreecommitdiff
path: root/libs/cassowary/ClStrength.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libs/cassowary/ClStrength.cc')
-rw-r--r--libs/cassowary/ClStrength.cc52
1 files changed, 52 insertions, 0 deletions
diff --git a/libs/cassowary/ClStrength.cc b/libs/cassowary/ClStrength.cc
new file mode 100644
index 0000000000..0629d4afff
--- /dev/null
+++ b/libs/cassowary/ClStrength.cc
@@ -0,0 +1,52 @@
+// $Id$
+//
+// Cassowary Incremental Constraint Solver
+// Original Smalltalk Implementation by Alan Borning
+// This C++ Implementation by Greg J. Badros, <gjb@cs.washington.edu>
+// http://www.cs.washington.edu/homes/gjb
+// (C) 1998, 1999 Greg J. Badros and Alan Borning
+// See ../LICENSE for legal details regarding this software
+//
+// ClStrength.cc
+
+#include <cassowary/ClStrength.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#define CONFIG_H_INCLUDED
+#endif
+
+// Use the singleton pattern for the strength objects
+const ClStrength &ClsRequired()
+{
+ // required is distinct by equality to this static object,
+ // but I still use an especially high symbolic weight, just in case
+ // FIXGJB: hack?
+ static ClStrength required_strength("<Required>", 1000, 1000, 1000);
+ return required_strength;
+}
+
+const ClStrength &ClsStrong()
+{
+ static ClStrength strong_strength("strong", 1.0, 0.0, 0.0);
+ return strong_strength;
+}
+
+const ClStrength &ClsMedium()
+{
+ static ClStrength medium_strength("medium", 0.0, 1.0, 0.0);
+ return medium_strength;
+}
+
+
+const ClStrength &ClsWeak()
+{
+ static ClStrength weak_strength("weak", 0.0, 0.0, 1.0);
+ return weak_strength;
+}
+
+// special case for when nLevels = 3, should assert nLevels() == 3
+ClStrength::ClStrength(const string &Name, double w1, double w2, double w3) :
+ _name(Name), _symbolicWeight(w1, w2, w3)
+{
+}