blob: 644c04cb5f0ca97dea1c9a1c28b79f10b9da122f (
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
// $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.h
#ifndef ClStrength_H
#define ClStrength_H
#if defined(HAVE_CONFIG_H) && !defined(CONFIG_H_INCLUDED) && !defined(CONFIG_INLINE_H_INCLUDED)
#include <cassowary/config-inline.h>
#define CONFIG_INLINE_H_INCLUDED
#endif
#include <string>
#include "Cassowary.h"
#include "ClSymbolicWeight.h"
using std::string;
class ClStrength;
const ClStrength &ClsRequired();
const ClStrength &ClsStrong();
const ClStrength &ClsMedium();
const ClStrength &ClsWeak();
class ClStrength {
public:
ClStrength(const string &Name, const ClSymbolicWeight &symbolicWeight) :
_name(Name), _symbolicWeight(symbolicWeight)
{ }
// special case for when nLevels = 3, should assert nLevels() == 3
ClStrength(const string &Name, double w1, double w2, double w3);
virtual ~ClStrength()
{ }
virtual bool IsRequired() const
{ return (_symbolicWeight == ClsRequired()._symbolicWeight); }
#ifndef CL_NO_IO
virtual ostream &PrintOn(ostream &xo) const
{
xo << Name();
if (!IsRequired())
xo << ":" << symbolicWeight();
return xo;
}
friend ostream& operator<<(ostream &xos, const ClStrength &Cls)
{ Cls.PrintOn(xos); return xos; }
#endif
virtual const ClSymbolicWeight &symbolicWeight() const
{ return _symbolicWeight; }
void SetPv(void *pv)
{ _pv = pv; }
void *Pv() const
{ return _pv; }
private:
string Name() const
{ return _name; }
void SetName(string Name)
{ _name = Name; }
void SetSymbolicWeight(const ClSymbolicWeight &symbolicWeight)
{ _symbolicWeight = symbolicWeight; }
// instance variables
string _name;
ClSymbolicWeight _symbolicWeight;
void *_pv;
};
#endif
|