Commit c587eedc authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Improving pool handling and looking for memory leak

parent 9e33ba0d
/*
*
* VVV VVV A
* VVV VVV AAA Virtual Acoustics
* VVV VVV AAA Real-time auralisation for virtual reality
* VVV VVV AAA
* VVVVVV AAA (c) Copyright Institut fr Technische Akustik (ITA)
* VVVV AAA RWTH Aachen (http://www.akustik.rwth-aachen.de)
*
* ---------------------------------------------------------------------------------
*
* Datei: VACoreDumper.h
*
* Zweck: Dumper-Klasse welche VACore-Calls als Strings ausgibt
*
* Autor(en): Frank Wefers (Frank.Wefers@akustik.rwth-aachen.de
*
* ---------------------------------------------------------------------------------
*/
// $Id: VACoreDumper.h 2729 2012-06-26 13:23:36Z fwefers $
#ifndef __VACORE_DUMPER_H__
#define __VACORE_DUMPER_H__
#include <VACoreDefinitions.h>
#include <VACore.h>
#include <iostream>
#include <string>
//! Dumper-Klasse welche Aufrufe und Ereignisse als Strings auf einem Stream ausgibt
class VACORE_API CVACoreDumper : public IVACore {
public:
CVACoreDumper(IVACore* pTarget=NULL, std::ostream* pOutputStream=&std::cout);
virtual ~CVACoreDumper();
//! Zielinstanz des Dumpers zurckgeben
IVACore* getCoreInstance() const;
//! Zielinstanz des Dumpers zurckgeben
void setCoreInstance(IVACore* pTarget);
//! Ausgabestream fr das Dump zurckgeben
std::ostream* getOutputStream() const;
//! Ausgabestream fr das Dump setzen
void setOutputStream(std::ostream* pOutputStream) const;
// --= Interface "IVACore" =--
private:
IVACore* m_pTarget;
std::ostream* m_pStream;
};
#endif // __VACORE_DUMPER_H__
......@@ -16,7 +16,6 @@
#include <VACoreDefinitions.h>
#include <VAReferenceableObject.h>
#include <VAUncopyable.h>
#include <string>
......@@ -120,95 +119,4 @@ protected:
friend class CVAPoolObject;
};
//! Pool objects base class
/**
* Pool objects are referencable and linked to a superior pool. The
* reference counter holds information on number of usages/links of
* the specific object. In case the reference counter states that
* no connections to the given object are available, it is marked
* for new usage (recycling). The object releases itself to
* the pool if no references are existent.
*/
class VACORE_API CVAPoolObject : public IVAUncopyable, public CVAReferenceableObject
{
public:
//! Redefined method to remove reference
/**
* Releases object to the pool if no reference available anymore
*/
virtual int RemoveReference() const;
protected:
//! Protected constructor [Jonas fragt Frank: so richtig?! (hinzugefgt, damit m_pParentPool auf nullptr gesetzt werden kann]
/**
* Can only be called by CVAObjectPool(), protected for users
*/
CVAPoolObject();
//! Protected destructor
/**
* Can only be called by CVAObjectPool(), protected for users
*/
virtual ~CVAPoolObject();
//! Pre request method
/**
* The PreRequest method is called before the object is used
*/
virtual void PreRequest() {};
//! Pre release method
/**
* The PreRelease method is called after the object has been released
*/
virtual void PreRelease() {};
private:
IVAObjectPool* m_pParentPool; //!< Pointer to the pool
friend class CVAObjectPool;
friend class CVALockfreeObjectPool;
};
//! Pool object factory interface
/**
* Interface for the creation of a pool object (factory method)
*/
class VACORE_API IVAPoolObjectFactory
{
public:
inline virtual ~IVAPoolObjectFactory() {};
//! Factory method (abstract)
/**
* Interface method to create a new pool object
*
* \return Pointer to the new pool object
*/
virtual CVAPoolObject* CreatePoolObject() = 0;
};
//! Default factory for pool objects with standard constructor
/**
* Pool object factory for objects using the default constructor
*/
template< class T > class CVAPoolObjectDefaultFactory : public IVAPoolObjectFactory
{
public:
//! Factory method
/**
* Creates new pool object using the standard constructor of the template object
*
* \return Pointer to the new pool object
*/
inline virtual CVAPoolObject* CreatePoolObject()
{
return new T;
}
};
#endif // IW_VACORE_OBJECT_POOL
\ No newline at end of file
/*
* --------------------------------------------------------------------------------------------
*
* VVV VVV A
* VVV VVV AAA Virtual Acoustics (VA)
* VVV VVV AAA Real-time auralisation for virtual reality
* VVV VVV AAA
* VVVVVV AAA (c) Copyright Institute of Technical Acoustics (ITA), 2015-2017
* VVVV AAA RWTH Aachen University (http://www.akustik.rwth-aachen.de)
*
* --------------------------------------------------------------------------------------------
*/
#ifndef IW_VA_POOL_OBJECT
#define IW_VA_POOL_OBJECT
#include <VACoreDefinitions.h>
#include <VAReferenceableObject.h>
#include <VAUncopyable.h>
class IVAObjectPool;
//! Pool objects base class
/**
* Pool objects are referencable and linked to a superior pool. The
* reference counter holds information on number of usages/links of
* the specific object. In case the reference counter states that
* no connections to the given object are available, it is marked
* for new usage (recycling). The object releases itself to
* the pool if no references are existent.
*/
class VACORE_API CVAPoolObject : public IVAUncopyable, public CVAReferenceableObject
{
public:
//! Redefined method to remove reference
/**
* Releases object to the pool if no reference available anymore
*/
virtual int RemoveReference() const;
protected:
//! Protected constructor [Jonas fragt Frank: so richtig?! (hinzugefgt, damit m_pParentPool auf nullptr gesetzt werden kann]
/**
* Can only be called by CVAObjectPool(), protected for users
*/
CVAPoolObject();
//! Protected destructor
/**
* Can only be called by CVAObjectPool(), protected for users
*/
virtual ~CVAPoolObject();
//! Pre request method
/**
* The PreRequest method is called before the object is used
*/
virtual inline void PreRequest() {};
//! Pre release method
/**
* The PreRelease method is called after the object has been released
*/
virtual inline void PreRelease() {};
private:
IVAObjectPool* m_pParentPool; //!< Pointer to the pool
friend class CVAObjectPool;
friend class CVALockfreeObjectPool;
};
//! Pool object factory interface
/**
* Interface for the creation of a pool object (factory method)
*/
class VACORE_API IVAPoolObjectFactory
{
public:
inline virtual ~IVAPoolObjectFactory() {};
//! Factory method (abstract)
/**
* Interface method to create a new pool object
*
* \return Pointer to the new pool object
*/
virtual CVAPoolObject* CreatePoolObject() = 0;
};
//! Default factory for pool objects with standard constructor
/**
* Pool object factory for objects using the default constructor
*/
template< class T > class CVAPoolObjectDefaultFactory : public IVAPoolObjectFactory
{
public:
//! Factory method
/**
* Creates new pool object using the standard constructor of the template object
*
* \return Pointer to the new pool object
*/
inline virtual CVAPoolObject* CreatePoolObject()
{
return new T;
}
};
#endif // IW_VA_POOL_OBJECT
......@@ -5,10 +5,10 @@ set( RelativeSourceGroup "include" )
set( DirFiles
VACoreDefinitions.h
#VACoreDumper.h
VACoreFactory.h
VANetworkStreamAudioSignalSource.h
VAObjectPool.h
VAPoolObject.h
VAReferenceableObject.h
VAUncopyable.h
_SourceFiles.cmake
......
This diff is collapsed.
......@@ -2,14 +2,14 @@
*
* VVV VVV A
* VVV VVV AAA Virtual Acoustics
* VVV VVV AAA Real-time auralisation for virtual reality
* VVV VVV AAA Real-time auralisation for virtual reality
* VVV VVV AAA
* VVVVVV AAA (c) Copyright Institut fr Technische Akustik (ITA)
* VVVV AAA RWTH Aachen (http://www.akustik.rwth-aachen.de)
*
* ---------------------------------------------------------------------------------
*
* Datei: VASceneManager.h
* Datei: VASceneManager.h
*
* Zweck: Zentrale Klasse zur Szenenverwaltung
*
......@@ -17,7 +17,7 @@
*
* ---------------------------------------------------------------------------------
*/
// $Id: VASceneManager.h 4573 2016-02-22 20:51:24Z stienen $
#ifndef __VA_SCENEMANAGER_H__
......@@ -51,11 +51,12 @@ class ITAClock;
* The class provides access to the head state of the scene as well as to any other scene
* in the past using IDs. It also provides mechanism to derive a scene from a base scene.
*/
class CVASceneManager {
class CVASceneManager
{
public:
//! Constructor with high performance timer clock
CVASceneManager(ITAClock* pClock);
CVASceneManager( ITAClock* pClock );
//! Destructor
virtual ~CVASceneManager();
......@@ -67,13 +68,13 @@ public:
* \note Performs a \Reset(), too
*/
void Initialize();
//! Finalize scene manager
/**
* Delete pools for objects like sources, receivers, portals, etc.
*/
void Finalize();
//! Reset scene manager
/**
* Resets pools for objects like sources, receivers, portals, etc.
......@@ -87,32 +88,32 @@ public:
int GetHeadSceneStateID() const;
//! ID der Primrkonfiguration setzen
void SetHeadSceneState(int iSceneStateID);
void SetHeadSceneState( const int iSceneStateID );
//! Primrkonfiguration zurckgeben
CVASceneState* GetHeadSceneState() const;
//! Konfiguration einer bestimmten ID zurckgeben
CVASceneState* GetSceneState(int iSceneStateID) const;
CVASceneState* GetSceneState( const int iSceneStateID ) const;
//! Neue Konfiguration erzeugen durch Ableitung von vorhandener Konfiguration
/**
* \param iSceneStateID ID der Basisszene, von der Abgeleitet wird
//! Create a new scene state based on the state given
/**
* \param iSceneStateBaseID ID der Basisszene, von der Abgeleitet wird
* \param dModificationTime Zeitpunkt, an dem der Ableitungszustand erzeugt wird
*
*
* \note Ist die ID der Basiskonfiguration 0 => unabhngigen Zustand erzeugen
* \note Wichtig: Der Referenzzhler wird direkt auf 1 gesetzt!
*/
CVASceneState* CreateDerivedSceneState(int iSceneStateID, double dModificationTime);
CVASceneState* CreateDerivedSceneState( const int iSceneStateBaseID, const double dModificationTime );
//! Neue Konfiguration erzeugen durch Ableitung der bergebenen Konfiguration
/**
/**
* \param pBaseState Basisszene, von der Abgeleitet wird
* \param dModificationTime Zeitpunkt, an dem der Ableitungszustand erzeugt wird
*
*
* \note Wichtig: Der Referenzzhler wird direkt auf 1 gesetzt!
*/
CVASceneState* CreateDerivedSceneState(const CVASceneState* pBaseState, double dModificationTime);
CVASceneState* CreateDerivedSceneState( const CVASceneState* pBaseState, const double dModificationTime );
//! Freien Schallquellenzustand erzeugen
CVASoundSourceState* RequestSoundSourceState();
......@@ -146,26 +147,26 @@ public:
// --= Unversionierte Szenedaten =--
CVASoundSourceDesc* CreateSoundSourceDesc(int iSoundSourceID);
void DeleteSoundSourceDesc(int iSoundSourceID);
CVASoundSourceDesc* GetSoundSourceDesc(int iSoundSourceID) const;
CVASoundSourceDesc* CreateSoundSourceDesc( int iSoundSourceID );
void DeleteSoundSourceDesc( int iSoundSourceID );
CVASoundSourceDesc* GetSoundSourceDesc( int iSoundSourceID ) const;
CVAListenerDesc* CreateListenerDesc(int iListenerID);
void DeleteListenerDesc(int iListenerID);
CVAListenerDesc* GetListenerDesc(int iListenerID) const;
CVAListenerDesc* CreateListenerDesc( int iListenerID );
void DeleteListenerDesc( int iListenerID );
CVAListenerDesc* GetListenerDesc( int iListenerID ) const;
CVAPortalDesc* CreatePortalDesc(int iPortalID);
void DeletePortalDesc(int iPortalID);
CVAPortalDesc* GetPortalDesc(int iPortalID) const;
CVAPortalDesc* CreatePortalDesc( int iPortalID );
void DeletePortalDesc( int iPortalID );
CVAPortalDesc* GetPortalDesc( int iPortalID ) const;
// Getter/Setter fr die Namen der Szeneobjekte
std::string GetSoundSourceName(int iSoundSourceID) const;
void SetSoundSourceName(int iSoundSourceID, const std::string& sName);
std::string GetListenerName(int iListenerID) const;
void SetListenerName(int iListenerID, const std::string& sName);
std::string GetPortalName(int iPortalID) const;
void SetPortalName(int iPortalID, const std::string& sName);
std::string GetSoundSourceName( int iSoundSourceID ) const;
void SetSoundSourceName( int iSoundSourceID, const std::string& sName );
std::string GetListenerName( int iListenerID ) const;
void SetListenerName( int iListenerID, const std::string& sName );
std::string GetPortalName( int iPortalID ) const;
void SetPortalName( int iPortalID, const std::string& sName );
private:
typedef std::map<int, CVASceneState*> SSMap;
......@@ -180,9 +181,9 @@ private:
int m_iIDCounterListeners; //!< ID-Counter: Hrer
int m_iIDCounterPortals; //!< ID-Counter: Portale
int m_iIDCounterSurfaces; //!< ID-Counter: Oberflchen
// Schallquellen
//CVASoundSourceStateFactory* m_pFactorySS;
IVAObjectPool* m_pPoolSceneStates; //!< State-Pool: Szenen-Zustnde
IVAObjectPool* m_pPoolSourceStates; //!< State-Pool: Schallquellen-Zustnde
......@@ -194,15 +195,15 @@ private:
// --= Unversionierte Szenedaten =--
typedef std::map<int,CVASoundSourceDesc*> SourceDescMap;
typedef std::map<int, CVASoundSourceDesc*> SourceDescMap;
SourceDescMap m_mSourceDesc;
IVAObjectPool* m_pPoolSourceDesc;
typedef std::map<int,CVAListenerDesc*> ListenerDescMap;
typedef std::map<int, CVAListenerDesc*> ListenerDescMap;
ListenerDescMap m_mListenerDesc;
IVAObjectPool* m_pPoolListenerDesc;
typedef std::map<int,CVAPortalDesc*> PortalDescMap;
typedef std::map<int, CVAPortalDesc*> PortalDescMap;
PortalDescMap m_mPortalDesc;
IVAObjectPool* m_pPoolPortalDesc;
......
This diff is collapsed.
/*
*
* VVV VVV A
* VVV VVV AAA Virtual Acoustics
* VVV VVV AAA Real-time auralisation for virtual reality
* VVV VVV AAA
* VVVVVV AAA (c) Copyright Institut fr Technische Akustik (ITA)
* VVVV AAA RWTH Aachen (http://www.akustik.rwth-aachen.de)
*
* ---------------------------------------------------------------------------------
*
* Datei: VASceneState.h
*
* Zweck: Klasse Szenezustnde
*
* Autor(en): Frank Wefers (Frank.Wefers@akustik.rwth-aachen.de)
*
* ---------------------------------------------------------------------------------
*/
// $Id: VASceneState.h 4095 2015-05-06 12:30:21Z stienen $
#ifndef __VA_SCENESTATE_H__
#define __VA_SCENESTATE_H__
#ifndef IW_VA_SCENE_STATE
#define IW_VA_SCENE_STATE
#include "VASceneStateBase.h"
#include <VACore.h>
......@@ -32,7 +10,6 @@
#include <set>
#include <vector>
// Vorwrtsdeklarationen
class CVASceneStateDiff;
class CVAContainerState;
class CVASoundSourceState;
......@@ -40,45 +17,44 @@ class CVAListenerState;
class CVAPortalState;
class CVASurfaceState;
class CVASceneState : public CVASceneStateBase {
class CVASceneState : public CVASceneStateBase
{
public:
// Initialisieren (initiale, leere Szene)
void Initialize(int iSceneStateID, double dModificationTime);
//! Initialized empty scene state
void Initialize( const int iSceneStateID, const double dModificationTime );
// Daten eines anderen Zustand bernehmen (mit neuer ID)
void Copy(int iSceneStateID, double dModificationTime, const CVASceneState* pBase);
//! Copy state from other state
void Copy( const int iNewSceneStateID, const double dModificationTime, const CVASceneState* pBase );
// Gibt die Konfiguration des Zustands zurck
//! Scene state ID getter
int GetID() const;
// Fixieren
// Fixate state and make it read-only
void Fix();
// --= Schallquellen =--
// Anzahl Schallquellen zurckgeben
//! Returns number of sound sources
int GetNumSoundSources() const;
// Stellt eine Liste mit den IDs aller Schallquellen zusammen
// und speichert die im angegebenen Container
void GetSoundSourceIDs(std::vector<int>* pviDest) const;
void GetSoundSourceIDs(std::list<int>* pliDest) const;
void GetSoundSourceIDs(std::set<int>* psiDest) const;
void GetSoundSourceIDs( std::vector< int >* pviDest ) const;
void GetSoundSourceIDs( std::list< int >* pliDest ) const;
void GetSoundSourceIDs( std::set< int >* psiDest ) const;
// Zustand eines Schallquelle zurckgeben [read-only]
// (Rckgabewert: nullptr falls ungltige ID)
CVASoundSourceState* GetSoundSourceState(int iSourceID) const;
CVASoundSourceState* GetSoundSourceState( const int iSourceID ) const;
// Zustand eines Schallquelle verndern [write]
// (Hinweis: Erzeugt einen autonomen Zustand der betreffenden Schallquelle)
// (Rckgabewert: nullptr falls ungltige ID)
CVASoundSourceState* AlterSoundSourceState(int iSourceID);
CVASoundSourceState* AlterSoundSourceState( const int iSourceID );
// Neue Schallquelle hinzufgen (Rckgabe: Fehlercode, ID => okay, -1 => Fehler)
int AddSoundSource();
int AddSoundSource();
// Existierende Schallquelle entfernen (Ausnahme falls ungltige ID)
void RemoveSoundSource(int iSourceID);
void RemoveSoundSource( const int iSourceID );
// --= Hrer =--
......@@ -87,62 +63,62 @@ public:
// Stellt eine Liste mit den IDs aller Hrer zusammen
// und speichert die im angegebenen Container
void GetListenerIDs(std::vector<int>* pviDest) const;
void GetListenerIDs(std::list<int>* pliDest) const;
void GetListenerIDs(std::set<int>* psiDest) const;
void GetListenerIDs( std::vector<int>* pviDest ) const;
void GetListenerIDs( std::list<int>* pliDest ) const;
void GetListenerIDs( std::set<int>* psiDest ) const;
// Zustand eines Hrers zurckgeben [read-only]
CVAListenerState* GetListenerState(int iListenerID) const;
CVAListenerState* GetListenerState( int iListenerID ) const;
// Zustand eines Hrers verndern [write]
// (Hinweis: Erzeugt einen autonomen Zustand der betreffenden Schallquelle)
CVAListenerState* AlterListenerState(int iListenerID);
CVAListenerState* AlterListenerState( int iListenerID );
// Neuen Hrer hinzufgen (Rckgabe: Fehlercode, ID => okay, -1 => Fehler)
int AddListener();
int AddListener();
// Existierende Schallquelle entfernen (Ausnahme falls ungltige ID)
void RemoveListener(int iListenerID);
void RemoveListener( int iListenerID );
// --= Portale =--
// Stellt eine Liste mit den IDs aller Portale zusammen
// und speichert die im angegebenen Vektor
void GetPortalIDs(std::vector<int>* pviDest) const;
void GetPortalIDs(std::list<int>* pliDest) const;
void GetPortalIDs(std::set<int>* psiDest) const;
void GetPortalIDs( std::vector<int>* pviDest ) const;
void GetPortalIDs( std::list<int>* pliDest ) const;
void GetPortalIDs( std::set<int>* psiDest ) const;
// Zustand eines Portals zurckgeben [read-only]
CVAPortalState* GetPortalState(int iPortalID) const;
CVAPortalState* GetPortalState( int iPortalID ) const;
// Zustand eines Portals verndern [write]
// (Hinweis: Erzeugt einen autonomen Zustand der betreffenden Schallquelle)
CVAPortalState* AlterPortalState(int iPortalID);
CVAPortalState* AlterPortalState( int iPortalID );
// Neues Portal hinzufgen (Rckgabe: Fehlercode, ID => okay, -1 => Fehler)
int AddPortal();
int AddPortal();
// Existierende Schallquelle entfernen (Ausnahme falls ungltige ID)
void RemovePortal(int iPortalID);
void RemovePortal( int iPortalID );
// --= Oberflchen =--
// Stellt eine Liste mit den IDs aller Oberflchen zusammen
// und speichert die im angegebenen Vektor
void GetSurfaceIDs(std::vector<int>* pviDest) const;
void GetSurfaceIDs( std::vector<int>* pviDest ) const;
// Zustand einer Oberflche zurckgeben [read-only]
CVASurfaceState* GetSurfaceState(int iSurfaceID) const;
CVASurfaceState* GetSurfaceState( int iSurfaceID ) const;