• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kstars

  • sources
  • kde-4.12
  • kdeedu
  • kstars
  • kstars
  • skycomponents
starblockfactory.h
Go to the documentation of this file.
1 /***************************************************************************
2  starblockfactory.h - K Desktop Planetarium
3  -------------------
4  begin : 7 Jun 2008
5  copyright : (C) 2008 by Akarsh Simha
6  email : akarshsimha@gmail.com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef STARBLOCKFACTORY_H
19 #define STARBLOCKFACTORY_H
20 
21 #include "typedef.h"
22 #include "starblock.h"
23 
32 class StarBlockFactory {
33 
34  public:
35 
36  static StarBlockFactory *Instance();
37 
42  ~StarBlockFactory();
43 
44 
56  StarBlock *getBlock();
57 
63  bool markFirst( StarBlock *block );
64 
73  bool markNext( StarBlock *after, StarBlock *block );
74 
80  inline int getBlockCount() { return nBlocks; }
81 
86  inline int freeAll() { return deleteBlocks( nBlocks ); }
87 
92  int freeUnused();
93 
97  void printStructure();
98 
99  quint32 drawID; // A number identifying the current draw cycle
100 
101  private:
102 
107  StarBlockFactory();
108 
115  int deleteBlocks( int nblocks );
116 
117  StarBlock *first, *last; // Pointers to the beginning and end of the linked list
118  int nBlocks; // Number of blocks we currently have in the cache
119  int nCache; // Number of blocks to start recycling cached blocks at
120 
121  static StarBlockFactory *pInstance;
122 
123 };
124 
125 #endif
StarBlockFactory::drawID
quint32 drawID
Definition: starblockfactory.h:99
StarBlock
Holds a block of stars and various peripheral variables to mark its place in data structures...
Definition: starblock.h:38
StarBlockFactory::markFirst
bool markFirst(StarBlock *block)
Mark a StarBlock as most recently used and sync its drawID with the current drawID.
Definition: starblockfactory.cpp:79
typedef.h
StarBlockFactory::freeAll
int freeAll()
Frees all StarBlocks that are in the cache.
Definition: starblockfactory.h:86
starblock.h
StarBlockFactory::~StarBlockFactory
~StarBlockFactory()
Destructor Deletes the linked list that maintains the Cache, sets the pointer to NULL.
Definition: starblockfactory.cpp:43
StarBlockFactory
A factory that creates StarBlocks and recycles them in an LRU Cache.
Definition: starblockfactory.h:32
StarBlockFactory::freeUnused
int freeUnused()
Frees all StarBlocks that are not used in this draw cycle.
Definition: starblockfactory.cpp:270
StarBlockFactory::Instance
static StarBlockFactory * Instance()
Definition: starblockfactory.cpp:29
StarBlockFactory::markNext
bool markNext(StarBlock *after, StarBlock *block)
Rank a given StarBlock after another given StarBlock in the LRU list and sync its drawID with the cur...
Definition: starblockfactory.cpp:117
StarBlockFactory::getBlockCount
int getBlockCount()
Returns the number of StarBlocks currently produced.
Definition: starblockfactory.h:80
StarBlockFactory::getBlock
StarBlock * getBlock()
Return a StarBlock available for use.
Definition: starblockfactory.cpp:49
StarBlockFactory::printStructure
void printStructure()
Prints the structure of the cache, for debugging.
Definition: starblockfactory.cpp:244
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:36:21 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kstars

Skip menu "kstars"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal