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

Adding stream output pointer to factory, now init output can be redirected...

Adding stream output pointer to factory, now init output can be redirected already during construction
parent 3a783705
......@@ -18,6 +18,7 @@
#include <VAStruct.h>
#include <string>
#include <iostream>
#ifndef VACORE_DEFAULT_CONFIGFILE
#define VACORE_DEFAULT_CONFIGFILE "\"VACore.ini\""
......@@ -33,7 +34,7 @@ namespace VACore
* @param[in] oArgs Arguments with configuration for the core
* @return Pointer to the core instance (VA interface API from VABase)
*/
VACORE_API IVAInterface* CreateCoreInstance( const CVAStruct& oArgs );
VACORE_API IVAInterface* CreateCoreInstance( const CVAStruct& oArgs, std::ostream* pOutputStream = nullptr );
//! Parses input INI configuration file and converts it into a VA core config struct
/**
......@@ -56,9 +57,9 @@ namespace VACore
*
* @sa GetCoreConfigFromFile()
*/
inline IVAInterface* CreateCoreInstance( const std::string& sConfigFile = VACORE_DEFAULT_CONFIGFILE )
inline IVAInterface* CreateCoreInstance( const std::string& sConfigFile = VACORE_DEFAULT_CONFIGFILE, std::ostream* pOutputStream = nullptr )
{
return CreateCoreInstance( VACore::LoadCoreConfigFromFile( sConfigFile ) );
return CreateCoreInstance( VACore::LoadCoreConfigFromFile( sConfigFile ), pOutputStream );
};
//! Returns the filesystem path of the VACore shared lib (e.g. VACore.dll)
......
......@@ -44,7 +44,7 @@ void CVACoreConfig::Init( const CVAStruct& oData )
conf.OptInteger( "Debug/TriggerUpdateMilliseconds", iTriggerUpdateMilliseconds, 100 );
VA_TRACE( "Config", oData );
CVAStruct oMacroStruct( conf.OptStruct( "Macros" ) );
CVAStruct::const_iterator cit = oMacroStruct.Begin();
while( cit != oMacroStruct.End() )
......@@ -60,7 +60,28 @@ void CVACoreConfig::Init( const CVAStruct& oData )
cit++;
}
CVAStruct oPathsStruct( conf.OptStruct( "Paths" ) );
std::string sWorkingDirectory = VistaFileSystemDirectory::GetCurrentWorkingDirectory();
VA_INFO( "Core", "Current working directory: '" << sWorkingDirectory << "'" );
if( oPathsStruct.HasKey( "WorkingDirectory" ) )
{
std::string sPath = oPathsStruct[ "WorkingDirectory" ];
VistaFileSystemDirectory oDir( sPath );
if( oDir.Exists() )
{
VistaFileSystemDirectory::SetCurrentWorkingDirectory( sPath );
std::string sWorkingDirectory = VistaFileSystemDirectory::GetCurrentWorkingDirectory();
VA_INFO( "Config", "Found valid working directory path entry, switching to: '" << sWorkingDirectory << "'" );
}
else
{
std::string sWorkingDirectory = VistaFileSystemDirectory::GetCurrentWorkingDirectory();
VA_WARN( "Config", "Requested working directory path '" << sPath << "' not found, will fall back to '" << sWorkingDirectory << "'" );
}
}
cit = oPathsStruct.Begin();
while( cit != oPathsStruct.End() )
{
......@@ -68,8 +89,12 @@ void CVACoreConfig::Init( const CVAStruct& oData )
const CVAStructValue& oPathValue( cit++->second );
if( oPathValue.IsString() )
{
if( toLowercase( sPathName ) == "workingdirectory" )
continue;
std::string sPath = oPathValue;
VistaFileSystemDirectory oDir( sPath );
if( oDir.Exists() )
{
vsSearchPaths.push_back( sPath );
......@@ -78,7 +103,7 @@ void CVACoreConfig::Init( const CVAStruct& oData )
}
else
{
VA_VERBOSE( "Config", "Could not find path '" + sPath + "', removed from search path list." );
VA_INFO( "Config", "Could not find path '" + sPath + "', removed from search path list." );
}
}
else
......@@ -87,7 +112,7 @@ void CVACoreConfig::Init( const CVAStruct& oData )
}
}
oAudioDriverConfig.Init( conf.OptStruct("Audio driver") );
oAudioDriverConfig.Init( conf.OptStruct( "Audio driver" ) );
oHardwareSetup.Init( oData );
......
......@@ -179,10 +179,10 @@ catch( ... ) { throw getDefaultUnexpectedVAException(); } \
} catch( ... ) { throw; }
IVAInterface* VACore::CreateCoreInstance( const CVAStruct& oArgs )
IVAInterface* VACore::CreateCoreInstance( const CVAStruct& oArgs, std::ostream* pOutputStream )
{
VA_TRACE( "Config", oArgs );
return new CVACoreImpl( oArgs );
return new CVACoreImpl( oArgs, pOutputStream );
}
void VACore::StoreCoreConfigToFile( const CVAStruct& oConfig, const std::string& sConfigFilePath )
......@@ -197,7 +197,7 @@ CVAStruct VACore::LoadCoreConfigFromFile( const std::string& sConfigFilePath )
std::vector< VistaFileSystemDirectory > voIncludePaths;
voConfigFiles.push_back( VistaFileSystemFile( sConfigFilePath ) );
VA_PRINT( "VA working directory: '" << VistaFileSystemDirectory::GetCurrentWorkingDirectory() << "'" );
VA_INFO( "Core", "Working directory: '" << VistaFileSystemDirectory::GetCurrentWorkingDirectory() << "'" );
while( voConfigFiles.empty() == false )
{
......@@ -219,7 +219,7 @@ CVAStruct VACore::LoadCoreConfigFromFile( const std::string& sConfigFilePath )
}
if( !oCurrentConfigFile.Exists() )
{
{
VA_EXCEPT2( FILE_NOT_FOUND, "Configuration file '" + oCurrentConfigFile.GetLocalName() + "' not found, aborting." );
}
}
......@@ -278,7 +278,7 @@ std::string VACore::GetCoreLibFilePath()
#endif // WIN32
}
CVACoreImpl::CVACoreImpl( const CVAStruct& oArgs )
CVACoreImpl::CVACoreImpl( const CVAStruct& oArgs, std::ostream* pOutputStream )
: m_pAudioDriverBackend( nullptr ),
m_pGlobalSamplePool( nullptr ),
m_pGlobalSampler( nullptr ),
......@@ -317,6 +317,9 @@ CVACoreImpl::CVACoreImpl( const CVAStruct& oArgs )
{
VA_NO_REENTRANCE;
if( pOutputStream )
SetOutputStream( pOutputStream );
VA_TRY
{
// read configuration
......
......@@ -57,10 +57,10 @@ class ITAStreamPatchbay;
class CVACoreImpl : public IVAInterface, public CVAObject, public VistaTicker::AfterPulseFunctor
{
public:
CVACoreImpl( const CVAStruct& oArgs );
CVACoreImpl( const CVAStruct& oArgs, std::ostream* pos );
virtual ~CVACoreImpl();
void SetOutputStream( std::ostream* posDebug );
void SetOutputStream( std::ostream* pos );
void GetVersionInfo( CVAVersionInfo* ) const;
int GetState() const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment