Coverage Report

Created: 2026-04-29 07:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/assimp/contrib/Open3DGC/o3dgcFIFO.h
Line
Count
Source
1
/*
2
Copyright (c) 2013 Khaled Mammou - Advanced Micro Devices, Inc.
3
4
Permission is hereby granted, free of charge, to any person obtaining a copy
5
of this software and associated documentation files (the "Software"), to deal
6
in the Software without restriction, including without limitation the rights
7
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
copies of the Software, and to permit persons to whom the Software is
9
furnished to do so, subject to the following conditions:
10
11
The above copyright notice and this permission notice shall be included in
12
all copies or substantial portions of the Software.
13
14
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
THE SOFTWARE.
21
*/
22
23
24
#pragma once
25
#ifndef O3DGC_FIFO_H
26
#define O3DGC_FIFO_H
27
28
#include "o3dgcCommon.h"
29
30
namespace o3dgc
31
{
32
    //! 
33
    template < typename T > class FIFO
34
    {
35
    public:
36
        //! Constructor.
37
                                FIFO()
38
0
                                {
39
0
                                    m_buffer    = 0;
40
0
                                    m_allocated = 0;
41
0
                                    m_size      = 0;
42
0
                                    m_start     = 0;
43
0
                                    m_end       = 0;
44
0
                                };
45
        //! Destructor.
46
                                ~FIFO(void)
47
0
                                {
48
0
                                    delete [] m_buffer;
49
0
                                };
50
        O3DGCErrorCode          Allocate(unsigned long size)
51
0
                                {
52
0
                                    assert(size > 0);
53
0
                                    if (size > m_allocated)
54
0
                                    {
55
0
                                        delete [] m_buffer;
56
0
                                        m_allocated = size;
57
0
                                        m_buffer = new T [m_allocated];
58
0
                                    }
59
0
                                    Clear();
60
0
                                    return O3DGC_OK;
61
0
                                }
62
        const T &               PopFirst()
63
0
                                {
64
0
                                    assert(m_size > 0);
65
0
                                    --m_size;
66
0
                                    unsigned long current = m_start++;
67
0
                                    if (m_start == m_allocated) 
68
0
                                    {
69
0
                                        m_end = 0;
70
0
                                    }
71
0
                                    return m_buffer[current];
72
0
                                };
73
        void                    PushBack(const T & value)
74
0
                                {
75
0
                                    assert( m_size < m_allocated);
76
0
                                    m_buffer[m_end] = value;
77
0
                                    ++m_size;
78
0
                                    ++m_end;
79
0
                                    if (m_end == m_allocated) 
80
0
                                    {
81
0
                                        m_end = 0;
82
0
                                    }
83
0
                                }
84
0
        unsigned long           GetSize()          const { return m_size;};
85
        unsigned long           GetAllocatedSize() const { return m_allocated;};
86
0
        void                    Clear() { m_start = m_end = m_size = 0;};
87
88
    private:
89
        T *                     m_buffer;
90
        unsigned long           m_allocated;
91
        unsigned long           m_size;
92
        unsigned long           m_start;
93
        unsigned long           m_end;
94
    };
95
}
96
#endif // O3DGC_FIFO_H
97