summaryrefslogtreecommitdiff
path: root/libs/cassowary/ClStrength.cc
blob: 0629d4afffae2c9ca4ed925c46cad47b9a4ce732 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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)
{ 
}