Kstars

starblocklist.h
1 /*
2  SPDX-FileCopyrightText: 2008 Akarsh Simha <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "typedef.h"
10 
11 class DeepStarComponent;
12 class StarBlock;
13 
14 /**
15  * @class StarBlockList
16  * Maintains a list of StarBlocks that contain the stars lying in a single trixel.
17  * Takes care of the dynamic loading of stars
18  *
19  * @author Akarsh Simha
20  * @version 0.1
21  */
23 {
24  public:
25  /**
26  * Constructor for deep star catalogs.
27  * @param trixel The trixel ID
28  * @param parent Pointer to the parent DeepStarComponent
29  */
30  explicit StarBlockList(const Trixel &trixel, DeepStarComponent *parent = nullptr);
31 
32  /**
33  * @short Ensures that the list is loaded with stars to given magnitude limit
34  *
35  * @param maglim Magnitude limit to load stars upto
36  * @return true on success, false on failure (data file not found, bad seek etc)
37  */
38  bool fillToMag(float maglim);
39 
40  /**
41  * @short Sets the first StarBlock in the list to point to the given StarBlock
42  *
43  * This function must ideally be used only once. Also, it does not make a copy
44  * of the StarBlock supplied, but uses the pointer directly. StarBlockList will
45  * take care of deleting the StarBlock when it is destroyed
46  *
47  * @param block Pointer to the StarBlock
48  */
49  void setStaticBlock(std::shared_ptr<StarBlock> &block);
50 
51  /**
52  * @short Drops the StarBlock with the given pointer from the list
53  * @param block Pointer to the StarBlock to remove
54  * @return Number of entries removed from the QList
55  */
57 
58  /**
59  * @short Returns the i-th block in this StarBlockList
60  *
61  * @param i Index of the required block
62  * @return The StarBlock requested for, nullptr if index out of bounds
63  */
64  inline std::shared_ptr<StarBlock> block(unsigned int i) { return ((i < nBlocks) ? blocks[i] : std::shared_ptr<StarBlock>()); }
65 
66  /**
67  * @return a const reference to the contents of this StarBlockList
68  */
69  inline const QList<std::shared_ptr<StarBlock>> &contents() const { return blocks; }
70 
71  /**
72  * @short Returns the total number of stars in this StarBlockList
73  * @return Total number of stars in this StarBlockList
74  */
75  inline long getStarCount() const { return nStars; }
76 
77  /**
78  * @short Returns the total number of blocks in theis StarBlockList
79  * @return Number of blocks in this StarBlockList
80  */
81  inline int getBlockCount() const { return nBlocks; }
82 
83  /**
84  * @short Returns the magnitude of the faintest star currently stored
85  * @return Magnitude of faintest star stored in this StarBlockList
86  */
87  inline float getFaintMag() const { return faintMag; }
88 
89  /**
90  * @short Returns the trixel that this SBL is meant for
91  * @return The value of trixel
92  */
93  inline Trixel getTrixel() const { return trixel; }
94 
95  private:
96  Trixel trixel;
97  unsigned long nStars { 0 };
98  long readOffset { 0 };
99  float faintMag { -5 };
101  unsigned int nBlocks { 0 };
102  bool staticStars { false };
103  DeepStarComponent *parent { nullptr };
104 };
const QList< std::shared_ptr< StarBlock > > & contents() const
Definition: starblocklist.h:69
StarBlockList(const Trixel &trixel, DeepStarComponent *parent=nullptr)
Constructor for deep star catalogs.
int releaseBlock(StarBlock *block)
Drops the StarBlock with the given pointer from the list.
void setStaticBlock(std::shared_ptr< StarBlock > &block)
Sets the first StarBlock in the list to point to the given StarBlock.
long getStarCount() const
Returns the total number of stars in this StarBlockList.
Definition: starblocklist.h:75
Trixel getTrixel() const
Returns the trixel that this SBL is meant for.
Definition: starblocklist.h:93
std::shared_ptr< StarBlock > block(unsigned int i)
Returns the i-th block in this StarBlockList.
Definition: starblocklist.h:64
float getFaintMag() const
Returns the magnitude of the faintest star currently stored.
Definition: starblocklist.h:87
int getBlockCount() const
Returns the total number of blocks in theis StarBlockList.
Definition: starblocklist.h:81
bool fillToMag(float maglim)
Ensures that the list is loaded with stars to given magnitude limit.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Fri Sep 29 2023 03:56:59 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.