JD2022-TU1/main/extern/Soundwich/Solution/Engine/Src/Connection.cpp

69 lines
1.8 KiB
C++

#include "Component.h"
#include "Connection.h"
#include "EngineImpl.h"
void Soundwich::Connection::Serialize( Util::BinaryWriter& writer )
{
writer.Write< Util::String >( _from->GetName( ) );
writer.Write< int32 >( _out );
writer.Write< Util::String >( _to->GetName( ) );
writer.Write< int32 >( _in );
}
bool Soundwich::Connection::Deserialize( Util::BinaryReader& reader )
{
Util::String name;
bool success = true;
success &= reader.Read< Util::String >( name );
success &= GetSynth( )->GetComponents( ).TryGetValue( name, _from );
success &= reader.Read< int32 >( _out );
success &= reader.Read< Util::String >( name );
success &= GetSynth( )->GetComponents( ).TryGetValue( name, _to );
success &= reader.Read< int32 >( _in );
success &= Init( );
return success;
}
void Soundwich::Connection::Serialize( Util::XmlWriter& writer )
{
writer.WriteAttribute( "ComponentOut", _from->GetName( ) );
writer.WriteAttribute( "PinOut", _out );
writer.WriteAttribute( "ComponentIn", _to->GetName( ) );
writer.WriteAttribute( "PinIn", _in );
}
bool Soundwich::Connection::Deserialize( Util::XmlReader& reader )
{
Util::String name;
bool success = true;
success &= reader.ReadAttribute< Util::String >( "ComponentOut", name );
success &= GetSynth( )->GetComponents( ).TryGetValue( name, _from );
success &= reader.ReadAttribute< int32 >( "PinOut", _out );
success &= reader.ReadAttribute< Util::String >( "ComponentIn", name );
success &= GetSynth( )->GetComponents( ).TryGetValue( name, _to );
success &= reader.ReadAttribute< int32 >( "PinIn", _in );
success &= Init( );
return success;
}
Util::TextWriter& Soundwich::Connection::GetLog( )
{
return GetEngine( )->GetLog( );
}