Verovio
Source code documentation
beamspan.h
1 // Name: beamspan.h
3 // Author: Andriy Makarchuk
4 // Created: 2020
5 // Copyright (c) Authors and others. All rights reserved.
7 
8 #ifndef __VRV_BEAMSPAN_H__
9 #define __VRV_BEAMSPAN_H__
10 
11 #include "atts_cmn.h"
12 #include "beam.h"
13 #include "controlelement.h"
14 #include "drawinginterface.h"
15 #include "plistinterface.h"
16 #include "timeinterface.h"
17 
18 namespace vrv {
19 
20 class Layer;
21 class Staff;
22 class System;
23 
24 //----------------------------------------------------------------------------
25 // BeamSpan
26 //----------------------------------------------------------------------------
27 
31 class BeamSpan : public ControlElement,
32  public BeamDrawingInterface,
33  public PlistInterface,
34  public TimeSpanningInterface,
35  public AttBeamedWith,
36  public AttBeamRend {
37 public:
42  BeamSpan();
44  virtual ~BeamSpan();
45  Object *Clone() const override { return new BeamSpan(*this); }
46  void Reset() override;
47  std::string GetClassName() const override { return "beamSpan"; }
49 
53  PlistInterface *GetPlistInterface() override { return vrv_cast<PlistInterface *>(this); }
55  const PlistInterface *GetPlistInterface() const override { return vrv_cast<const PlistInterface *>(this); }
56  TimePointInterface *GetTimePointInterface() override { return vrv_cast<TimePointInterface *>(this); }
57  const TimePointInterface *GetTimePointInterface() const override
58  {
59  return vrv_cast<const TimePointInterface *>(this);
60  }
61  TimeSpanningInterface *GetTimeSpanningInterface() override { return vrv_cast<TimeSpanningInterface *>(this); }
62  const TimeSpanningInterface *GetTimeSpanningInterface() const override
63  {
64  return vrv_cast<const TimeSpanningInterface *>(this);
65  }
67 
71  void InitBeamSegments();
73  void ClearBeamSegments();
75 
79  BeamSpanSegment *GetSegment(int index) { return m_beamSegments.at(index); }
81  const BeamSpanSegment *GetSegment(int index) const { return m_beamSegments.at(index); }
82  BeamSpanSegment *GetSegmentForSystem(const System *system);
83  const BeamSpanSegment *GetSegmentForSystem(const System *system) const;
85 
89  const ArrayOfObjects &GetBeamedElements() const { return m_beamedElements; }
91  void ResetBeamedElements() { m_beamedElements.clear(); }
92  void SetBeamedElements(const ArrayOfObjects &beamedElements) { m_beamedElements = beamedElements; }
94 
98  using SpanIndexVector = std::vector<std::pair<vrv::ArrayOfObjects::const_iterator, Object *>>;
100  bool AddSpanningSegment(const Doc *doc, const SpanIndexVector &elements, int index, bool newSegment = true);
102 
103  //----------//
104  // Functors //
105  //----------//
106 
110  FunctorCode Accept(Functor &functor) override;
112  FunctorCode Accept(ConstFunctor &functor) const override;
113  FunctorCode AcceptEnd(Functor &functor) override;
114  FunctorCode AcceptEnd(ConstFunctor &functor) const override;
116 
117 private:
118  //
119 public:
120  //
121 private:
125  std::vector<BeamSpanSegment *> m_beamSegments;
129  ArrayOfObjects m_beamedElements;
130 };
131 
132 } // namespace vrv
133 
134 #endif //__VRV_BEAMSPAN_H__
vrv::BeamSpan
This class models the MEI <beamSpan> element.
Definition: beamspan.h:31
vrv::Object
This class represents a basic object.
Definition: object.h:59
vrv::BeamSpan::Clone
Object * Clone() const override
Method call for copying child classes.
Definition: beamspan.h:45
vrv::BeamSpan::GetSegment
BeamSpanSegment * GetSegment(int index)
Access the beam segments.
Definition: beamspan.h:80
vrv::BeamDrawingInterface
This class is an interface for MEI beam elements (beam, beamSpan).
Definition: drawinginterface.h:97
vrv::BeamSpan::GetBeamedElements
const ArrayOfObjects & GetBeamedElements() const
Getter and setter for the beamed elements.
Definition: beamspan.h:90
vrv::ControlElement
This class represents elements appearing within a measure.
Definition: controlelement.h:28
vrv::PlistInterface
This class is an interface for elements having a single time point, such as tempo,...
Definition: plistinterface.h:29
vrv::BeamSpan::Accept
FunctorCode Accept(Functor &functor) override
Interface for class functor visitation.
vrv::TimeSpanningInterface
This class is an interface for spanning elements, such as slur, hairpin, etc.
Definition: timeinterface.h:141
vrv::BeamSpan::SpanIndexVector
std::vector< std::pair< vrv::ArrayOfObjects::const_iterator, Object * > > SpanIndexVector
Break one big spanning beamSpan into smaller beamSpans.
Definition: beamspan.h:99