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:
43  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  void CloneReset() override;
54 
59  PlistInterface *GetPlistInterface() override { return vrv_cast<PlistInterface *>(this); }
60  const PlistInterface *GetPlistInterface() const override { return vrv_cast<const PlistInterface *>(this); }
61  TimePointInterface *GetTimePointInterface() override { return vrv_cast<TimePointInterface *>(this); }
62  const TimePointInterface *GetTimePointInterface() const override
63  {
64  return vrv_cast<const TimePointInterface *>(this);
65  }
66  TimeSpanningInterface *GetTimeSpanningInterface() override { return vrv_cast<TimeSpanningInterface *>(this); }
67  const TimeSpanningInterface *GetTimeSpanningInterface() const override
68  {
69  return vrv_cast<const TimeSpanningInterface *>(this);
70  }
72 
77  void InitBeamSegments();
78  void ClearBeamSegments();
80 
85  BeamSpanSegment *GetSegment(int index) { return m_beamSegments.at(index); }
86  const BeamSpanSegment *GetSegment(int index) const { return m_beamSegments.at(index); }
87  BeamSpanSegment *GetSegmentForSystem(const System *system);
88  const BeamSpanSegment *GetSegmentForSystem(const System *system) const;
90 
95  const ArrayOfObjects &GetBeamedElements() const { return m_beamedElements; }
96  void ResetBeamedElements() { m_beamedElements.clear(); }
97  void SetBeamedElements(const ArrayOfObjects &beamedElements) { m_beamedElements = beamedElements; }
99 
104  using SpanIndexVector = std::vector<std::pair<vrv::ArrayOfObjects::const_iterator, Object *>>;
105  bool AddSpanningSegment(const Doc *doc, const SpanIndexVector &elements, int index, bool newSegment = true);
107 
108  //----------//
109  // Functors //
110  //----------//
111 
116  FunctorCode Accept(Functor &functor) override;
117  FunctorCode Accept(ConstFunctor &functor) const override;
118  FunctorCode AcceptEnd(Functor &functor) override;
119  FunctorCode AcceptEnd(ConstFunctor &functor) const override;
121 
122 private:
123  //
124 public:
125  //
126 private:
130  std::vector<BeamSpanSegment *> m_beamSegments;
134  ArrayOfObjects m_beamedElements;
135 };
136 
137 } // namespace vrv
138 
139 #endif //__VRV_BEAMSPAN_H__
This class is an interface for MEI beam elements (beam, beamSpan).
Definition: drawinginterface.h:98
This class models the MEI <beamSpan> element.
Definition: beamspan.h:36
const ArrayOfObjects & GetBeamedElements() const
Getter and setter for the beamed elements.
Definition: beamspan.h:95
Object * Clone() const override
Method call for copying child classes.
Definition: beamspan.h:45
void CloneReset() override
Overriding CloneReset() method to be called after copy / assignment calls.
FunctorCode Accept(Functor &functor) override
Interface for class functor visitation.
std::vector< std::pair< vrv::ArrayOfObjects::const_iterator, Object * > > SpanIndexVector
Break one big spanning beamSpan into smaller beamSpans.
Definition: beamspan.h:104
BeamSpanSegment * GetSegment(int index)
Access the beam segments.
Definition: beamspan.h:85
Definition: beam.h:225
This abstract class is the base class for all const functors.
Definition: functor.h:126
This class represents elements appearing within a measure.
Definition: controlelement.h:35
This class is a hold the data and corresponds to the model of a MVC design pattern.
Definition: doc.h:41
This abstract class is the base class for all mutable functors.
Definition: functor.h:101
This class represents a basic object.
Definition: object.h:64
This class is an interface for elements having a single time point, such as tempo,...
Definition: plistinterface.h:29
This class is an interface for spanning elements, such as slur, hairpin, etc.
Definition: timeinterface.h:145