Working audio output from VST!
- Fix namespace clash with Value from DOSBox and Juce - Generate samples using HiOPL wrapper and convert to floating point format
This commit is contained in:
parent
d7e1629618
commit
f160931d6f
7 changed files with 114 additions and 345 deletions
|
@ -1,181 +0,0 @@
|
||||||
/*
|
|
||||||
==============================================================================
|
|
||||||
|
|
||||||
This is an automatically generated GUI class created by the Introjucer!
|
|
||||||
|
|
||||||
Be careful when adding custom code to these files, as only the code within
|
|
||||||
the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
|
|
||||||
and re-saved.
|
|
||||||
|
|
||||||
Created with Introjucer version: 3.1.0
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
The Introjucer is part of the JUCE library - "Jules' Utility Class Extensions"
|
|
||||||
Copyright 2004-13 by Raw Material Software Ltd.
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
*/
|
|
||||||
|
|
||||||
//[Headers] You can add your own extra header files here...
|
|
||||||
//[/Headers]
|
|
||||||
|
|
||||||
#include "OplGui.h"
|
|
||||||
|
|
||||||
|
|
||||||
//[MiscUserDefs] You can add your own user definitions and misc code here...
|
|
||||||
//[/MiscUserDefs]
|
|
||||||
|
|
||||||
//==============================================================================
|
|
||||||
NewComponent::NewComponent ()
|
|
||||||
{
|
|
||||||
addAndMakeVisible (label = new Label ("new label",
|
|
||||||
"Carrier waveform"));
|
|
||||||
label->setFont (Font (15.00f, Font::plain));
|
|
||||||
label->setJustificationType (Justification::centredLeft);
|
|
||||||
label->setEditable (false, false, false);
|
|
||||||
label->setColour (TextEditor::textColourId, Colours::black);
|
|
||||||
label->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
|
|
||||||
|
|
||||||
addAndMakeVisible (wav_car_sin = new ToggleButton ("new toggle button"));
|
|
||||||
wav_car_sin->setButtonText ("Sine");
|
|
||||||
wav_car_sin->addListener (this);
|
|
||||||
|
|
||||||
addAndMakeVisible (toggleButton2 = new ToggleButton ("new toggle button"));
|
|
||||||
toggleButton2->setButtonText ("Half Sine");
|
|
||||||
toggleButton2->addListener (this);
|
|
||||||
|
|
||||||
addAndMakeVisible (toggleButton3 = new ToggleButton ("new toggle button"));
|
|
||||||
toggleButton3->setButtonText ("Abs Sine");
|
|
||||||
toggleButton3->addListener (this);
|
|
||||||
|
|
||||||
addAndMakeVisible (toggleButton4 = new ToggleButton ("new toggle button"));
|
|
||||||
toggleButton4->setButtonText ("Quarter Sine");
|
|
||||||
toggleButton4->addListener (this);
|
|
||||||
|
|
||||||
|
|
||||||
//[UserPreSize]
|
|
||||||
//[/UserPreSize]
|
|
||||||
|
|
||||||
setSize (600, 400);
|
|
||||||
|
|
||||||
|
|
||||||
//[Constructor] You can add your own custom stuff here..
|
|
||||||
//[/Constructor]
|
|
||||||
}
|
|
||||||
|
|
||||||
NewComponent::~NewComponent()
|
|
||||||
{
|
|
||||||
//[Destructor_pre]. You can add your own custom destruction code here..
|
|
||||||
//[/Destructor_pre]
|
|
||||||
|
|
||||||
label = nullptr;
|
|
||||||
wav_car_sin = nullptr;
|
|
||||||
toggleButton2 = nullptr;
|
|
||||||
toggleButton3 = nullptr;
|
|
||||||
toggleButton4 = nullptr;
|
|
||||||
|
|
||||||
|
|
||||||
//[Destructor]. You can add your own custom destruction code here..
|
|
||||||
//[/Destructor]
|
|
||||||
}
|
|
||||||
|
|
||||||
//==============================================================================
|
|
||||||
void NewComponent::paint (Graphics& g)
|
|
||||||
{
|
|
||||||
//[UserPrePaint] Add your own custom painting code here..
|
|
||||||
//[/UserPrePaint]
|
|
||||||
|
|
||||||
g.fillAll (Colours::white);
|
|
||||||
|
|
||||||
//[UserPaint] Add your own custom painting code here..
|
|
||||||
//[/UserPaint]
|
|
||||||
}
|
|
||||||
|
|
||||||
void NewComponent::resized()
|
|
||||||
{
|
|
||||||
label->setBounds (8, 8, 150, 24);
|
|
||||||
wav_car_sin->setBounds (152, 8, 150, 24);
|
|
||||||
toggleButton2->setBounds (152, 32, 150, 24);
|
|
||||||
toggleButton3->setBounds (152, 56, 150, 24);
|
|
||||||
toggleButton4->setBounds (152, 80, 150, 24);
|
|
||||||
//[UserResized] Add your own custom resize handling here..
|
|
||||||
//[/UserResized]
|
|
||||||
}
|
|
||||||
|
|
||||||
void NewComponent::buttonClicked (Button* buttonThatWasClicked)
|
|
||||||
{
|
|
||||||
//[UserbuttonClicked_Pre]
|
|
||||||
//[/UserbuttonClicked_Pre]
|
|
||||||
|
|
||||||
if (buttonThatWasClicked == wav_car_sin)
|
|
||||||
{
|
|
||||||
//[UserButtonCode_wav_car_sin] -- add your button handler code here..
|
|
||||||
//[/UserButtonCode_wav_car_sin]
|
|
||||||
}
|
|
||||||
else if (buttonThatWasClicked == toggleButton2)
|
|
||||||
{
|
|
||||||
//[UserButtonCode_toggleButton2] -- add your button handler code here..
|
|
||||||
//[/UserButtonCode_toggleButton2]
|
|
||||||
}
|
|
||||||
else if (buttonThatWasClicked == toggleButton3)
|
|
||||||
{
|
|
||||||
//[UserButtonCode_toggleButton3] -- add your button handler code here..
|
|
||||||
//[/UserButtonCode_toggleButton3]
|
|
||||||
}
|
|
||||||
else if (buttonThatWasClicked == toggleButton4)
|
|
||||||
{
|
|
||||||
//[UserButtonCode_toggleButton4] -- add your button handler code here..
|
|
||||||
//[/UserButtonCode_toggleButton4]
|
|
||||||
}
|
|
||||||
|
|
||||||
//[UserbuttonClicked_Post]
|
|
||||||
//[/UserbuttonClicked_Post]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
|
|
||||||
//[/MiscUserCode]
|
|
||||||
|
|
||||||
|
|
||||||
//==============================================================================
|
|
||||||
#if 0
|
|
||||||
/* -- Introjucer information section --
|
|
||||||
|
|
||||||
This is where the Introjucer stores the metadata that describe this GUI layout, so
|
|
||||||
make changes in here at your peril!
|
|
||||||
|
|
||||||
BEGIN_JUCER_METADATA
|
|
||||||
|
|
||||||
<JUCER_COMPONENT documentType="Component" className="NewComponent" componentName=""
|
|
||||||
parentClasses="public Component" constructorParams="" variableInitialisers=""
|
|
||||||
snapPixels="8" snapActive="1" snapShown="1" overlayOpacity="0.33"
|
|
||||||
fixedSize="0" initialWidth="600" initialHeight="400">
|
|
||||||
<BACKGROUND backgroundColour="ffffffff"/>
|
|
||||||
<LABEL name="new label" id="40d227ec2225494a" memberName="label" virtualName=""
|
|
||||||
explicitFocusOrder="0" pos="8 8 150 24" edTextCol="ff000000"
|
|
||||||
edBkgCol="0" labelText="Carrier waveform" editableSingleClick="0"
|
|
||||||
editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font"
|
|
||||||
fontsize="15" bold="0" italic="0" justification="33"/>
|
|
||||||
<TOGGLEBUTTON name="new toggle button" id="bfb505f78994ec5d" memberName="wav_car_sin"
|
|
||||||
virtualName="" explicitFocusOrder="0" pos="152 8 150 24" buttonText="Sine"
|
|
||||||
connectedEdges="0" needsCallback="1" radioGroupId="0" state="0"/>
|
|
||||||
<TOGGLEBUTTON name="new toggle button" id="f565d4caaf1be1c8" memberName="toggleButton2"
|
|
||||||
virtualName="" explicitFocusOrder="0" pos="152 32 150 24" buttonText="Half Sine"
|
|
||||||
connectedEdges="0" needsCallback="1" radioGroupId="0" state="0"/>
|
|
||||||
<TOGGLEBUTTON name="new toggle button" id="c8242ddebab8a74f" memberName="toggleButton3"
|
|
||||||
virtualName="" explicitFocusOrder="0" pos="152 56 150 24" buttonText="Abs Sine"
|
|
||||||
connectedEdges="0" needsCallback="1" radioGroupId="0" state="0"/>
|
|
||||||
<TOGGLEBUTTON name="new toggle button" id="86bf0db3d1bd0f34" memberName="toggleButton4"
|
|
||||||
virtualName="" explicitFocusOrder="0" pos="152 80 150 24" buttonText="Quarter Sine"
|
|
||||||
connectedEdges="0" needsCallback="1" radioGroupId="0" state="0"/>
|
|
||||||
</JUCER_COMPONENT>
|
|
||||||
|
|
||||||
END_JUCER_METADATA
|
|
||||||
*/
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//[EndFile] You can add extra defines here...
|
|
||||||
//[/EndFile]
|
|
|
@ -1,74 +0,0 @@
|
||||||
/*
|
|
||||||
==============================================================================
|
|
||||||
|
|
||||||
This is an automatically generated GUI class created by the Introjucer!
|
|
||||||
|
|
||||||
Be careful when adding custom code to these files, as only the code within
|
|
||||||
the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
|
|
||||||
and re-saved.
|
|
||||||
|
|
||||||
Created with Introjucer version: 3.1.0
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
The Introjucer is part of the JUCE library - "Jules' Utility Class Extensions"
|
|
||||||
Copyright 2004-13 by Raw Material Software Ltd.
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __JUCE_HEADER_A8B78202A92195B5__
|
|
||||||
#define __JUCE_HEADER_A8B78202A92195B5__
|
|
||||||
|
|
||||||
//[Headers] -- You can add your own extra header files here --
|
|
||||||
#include "JuceHeader.h"
|
|
||||||
//[/Headers]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==============================================================================
|
|
||||||
/**
|
|
||||||
//[Comments]
|
|
||||||
An auto-generated component, created by the Introjucer.
|
|
||||||
|
|
||||||
Describe your class and how it works here!
|
|
||||||
//[/Comments]
|
|
||||||
*/
|
|
||||||
class NewComponent : public Component,
|
|
||||||
public ButtonListener
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//==============================================================================
|
|
||||||
NewComponent ();
|
|
||||||
~NewComponent();
|
|
||||||
|
|
||||||
//==============================================================================
|
|
||||||
//[UserMethods] -- You can add your own custom methods in this section.
|
|
||||||
//[/UserMethods]
|
|
||||||
|
|
||||||
void paint (Graphics& g);
|
|
||||||
void resized();
|
|
||||||
void buttonClicked (Button* buttonThatWasClicked);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
//[UserVariables] -- You can add your own custom variables in this section.
|
|
||||||
//[/UserVariables]
|
|
||||||
|
|
||||||
//==============================================================================
|
|
||||||
ScopedPointer<Label> label;
|
|
||||||
ScopedPointer<ToggleButton> wav_car_sin;
|
|
||||||
ScopedPointer<ToggleButton> toggleButton2;
|
|
||||||
ScopedPointer<ToggleButton> toggleButton3;
|
|
||||||
ScopedPointer<ToggleButton> toggleButton4;
|
|
||||||
|
|
||||||
|
|
||||||
//==============================================================================
|
|
||||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NewComponent)
|
|
||||||
};
|
|
||||||
|
|
||||||
//[EndFile] You can add extra defines here...
|
|
||||||
//[/EndFile]
|
|
||||||
|
|
||||||
#endif // __JUCE_HEADER_A8B78202A92195B5__
|
|
|
@ -10,14 +10,12 @@
|
||||||
|
|
||||||
#include "PluginProcessor.h"
|
#include "PluginProcessor.h"
|
||||||
#include "PluginEditor.h"
|
#include "PluginEditor.h"
|
||||||
#include "hiopl.h"
|
|
||||||
|
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
JuceOplvstiAudioProcessor::JuceOplvstiAudioProcessor()
|
JuceOplvstiAudioProcessor::JuceOplvstiAudioProcessor()
|
||||||
{
|
{
|
||||||
Opl = new Hiopl(buflen);
|
Opl = new Hiopl(44100); // 1 second at 44100
|
||||||
Opl->SetSampleRate(SAMPLE_RATE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JuceOplvstiAudioProcessor::~JuceOplvstiAudioProcessor()
|
JuceOplvstiAudioProcessor::~JuceOplvstiAudioProcessor()
|
||||||
|
@ -128,8 +126,36 @@ void JuceOplvstiAudioProcessor::changeProgramName (int index, const String& newN
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
void JuceOplvstiAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
|
void JuceOplvstiAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
|
||||||
{
|
{
|
||||||
|
Opl->SetSampleRate(sampleRate);
|
||||||
// Use this method as the place to do any pre-playback
|
// Use this method as the place to do any pre-playback
|
||||||
// initialisation that you need..
|
// initialisation that you need..
|
||||||
|
|
||||||
|
Opl->_WriteReg(0x20,0x32);
|
||||||
|
Opl->_WriteReg(0x23,0x21);
|
||||||
|
Opl->_WriteReg(0x40,0x1a);
|
||||||
|
Opl->_WriteReg(0x43,0x09);
|
||||||
|
Opl->_WriteReg(0x60,0x84);
|
||||||
|
Opl->_WriteReg(0x63,0x84);
|
||||||
|
Opl->_WriteReg(0x80,0x29);
|
||||||
|
Opl->_WriteReg(0x83,0x44);
|
||||||
|
Opl->_WriteReg(0xe3,0x00);
|
||||||
|
Opl->_WriteReg(0xe0,0x02);
|
||||||
|
Opl->_WriteReg(0xc0,0x06);
|
||||||
|
Opl->_WriteReg(0xa0,0x8b);
|
||||||
|
Opl->_WriteReg(0xb0,0x26);
|
||||||
|
Opl->_WriteReg(0x21,0x32);
|
||||||
|
Opl->_WriteReg(0x24,0x21);
|
||||||
|
Opl->_WriteReg(0x41,0x1a);
|
||||||
|
Opl->_WriteReg(0x44,0x09);
|
||||||
|
Opl->_WriteReg(0x61,0x84);
|
||||||
|
Opl->_WriteReg(0x64,0x84);
|
||||||
|
Opl->_WriteReg(0x81,0x29);
|
||||||
|
Opl->_WriteReg(0x84,0x44);
|
||||||
|
Opl->_WriteReg(0xe4,0x00);
|
||||||
|
Opl->_WriteReg(0xe1,0x02);
|
||||||
|
Opl->_WriteReg(0xc1,0x06);
|
||||||
|
Opl->_WriteReg(0xa1,0x8b);
|
||||||
|
Opl->_WriteReg(0xb1,0x2a);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JuceOplvstiAudioProcessor::releaseResources()
|
void JuceOplvstiAudioProcessor::releaseResources()
|
||||||
|
@ -140,22 +166,8 @@ void JuceOplvstiAudioProcessor::releaseResources()
|
||||||
|
|
||||||
void JuceOplvstiAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
|
void JuceOplvstiAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
|
||||||
{
|
{
|
||||||
// This is the place where you'd normally do the guts of your plugin's
|
buffer.clear(0, 0, buffer.getNumSamples());
|
||||||
// audio processing...
|
Opl->Generate(buffer.getNumSamples(), buffer.getSampleData(0));
|
||||||
for (int channel = 0; channel < getNumInputChannels(); ++channel)
|
|
||||||
{
|
|
||||||
float* channelData = buffer.getSampleData (channel);
|
|
||||||
|
|
||||||
// ..do something to the data...
|
|
||||||
}
|
|
||||||
|
|
||||||
// In case we have more outputs than inputs, we'll clear any output
|
|
||||||
// channels that didn't contain input data, (because these aren't
|
|
||||||
// guaranteed to be empty - they may contain garbage).
|
|
||||||
for (int i = getNumInputChannels(); i < getNumOutputChannels(); ++i)
|
|
||||||
{
|
|
||||||
buffer.clear (i, 0, buffer.getNumSamples());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#define PLUGINPROCESSOR_H_INCLUDED
|
#define PLUGINPROCESSOR_H_INCLUDED
|
||||||
|
|
||||||
#include "../JuceLibraryCode/JuceHeader.h"
|
#include "../JuceLibraryCode/JuceHeader.h"
|
||||||
|
#include "hiopl.h"
|
||||||
|
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
@ -67,6 +68,8 @@ public:
|
||||||
void setStateInformation (const void* data, int sizeInBytes);
|
void setStateInformation (const void* data, int sizeInBytes);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Hiopl *Opl;
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (JuceOplvstiAudioProcessor)
|
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (JuceOplvstiAudioProcessor)
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,6 +17,14 @@ void Hiopl::Generate(int length, short* buffer) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Hiopl::Generate(int length, float* buffer) {
|
||||||
|
// This would be better done using Juce's built in audio format conversion.
|
||||||
|
adlib->Generate(length, Buf32);
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
buffer[i] = (float)(Buf32[i])/32768.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Hiopl::SetSampleRate(int hz) {
|
void Hiopl::SetSampleRate(int hz) {
|
||||||
adlib->Init(hz);
|
adlib->Init(hz);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ class Hiopl {
|
||||||
public:
|
public:
|
||||||
Hiopl(int buflen);
|
Hiopl(int buflen);
|
||||||
void Generate(int length, short* buffer);
|
void Generate(int length, short* buffer);
|
||||||
|
void Generate(int length, float* buffer);
|
||||||
void SetSampleRate(int hz);
|
void SetSampleRate(int hz);
|
||||||
void SetWaveform(int ch, int osc, Waveform wave);
|
void SetWaveform(int ch, int osc, Waveform wave);
|
||||||
Waveform GetWaveform(int ch, int osc);
|
Waveform GetWaveform(int ch, int osc);
|
||||||
|
|
142
Source/setup.h
142
Source/setup.h
|
@ -54,11 +54,11 @@ public:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Value {
|
class DbxValue {
|
||||||
/*
|
/*
|
||||||
* Multitype storage container that is aware of the currently stored type in it.
|
* Multitype storage container that is aware of the currently stored type in it.
|
||||||
* Value st = "hello";
|
* DbxValue st = "hello";
|
||||||
* Value in = 1;
|
* DbxValue in = 1;
|
||||||
* st = 12 //Exception
|
* st = 12 //Exception
|
||||||
* in = 12 //works
|
* in = 12 //works
|
||||||
*/
|
*/
|
||||||
|
@ -73,39 +73,39 @@ public:
|
||||||
enum Etype { V_NONE, V_HEX, V_BOOL, V_INT, V_STRING, V_DOUBLE,V_CURRENT} type;
|
enum Etype { V_NONE, V_HEX, V_BOOL, V_INT, V_STRING, V_DOUBLE,V_CURRENT} type;
|
||||||
|
|
||||||
/* Constructors */
|
/* Constructors */
|
||||||
Value() :_string(0), type(V_NONE) { };
|
DbxValue() :_string(0), type(V_NONE) { };
|
||||||
Value(Hex in) :_hex(in), type(V_HEX) { };
|
DbxValue(Hex in) :_hex(in), type(V_HEX) { };
|
||||||
Value(int in) :_int(in), type(V_INT) { };
|
DbxValue(int in) :_int(in), type(V_INT) { };
|
||||||
Value(bool in) :_bool(in), type(V_BOOL) { };
|
DbxValue(bool in) :_bool(in), type(V_BOOL) { };
|
||||||
Value(double in) :_double(in), type(V_DOUBLE) { };
|
DbxValue(double in) :_double(in), type(V_DOUBLE) { };
|
||||||
Value(std::string const& in) :_string(new std::string(in)),type(V_STRING) { };
|
DbxValue(std::string const& in) :_string(new std::string(in)),type(V_STRING) { };
|
||||||
Value(char const * const in) :_string(new std::string(in)),type(V_STRING) { };
|
DbxValue(char const * const in) :_string(new std::string(in)),type(V_STRING) { };
|
||||||
Value(Value const& in):_string(0) {plaincopy(in);}
|
DbxValue(DbxValue const& in):_string(0) {plaincopy(in);}
|
||||||
~Value() { destroy();};
|
~DbxValue() { destroy();};
|
||||||
Value(std::string const& in,Etype _t) :_string(0),type(V_NONE) {SetValue(in,_t);}
|
DbxValue(std::string const& in,Etype _t) :_string(0),type(V_NONE) {SetDbxValue(in,_t);}
|
||||||
|
|
||||||
/* Assigment operators */
|
/* Assigment operators */
|
||||||
Value& operator= (Hex in) throw(WrongType) { return copy(Value(in));}
|
DbxValue& operator= (Hex in) throw(WrongType) { return copy(DbxValue(in));}
|
||||||
Value& operator= (int in) throw(WrongType) { return copy(Value(in));}
|
DbxValue& operator= (int in) throw(WrongType) { return copy(DbxValue(in));}
|
||||||
Value& operator= (bool in) throw(WrongType) { return copy(Value(in));}
|
DbxValue& operator= (bool in) throw(WrongType) { return copy(DbxValue(in));}
|
||||||
Value& operator= (double in) throw(WrongType) { return copy(Value(in));}
|
DbxValue& operator= (double in) throw(WrongType) { return copy(DbxValue(in));}
|
||||||
Value& operator= (std::string const& in) throw(WrongType) { return copy(Value(in));}
|
DbxValue& operator= (std::string const& in) throw(WrongType) { return copy(DbxValue(in));}
|
||||||
Value& operator= (char const * const in) throw(WrongType) { return copy(Value(in));}
|
DbxValue& operator= (char const * const in) throw(WrongType) { return copy(DbxValue(in));}
|
||||||
Value& operator= (Value const& in) throw(WrongType) { return copy(Value(in));}
|
DbxValue& operator= (DbxValue const& in) throw(WrongType) { return copy(DbxValue(in));}
|
||||||
|
|
||||||
bool operator== (Value const & other);
|
bool operator== (DbxValue const & other);
|
||||||
operator bool () const throw(WrongType);
|
operator bool () const throw(WrongType);
|
||||||
operator Hex () const throw(WrongType);
|
operator Hex () const throw(WrongType);
|
||||||
operator int () const throw(WrongType);
|
operator int () const throw(WrongType);
|
||||||
operator double () const throw(WrongType);
|
operator double () const throw(WrongType);
|
||||||
operator char const* () const throw(WrongType);
|
operator char const* () const throw(WrongType);
|
||||||
void SetValue(std::string const& in,Etype _type = V_CURRENT) throw(WrongType);
|
void SetDbxValue(std::string const& in,Etype _type = V_CURRENT) throw(WrongType);
|
||||||
std::string ToString() const;
|
std::string ToString() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void destroy() throw();
|
void destroy() throw();
|
||||||
Value& copy(Value const& in) throw(WrongType);
|
DbxValue& copy(DbxValue const& in) throw(WrongType);
|
||||||
void plaincopy(Value const& in) throw();
|
void plaincopy(DbxValue const& in) throw();
|
||||||
void set_hex(std::string const& in);
|
void set_hex(std::string const& in);
|
||||||
void set_int(std::string const&in);
|
void set_int(std::string const&in);
|
||||||
void set_bool(std::string const& in);
|
void set_bool(std::string const& in);
|
||||||
|
@ -115,104 +115,104 @@ private:
|
||||||
|
|
||||||
class Property {
|
class Property {
|
||||||
public:
|
public:
|
||||||
struct Changeable { enum Value {Always, WhenIdle,OnlyAtStart};};
|
struct Changeable { enum DbxValue {Always, WhenIdle,OnlyAtStart};};
|
||||||
const std::string propname;
|
const std::string propname;
|
||||||
|
|
||||||
Property(std::string const& _propname, Changeable::Value when):propname(_propname),change(when) { }
|
Property(std::string const& _propname, Changeable::DbxValue when):propname(_propname),change(when) { }
|
||||||
void Set_values(const char * const * in);
|
void Set_values(const char * const * in);
|
||||||
void Set_help(std::string const& str);
|
void Set_help(std::string const& str);
|
||||||
char const* Get_help();
|
char const* Get_help();
|
||||||
virtual void SetValue(std::string const& str)=0;
|
virtual void SetDbxValue(std::string const& str)=0;
|
||||||
Value const& GetValue() const { return value;}
|
DbxValue const& GetDbxValue() const { return value;}
|
||||||
Value const& Get_Default_Value() const { return default_value; }
|
DbxValue const& Get_Default_DbxValue() const { return default_value; }
|
||||||
//CheckValue returns true if value is in suggested_values;
|
//CheckDbxValue returns true if value is in suggested_values;
|
||||||
//Type specific properties are encouraged to override this and check for type
|
//Type specific properties are encouraged to override this and check for type
|
||||||
//specific features.
|
//specific features.
|
||||||
virtual bool CheckValue(Value const& in, bool warn);
|
virtual bool CheckDbxValue(DbxValue const& in, bool warn);
|
||||||
//Set interval value to in or default if in is invalid. force always sets the value.
|
//Set interval value to in or default if in is invalid. force always sets the value.
|
||||||
void SetVal(Value const& in, bool forced,bool warn=true) {if(forced || CheckValue(in,warn)) value = in; else value = default_value;}
|
void SetVal(DbxValue const& in, bool forced,bool warn=true) {if(forced || CheckDbxValue(in,warn)) value = in; else value = default_value;}
|
||||||
virtual ~Property(){ }
|
virtual ~Property(){ }
|
||||||
virtual const std::vector<Value>& GetValues() const;
|
virtual const std::vector<DbxValue>& GetDbxValues() const;
|
||||||
Value::Etype Get_type(){return default_value.type;}
|
DbxValue::Etype Get_type(){return default_value.type;}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Value value;
|
DbxValue value;
|
||||||
std::vector<Value> suggested_values;
|
std::vector<DbxValue> suggested_values;
|
||||||
typedef std::vector<Value>::iterator iter;
|
typedef std::vector<DbxValue>::iterator iter;
|
||||||
Value default_value;
|
DbxValue default_value;
|
||||||
const Changeable::Value change;
|
const Changeable::DbxValue change;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Prop_int:public Property {
|
class Prop_int:public Property {
|
||||||
public:
|
public:
|
||||||
Prop_int(std::string const& _propname,Changeable::Value when, int _value)
|
Prop_int(std::string const& _propname,Changeable::DbxValue when, int _value)
|
||||||
:Property(_propname,when) {
|
:Property(_propname,when) {
|
||||||
default_value = value = _value;
|
default_value = value = _value;
|
||||||
min = max = -1;
|
min = max = -1;
|
||||||
}
|
}
|
||||||
Prop_int(std::string const& _propname,Changeable::Value when, int _min,int _max,int _value)
|
Prop_int(std::string const& _propname,Changeable::DbxValue when, int _min,int _max,int _value)
|
||||||
:Property(_propname,when) {
|
:Property(_propname,when) {
|
||||||
default_value = value = _value;
|
default_value = value = _value;
|
||||||
min = _min;
|
min = _min;
|
||||||
max = _max;
|
max = _max;
|
||||||
}
|
}
|
||||||
void SetMinMax(Value const& min,Value const& max) {this->min = min; this->max=max;}
|
void SetMinMax(DbxValue const& min,DbxValue const& max) {this->min = min; this->max=max;}
|
||||||
void SetValue(std::string const& in);
|
void SetDbxValue(std::string const& in);
|
||||||
~Prop_int(){ }
|
~Prop_int(){ }
|
||||||
virtual bool CheckValue(Value const& in, bool warn);
|
virtual bool CheckDbxValue(DbxValue const& in, bool warn);
|
||||||
private:
|
private:
|
||||||
Value min,max;
|
DbxValue min,max;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Prop_double:public Property {
|
class Prop_double:public Property {
|
||||||
public:
|
public:
|
||||||
Prop_double(std::string const & _propname, Changeable::Value when, double _value)
|
Prop_double(std::string const & _propname, Changeable::DbxValue when, double _value)
|
||||||
:Property(_propname,when){
|
:Property(_propname,when){
|
||||||
default_value = value = _value;
|
default_value = value = _value;
|
||||||
}
|
}
|
||||||
void SetValue(std::string const& input);
|
void SetDbxValue(std::string const& input);
|
||||||
~Prop_double(){ }
|
~Prop_double(){ }
|
||||||
};
|
};
|
||||||
|
|
||||||
class Prop_bool:public Property {
|
class Prop_bool:public Property {
|
||||||
public:
|
public:
|
||||||
Prop_bool(std::string const& _propname, Changeable::Value when, bool _value)
|
Prop_bool(std::string const& _propname, Changeable::DbxValue when, bool _value)
|
||||||
:Property(_propname,when) {
|
:Property(_propname,when) {
|
||||||
default_value = value = _value;
|
default_value = value = _value;
|
||||||
}
|
}
|
||||||
void SetValue(std::string const& in);
|
void SetDbxValue(std::string const& in);
|
||||||
~Prop_bool(){ }
|
~Prop_bool(){ }
|
||||||
};
|
};
|
||||||
|
|
||||||
class Prop_string:public Property{
|
class Prop_string:public Property{
|
||||||
public:
|
public:
|
||||||
Prop_string(std::string const& _propname, Changeable::Value when, char const * const _value)
|
Prop_string(std::string const& _propname, Changeable::DbxValue when, char const * const _value)
|
||||||
:Property(_propname,when) {
|
:Property(_propname,when) {
|
||||||
default_value = value = _value;
|
default_value = value = _value;
|
||||||
}
|
}
|
||||||
void SetValue(std::string const& in);
|
void SetDbxValue(std::string const& in);
|
||||||
virtual bool CheckValue(Value const& in, bool warn);
|
virtual bool CheckDbxValue(DbxValue const& in, bool warn);
|
||||||
~Prop_string(){ }
|
~Prop_string(){ }
|
||||||
};
|
};
|
||||||
class Prop_path:public Prop_string{
|
class Prop_path:public Prop_string{
|
||||||
public:
|
public:
|
||||||
std::string realpath;
|
std::string realpath;
|
||||||
Prop_path(std::string const& _propname, Changeable::Value when, char const * const _value)
|
Prop_path(std::string const& _propname, Changeable::DbxValue when, char const * const _value)
|
||||||
:Prop_string(_propname,when,_value) {
|
:Prop_string(_propname,when,_value) {
|
||||||
default_value = value = _value;
|
default_value = value = _value;
|
||||||
realpath = _value;
|
realpath = _value;
|
||||||
}
|
}
|
||||||
void SetValue(std::string const& in);
|
void SetDbxValue(std::string const& in);
|
||||||
~Prop_path(){ }
|
~Prop_path(){ }
|
||||||
};
|
};
|
||||||
|
|
||||||
class Prop_hex:public Property {
|
class Prop_hex:public Property {
|
||||||
public:
|
public:
|
||||||
Prop_hex(std::string const& _propname, Changeable::Value when, Hex _value)
|
Prop_hex(std::string const& _propname, Changeable::DbxValue when, Hex _value)
|
||||||
:Property(_propname,when) {
|
:Property(_propname,when) {
|
||||||
default_value = value = _value;
|
default_value = value = _value;
|
||||||
}
|
}
|
||||||
void SetValue(std::string const& in);
|
void SetDbxValue(std::string const& in);
|
||||||
~Prop_hex(){ }
|
~Prop_hex(){ }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ public:
|
||||||
void ExecuteDestroy(bool destroyall=true);
|
void ExecuteDestroy(bool destroyall=true);
|
||||||
const char* GetName() const {return sectionname.c_str();}
|
const char* GetName() const {return sectionname.c_str();}
|
||||||
|
|
||||||
virtual std::string GetPropValue(std::string const& _property) const =0;
|
virtual std::string GetPropDbxValue(std::string const& _property) const =0;
|
||||||
virtual void HandleInputline(std::string const& _line)=0;
|
virtual void HandleInputline(std::string const& _line)=0;
|
||||||
virtual void PrintData(FILE* outfile) const =0;
|
virtual void PrintData(FILE* outfile) const =0;
|
||||||
virtual ~Section() { /*Children must call executedestroy ! */}
|
virtual ~Section() { /*Children must call executedestroy ! */}
|
||||||
|
@ -258,14 +258,14 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Section_prop(std::string const& _sectionname):Section(_sectionname){}
|
Section_prop(std::string const& _sectionname):Section(_sectionname){}
|
||||||
Prop_int* Add_int(std::string const& _propname, Property::Changeable::Value when, int _value=0);
|
Prop_int* Add_int(std::string const& _propname, Property::Changeable::DbxValue when, int _value=0);
|
||||||
Prop_string* Add_string(std::string const& _propname, Property::Changeable::Value when, char const * const _value=NULL);
|
Prop_string* Add_string(std::string const& _propname, Property::Changeable::DbxValue when, char const * const _value=NULL);
|
||||||
Prop_path* Add_path(std::string const& _propname, Property::Changeable::Value when, char const * const _value=NULL);
|
Prop_path* Add_path(std::string const& _propname, Property::Changeable::DbxValue when, char const * const _value=NULL);
|
||||||
Prop_bool* Add_bool(std::string const& _propname, Property::Changeable::Value when, bool _value=false);
|
Prop_bool* Add_bool(std::string const& _propname, Property::Changeable::DbxValue when, bool _value=false);
|
||||||
Prop_hex* Add_hex(std::string const& _propname, Property::Changeable::Value when, Hex _value=0);
|
Prop_hex* Add_hex(std::string const& _propname, Property::Changeable::DbxValue when, Hex _value=0);
|
||||||
// void Add_double(char const * const _propname, double _value=0.0);
|
// void Add_double(char const * const _propname, double _value=0.0);
|
||||||
Prop_multival *Add_multi(std::string const& _propname, Property::Changeable::Value when,std::string const& sep);
|
Prop_multival *Add_multi(std::string const& _propname, Property::Changeable::DbxValue when,std::string const& sep);
|
||||||
Prop_multival_remain *Add_multiremain(std::string const& _propname, Property::Changeable::Value when,std::string const& sep);
|
Prop_multival_remain *Add_multiremain(std::string const& _propname, Property::Changeable::DbxValue when,std::string const& sep);
|
||||||
|
|
||||||
Property* Get_prop(int index);
|
Property* Get_prop(int index);
|
||||||
int Get_int(std::string const& _propname) const;
|
int Get_int(std::string const& _propname) const;
|
||||||
|
@ -278,7 +278,7 @@ public:
|
||||||
Prop_multival_remain* Get_multivalremain(std::string const& _propname) const;
|
Prop_multival_remain* Get_multivalremain(std::string const& _propname) const;
|
||||||
void HandleInputline(std::string const& gegevens);
|
void HandleInputline(std::string const& gegevens);
|
||||||
void PrintData(FILE* outfile) const;
|
void PrintData(FILE* outfile) const;
|
||||||
virtual std::string GetPropValue(std::string const& _property) const;
|
virtual std::string GetPropDbxValue(std::string const& _property) const;
|
||||||
//ExecuteDestroy should be here else the destroy functions use destroyed properties
|
//ExecuteDestroy should be here else the destroy functions use destroyed properties
|
||||||
virtual ~Section_prop();
|
virtual ~Section_prop();
|
||||||
};
|
};
|
||||||
|
@ -289,21 +289,21 @@ protected:
|
||||||
std::string seperator;
|
std::string seperator;
|
||||||
void make_default_value();
|
void make_default_value();
|
||||||
public:
|
public:
|
||||||
Prop_multival(std::string const& _propname, Changeable::Value when,std::string const& sep):Property(_propname,when), section(new Section_prop("")),seperator(sep) {
|
Prop_multival(std::string const& _propname, Changeable::DbxValue when,std::string const& sep):Property(_propname,when), section(new Section_prop("")),seperator(sep) {
|
||||||
default_value = value = "";
|
default_value = value = "";
|
||||||
}
|
}
|
||||||
Section_prop *GetSection() { return section; }
|
Section_prop *GetSection() { return section; }
|
||||||
const Section_prop *GetSection() const { return section; }
|
const Section_prop *GetSection() const { return section; }
|
||||||
virtual void SetValue(std::string const& input);
|
virtual void SetDbxValue(std::string const& input);
|
||||||
virtual const std::vector<Value>& GetValues() const;
|
virtual const std::vector<DbxValue>& GetDbxValues() const;
|
||||||
~Prop_multival() { delete section; }
|
~Prop_multival() { delete section; }
|
||||||
}; //value bevat totale string. setvalue zet elk van de sub properties en checked die.
|
}; //value bevat totale string. setvalue zet elk van de sub properties en checked die.
|
||||||
|
|
||||||
class Prop_multival_remain:public Prop_multival{
|
class Prop_multival_remain:public Prop_multival{
|
||||||
public:
|
public:
|
||||||
Prop_multival_remain(std::string const& _propname, Changeable::Value when,std::string const& sep):Prop_multival(_propname,when,sep){ }
|
Prop_multival_remain(std::string const& _propname, Changeable::DbxValue when,std::string const& sep):Prop_multival(_propname,when,sep){ }
|
||||||
|
|
||||||
virtual void SetValue(std::string const& input);
|
virtual void SetDbxValue(std::string const& input);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -313,7 +313,7 @@ public:
|
||||||
~Section_line(){ExecuteDestroy(true);}
|
~Section_line(){ExecuteDestroy(true);}
|
||||||
void HandleInputline(std::string const& gegevens);
|
void HandleInputline(std::string const& gegevens);
|
||||||
void PrintData(FILE* outfile) const;
|
void PrintData(FILE* outfile) const;
|
||||||
virtual std::string GetPropValue(std::string const& _property) const;
|
virtual std::string GetPropDbxValue(std::string const& _property) const;
|
||||||
std::string data;
|
std::string data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue