Beatmup
Beatmup::Fragments::FragmentPtr Struct Reference

Pointer to a Fragment. More...

#include <fragment.h>

Public Member Functions

void operator= (const FragmentPtr &)
 
 FragmentPtr ()
 Initialize to null. More...
 
 FragmentPtr (Fragment &fragment, int offset, int length)
 
 FragmentPtr (const FragmentPtr &)
 
 FragmentPtr (FragmentPtr &&)
 
 ~FragmentPtr ()
 
void editData ()
 
bool isNull () const
 
void nullify ()
 

Public Attributes

Fragmentfragment
 
int offset
 offset in samples inside the fragment since its beginning More...
 
int length
 number of samples to use from the fragment More...
 

Detailed Description

Pointer to a Fragment.

Handles reference counting of the pointer Fragment.

Definition at line 67 of file fragment.h.

Constructor & Destructor Documentation

◆ FragmentPtr() [1/4]

FragmentPtr::FragmentPtr ( )

Initialize to null.

Definition at line 71 of file fragment.cpp.

71  {
72  fragment = NULL;
73  offset = length = 0;
74 }
int offset
offset in samples inside the fragment since its beginning
Definition: fragment.h:70
int length
number of samples to use from the fragment
Definition: fragment.h:71

◆ FragmentPtr() [2/4]

FragmentPtr::FragmentPtr ( Fragment fragment,
int  offset,
int  length 
)

Definition at line 78 of file fragment.cpp.

78  :
80 {
81  fragment.use();
82 }
Fragment * use()
References the frame when it is used one more time.
Definition: fragment.cpp:39

◆ FragmentPtr() [3/4]

FragmentPtr::FragmentPtr ( const FragmentPtr src)

Definition at line 85 of file fragment.cpp.

85  {
86  if (src.isNull()) {
87  fragment = NULL;
88  offset = length = 0;
89  }
90  else {
91  fragment = src.fragment->use();
92  offset = src.offset;
93  length = src.length;
94  }
95 }
return(jlong) new Beatmup jlong jstring src

◆ FragmentPtr() [4/4]

FragmentPtr::FragmentPtr ( FragmentPtr &&  src)

Definition at line 98 of file fragment.cpp.

98  {
99  fragment = src.fragment;
100  offset = src.offset;
101  length = src.length;
102  // nullifying source
103  src.fragment = NULL;
104  src.offset = src.length = 0;
105 }

◆ ~FragmentPtr()

FragmentPtr::~FragmentPtr ( )

Definition at line 108 of file fragment.cpp.

108  {
109  if (!isNull())
110  fragment->drop();
111 }
void drop()
Dereferences the frame when it is not used any more.
Definition: fragment.cpp:46

Member Function Documentation

◆ operator=()

void FragmentPtr::operator= ( const FragmentPtr src)

Definition at line 58 of file fragment.cpp.

58  {
59  if (!isNull())
60  fragment->drop();
61  if (src.isNull())
62  nullify();
63  else {
64  fragment = src.fragment->use();
65  offset = src.offset;
66  length = src.length;
67  }
68 }

◆ editData()

void FragmentPtr::editData ( )

Definition at line 114 of file fragment.cpp.

114  {
115  fragment = fragment->edit();
116  // No need to check if the fragment is cloned or not and drop the original if it is.
117  // If it is cloned, there is at least one reference to the original fragment.
118  // So no dropping, just decrease ref counter in fragment->edit().
119 }
Fragment * edit()
Enables editing of the current frame.
Definition: fragment.cpp:27

◆ isNull()

bool Beatmup::Fragments::FragmentPtr::isNull ( ) const
inline

Definition at line 85 of file fragment.h.

85 { return fragment == NULL; }

◆ nullify()

void FragmentPtr::nullify ( )

Definition at line 122 of file fragment.cpp.

122  {
123  if (!isNull())
124  fragment->drop();
125  fragment = NULL;
126  offset = length = 0;
127 }

Member Data Documentation

◆ fragment

Fragment* Beatmup::Fragments::FragmentPtr::fragment

Definition at line 69 of file fragment.h.

◆ offset

int Beatmup::Fragments::FragmentPtr::offset

offset in samples inside the fragment since its beginning

Definition at line 70 of file fragment.h.

◆ length

int Beatmup::Fragments::FragmentPtr::length

number of samples to use from the fragment

Definition at line 71 of file fragment.h.


The documentation for this struct was generated from the following files: