From: fred Date: Sun, 24 Mar 2002 19:39:30 +0000 (+0000) Subject: lilypond-0.0.52 X-Git-Tag: release/1.5.59~4946 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=10a4a95b75d1e5332093c6eeaf48ef4f5329dd6a;p=lilypond.git lilypond-0.0.52 --- diff --git a/flower/include/interval.hh b/flower/include/interval.hh index 57f6a5607a..1c3c6588c0 100644 --- a/flower/include/interval.hh +++ b/flower/include/interval.hh @@ -12,9 +12,10 @@ #include "real.hh" -/** a T interval. - this represents the closed interval [left,right]. - No invariants. T must be a totally ordered ring +/** a T interval. this represents the closed interval [left,right]. + No invariants. T must be a totally ordered ring (with division, anyway ..) + At instantiation, the function infinity() has to be defined explicitely. + */ template struct Interval_t { @@ -22,6 +23,8 @@ struct Interval_t { /* ************** */ + static T infinity() ; + T center() { return (left + right) / T(2);} void translate(T t) { left += t; @@ -56,6 +59,7 @@ struct Interval_t { T length() const; void set_empty() ; bool empty_b() const { return left > right; } + bool contains_b(Interval_t const&) const; Interval_t() { set_empty(); } diff --git a/flower/include/interval.tcc b/flower/include/interval.tcc index 32eec44580..49be704608 100644 --- a/flower/include/interval.tcc +++ b/flower/include/interval.tcc @@ -20,6 +20,15 @@ _Interval__compare(const Interval_t&a,Interval_t const&b) return -2; } +template +bool +Interval_t::contains_b(Interval_t const& a)const +{ + int c_i= _Interval__compare( *this, a); + if (c_i == -2) + return false; + return c_i >= 0; +} template int @@ -31,18 +40,12 @@ Interval__compare(const Interval_t&a,Interval_t const&b) return i; } -#ifdef AIX -const Real INFTY = 1e8; // ARGh. AIX sucks -#else -const Real INFTY = HUGE_VAL; -#endif - template void Interval_t::set_empty() { - left = INFTY; - right = -INFTY; + left = (T) infinity(); + right = (T) -infinity(); } template diff --git a/flower/interval.cc b/flower/interval.cc new file mode 100644 index 0000000000..1db78d8dbf --- /dev/null +++ b/flower/interval.cc @@ -0,0 +1,19 @@ +/* + interval.cc -- instantiate Interval_t + + source file of the Flower Library + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "interval.hh" +#include "real.hh" +#include "interval.tcc" + +Interval__instantiate(Real); + +Real +Interval_t::infinity() +{ + return HUGE; +} diff --git a/lily/include/dynamic-reg.hh b/lily/include/dynamic-reg.hh index b0f8b1a437..c56805d07d 100644 --- a/lily/include/dynamic-reg.hh +++ b/lily/include/dynamic-reg.hh @@ -31,7 +31,7 @@ protected: virtual void pre_move_processing(); virtual void post_move_processing(); virtual bool acceptable_request_b(Request*) const; - virtual void set_feature(Features); + virtual void set_feature(Feature); }; #endif // DYNAMIC_REG_HH diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh index abe556db86..3864ace146 100644 --- a/lily/include/lily-proto.hh +++ b/lily/include/lily-proto.hh @@ -27,6 +27,7 @@ struct Decresc_req; struct Durational_req; struct Dynamic_req; struct Group_change_req; +struct Feature; struct Group_feature_req; struct Key_change_req; struct Lyric_req; @@ -35,6 +36,8 @@ struct Measure_grouping_req; struct Meter_change_req; struct Musical_req; struct Command_req; +struct Collision_register; +struct Collision; struct Note_req; struct Plet_req; struct Partial_measure_req; diff --git a/lily/include/register-group.hh b/lily/include/register-group.hh index 7af00f6505..cccafc4804 100644 --- a/lily/include/register-group.hh +++ b/lily/include/register-group.hh @@ -39,7 +39,7 @@ public: Remove #reg_l# from the list, and return it. */ Request_register * get_register_p(Request_register*reg_l); - virtual void set_feature(Features i); + virtual void set_feature(Feature i); virtual bool acceptable_request_b(Request*)const; virtual void pre_move_processing(); virtual void post_move_processing(); diff --git a/lily/include/register.hh b/lily/include/register.hh index 3978c79727..6d62b74c61 100644 --- a/lily/include/register.hh +++ b/lily/include/register.hh @@ -80,9 +80,9 @@ protected: */ virtual void announce_element(Staff_elem_info); /** - Set features of the register(s). Default: ignore features. + Set Feature of the register(s). Default: ignore Feature. */ - virtual void set_feature(Features){} + virtual void set_feature(Feature){} /** Does this equal or contain a certain register? */ diff --git a/lily/include/stem-beam-reg.hh b/lily/include/stem-beam-reg.hh index dddba269a4..9c64765807 100644 --- a/lily/include/stem-beam-reg.hh +++ b/lily/include/stem-beam-reg.hh @@ -22,7 +22,7 @@ struct Stem_beam_register : Request_register { /* *************** */ Stem_beam_register(); ~Stem_beam_register(); - virtual void set_feature(Features dir_i_); + virtual void set_feature(Feature dir_i_); virtual bool try_request(Request*); virtual void process_requests(); virtual void acknowledge_element(Staff_elem_info); diff --git a/lily/include/text-reg.hh b/lily/include/text-reg.hh index db668dd44f..f3544b3ec7 100644 --- a/lily/include/text-reg.hh +++ b/lily/include/text-reg.hh @@ -15,7 +15,7 @@ class Text_register : public Request_register{ int dir_i_; /* *************** */ protected: - virtual void set_feature(Features ); + virtual void set_feature(Feature ); virtual bool try_request(Request*); virtual void process_requests(); virtual void pre_move_processing(); diff --git a/lily/register-group.cc b/lily/register-group.cc index 9400bbc87a..611ac59b75 100644 --- a/lily/register-group.cc +++ b/lily/register-group.cc @@ -22,7 +22,7 @@ Register_group_register::acceptable_request_b(Request* r)const } void -Register_group_register::set_feature(Features d) +Register_group_register::set_feature(Feature d) { for (iter_top(reg_list_, i); i.ok(); i++) { i->set_feature(d); diff --git a/lily/script-reg.cc b/lily/script-reg.cc index 5fd12bc9f6..67ab628183 100644 --- a/lily/script-reg.cc +++ b/lily/script-reg.cc @@ -81,11 +81,5 @@ Script_register::post_move_processing() script_req_l_arr_.set_size(0); } -void -Script_register::set_feature(Features ) -{ -// if (i.direction_i_|| i.initialiser_b_) - //dir_i_ = i.direction_i_; -} IMPLEMENT_STATIC_NAME(Script_register); ADD_THIS_REGISTER(Script_register); diff --git a/lily/staff-elem-info.cc b/lily/staff-elem-info.cc index c046558492..0bef384db6 100644 --- a/lily/staff-elem-info.cc +++ b/lily/staff-elem-info.cc @@ -24,17 +24,5 @@ Staff_elem_info::Staff_elem_info() req_l_ = 0; } -Features::Features() -{ - direction_i_ = 0; - initialiser_b_ = false; -} - -Features -Features::dir(int d) return f; -{ - f.initialiser_b_ = true; - f.direction_i_ = d; -} diff --git a/lily/template5.cc b/lily/template5.cc index a1ab7e8df3..05b842473d 100644 --- a/lily/template5.cc +++ b/lily/template5.cc @@ -1,3 +1,4 @@ +#include #include "proto.hh" #include "string.hh" #include "moment.hh" @@ -5,5 +6,23 @@ #include "interval.tcc" -Interval__instantiate(Real); Interval__instantiate(Rational); +Interval__instantiate(int); + +#ifdef AIX +const Real INFTY = 1e8; // ARGh. AIX sucks +#else +const Real INFTY = HUGE_VAL; +#endif + +Rational +Interval_t::infinity() +{ + return INFTY; +} + +int +Interval_t::infinity() +{ + return INT_MAX; +}