Merging from trunk
[ardour.git] / libs / cassowary / ClStrength.cc
1 // $Id$
2 //
3 // Cassowary Incremental Constraint Solver
4 // Original Smalltalk Implementation by Alan Borning
5 // This C++ Implementation by Greg J. Badros, <gjb@cs.washington.edu>
6 // http://www.cs.washington.edu/homes/gjb
7 // (C) 1998, 1999 Greg J. Badros and Alan Borning
8 // See ../LICENSE for legal details regarding this software
9 //
10 // ClStrength.cc
11
12 #include <cassowary/ClStrength.h>
13
14 #ifdef HAVE_CONFIG_H
15 #include <config.h>
16 #define CONFIG_H_INCLUDED
17 #endif
18
19 // Use the singleton pattern for the strength objects
20 const ClStrength &ClsRequired()
21 {
22   // required is distinct by equality to this static object,
23   // but I still use an especially high symbolic weight, just in case
24   // FIXGJB: hack?
25   static ClStrength required_strength("<Required>", 1000, 1000, 1000);
26   return required_strength;
27 }
28
29 const ClStrength &ClsStrong()
30 {
31   static ClStrength strong_strength("strong", 1.0, 0.0, 0.0);
32   return strong_strength;
33 }
34
35 const ClStrength &ClsMedium()
36 {
37   static ClStrength medium_strength("medium", 0.0, 1.0, 0.0);
38   return medium_strength;
39 }
40
41
42 const ClStrength &ClsWeak()
43 {
44   static ClStrength weak_strength("weak", 0.0, 0.0, 1.0);
45   return weak_strength;
46 }
47
48 // special case for when nLevels = 3, should assert nLevels() == 3
49 ClStrength::ClStrength(const string &Name, double w1, double w2, double w3) :
50   _name(Name), _symbolicWeight(w1, w2, w3)
51
52 }