diff options
Diffstat (limited to 'libs/cassowary/cassowary/ClStrength.h')
-rw-r--r-- | libs/cassowary/cassowary/ClStrength.h | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/libs/cassowary/cassowary/ClStrength.h b/libs/cassowary/cassowary/ClStrength.h new file mode 100644 index 0000000000..644c04cb5f --- /dev/null +++ b/libs/cassowary/cassowary/ClStrength.h @@ -0,0 +1,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 |