mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-15 02:56:35 +01:00
stub constraint-based packer for canvas
This commit is contained in:
parent
c8f85d6b6c
commit
91af7cd9a2
20 changed files with 141 additions and 0 deletions
52
libs/canvas/kiwi/expression.h
Normal file
52
libs/canvas/kiwi/expression.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*-----------------------------------------------------------------------------
|
||||
| Copyright (c) 2013-2017, Nucleic Development Team.
|
||||
|
|
||||
| Distributed under the terms of the Modified BSD License.
|
||||
|
|
||||
| The full license is in the file LICENSE, distributed with this software.
|
||||
|----------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include "term.h"
|
||||
|
||||
namespace kiwi
|
||||
{
|
||||
|
||||
class Expression
|
||||
{
|
||||
|
||||
public:
|
||||
Expression(double constant = 0.0) : m_constant(constant) {}
|
||||
|
||||
Expression(const Term &term, double constant = 0.0) : m_terms(1, term), m_constant(constant) {}
|
||||
|
||||
Expression(const std::vector<Term> &terms, double constant = 0.0) : m_terms(terms), m_constant(constant) {}
|
||||
|
||||
~Expression() {}
|
||||
|
||||
const std::vector<Term> &terms() const
|
||||
{
|
||||
return m_terms;
|
||||
}
|
||||
|
||||
double constant() const
|
||||
{
|
||||
return m_constant;
|
||||
}
|
||||
|
||||
double value() const
|
||||
{
|
||||
typedef std::vector<Term>::const_iterator iter_t;
|
||||
double result = m_constant;
|
||||
iter_t end = m_terms.end();
|
||||
for (iter_t it = m_terms.begin(); it != end; ++it)
|
||||
result += it->value();
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<Term> m_terms;
|
||||
double m_constant;
|
||||
};
|
||||
|
||||
} // namespace kiwi
|
||||
Loading…
Add table
Add a link
Reference in a new issue