Commit a4091df7 authored by Serrière Guillaume's avatar Serrière Guillaume

Rename stimulation generation file.

Signed-off-by: default avatarSerrière Guillaume <guillaume.serriere@inria.fr>
parent 23fba713
#include "defines.h"
#include "file_generator_base.h"
#include <fstream>
using namespace std;
bool CCppCodeGenerator::openFile(const char* sFilename)
{
m_oFile.open(sFilename, ios::out | ios::trunc);
if(!m_oFile.is_open())
return false;
m_oFile << "#include \"toolkit/ovtk_all.h\"" << endl << endl;
m_oFile << "using namespace OpenViBE;" << endl;
m_oFile << "using namespace OpenViBE::Kernel;" << endl;
m_oFile << "using namespace OpenViBEToolkit;" << endl << endl << endl;
m_oFile << "boolean OpenViBEToolkit::initializeStimulationList(const IKernelContext& rKernelContext)" << endl;
m_oFile << "{" << endl;
m_oFile << "\tITypeManager& l_rTypeManager=rKernelContext.getTypeManager();" << endl << endl;
return true;
}
bool CCppCodeGenerator::appendStimulation(SStimulation &rStim)
{
m_oFile << "\tl_rTypeManager.registerEnumerationEntry(OV_TypeId_Stimulation, \""
<< rStim.m_sName
<< "\", "
<< rStim.m_sId
<< ");"
<< endl;
return true;
}
bool CCppCodeGenerator::closeFile(void)
{
m_oFile << endl << "\treturn true;" << endl;
m_oFile << "}" << endl;
m_oFile.close();
return true;
}
#include "defines.h"
#include "file_generator_base.h"
#include <fstream>
using namespace std;
bool CCppDefineGenerator::openFile(const char* sFilename)
{
m_oFile.open(sFilename, ios::out | ios::trunc);
if(!m_oFile.is_open())
return false;
m_oFile << "#ifndef __OpenViBEToolkit_Stimulations_Defines_H__" << endl;
m_oFile << "#define __OpenViBEToolkit_Stimulations_Defines_H__" << endl << endl;
return true;
}
bool CCppDefineGenerator::appendStimulation(SStimulation &rStim)
{
m_oFile << "#define " << rStim.m_sId << " " << rStim.m_sHexaCode << endl;
return true;
}
bool CCppDefineGenerator::closeFile(void)
{
m_oFile << endl << "#endif // __OpenViBEToolkit_Stimulations_Defines_H__" << endl;
m_oFile.close();
return true;
}
#include "ovbt_sg_defines.h"
#include "ovbt_sg_file_generator_base.h"
#include <fstream>
using namespace std;
bool CCppCodeGenerator::openFile(const char* sFilename)
{
m_oFile.open(sFilename, ios::out | ios::trunc);
if(!m_oFile.is_open())
return false;
m_oFile << "#include \"toolkit/ovtk_all.h\"" << endl << endl;
m_oFile << "using namespace OpenViBE;" << endl;
m_oFile << "using namespace OpenViBE::Kernel;" << endl;
m_oFile << "using namespace OpenViBEToolkit;" << endl << endl << endl;
m_oFile << "boolean OpenViBEToolkit::initializeStimulationList(const IKernelContext& rKernelContext)" << endl;
m_oFile << "{" << endl;
m_oFile << "\tITypeManager& l_rTypeManager=rKernelContext.getTypeManager();" << endl << endl;
return true;
}
bool CCppCodeGenerator::appendStimulation(SStimulation &rStim)
{
m_oFile << "\tl_rTypeManager.registerEnumerationEntry(OV_TypeId_Stimulation, \""
<< rStim.m_sName
<< "\", "
<< rStim.m_sId
<< ");"
<< endl;
return true;
}
bool CCppCodeGenerator::closeFile(void)
{
m_oFile << endl << "\treturn true;" << endl;
m_oFile << "}" << endl;
m_oFile.close();
return true;
}
#include "ovbt_sg_defines.h"
#include "ovbt_sg_file_generator_base.h"
#include <fstream>
using namespace std;
bool CCppDefineGenerator::openFile(const char* sFilename)
{
m_oFile.open(sFilename, ios::out | ios::trunc);
if(!m_oFile.is_open())
return false;
m_oFile << "#ifndef __OpenViBEToolkit_Stimulations_Defines_H__" << endl;
m_oFile << "#define __OpenViBEToolkit_Stimulations_Defines_H__" << endl << endl;
return true;
}
bool CCppDefineGenerator::appendStimulation(SStimulation &rStim)
{
m_oFile << "#define " << rStim.m_sId << " " << rStim.m_sHexaCode << endl;
return true;
}
bool CCppDefineGenerator::closeFile(void)
{
m_oFile << endl << "#endif // __OpenViBEToolkit_Stimulations_Defines_H__" << endl;
m_oFile.close();
return true;
}
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include "ovbt_sg_defines.h"
#include "ovbt_sg_file_generator_base.h"
using namespace std;
string getBrutHexaCode(string l_oFormatedHexaCode)
{
string res = l_oFormatedHexaCode;
res.erase(res.begin(), res.begin()+2);
return res;
}
int main (int argc, char** argv)
{
if(argc < 3)
return -1;
vector<SStimulation> l_oStimulationList;
vector<CFileGeneratorBase*> l_oGeneratorList;
ifstream l_oStimulationFile(argv[1]);
string l_sName, l_sId, l_sHexaCode;
while(l_oStimulationFile >> l_sName >> l_sId >> l_sHexaCode)
{
SStimulation l_oTemp = {l_sName, l_sId, l_sHexaCode};
l_oStimulationList.push_back(l_oTemp);
}
CFileGeneratorBase* gen = new CCppDefineGenerator();
if(!gen->openFile(argv[2]))
{
cerr << "Unable to open " << argv[2] << endl;
return -1;
}
l_oGeneratorList.push_back(gen);
gen = new CCppCodeGenerator();
if(!gen->openFile(argv[3]))
{
cerr << "Unable to open " << argv[3] << endl;
return -1;
}
l_oGeneratorList.push_back(gen);
//Now we generate all files that needs to be done
for(vector<SStimulation>::iterator it = l_oStimulationList.begin(); it != l_oStimulationList.end(); ++it)
{
SStimulation &l_oTemp = *it;
for(vector<CFileGeneratorBase*>::iterator it_gen = l_oGeneratorList.begin(); it_gen != l_oGeneratorList.end(); ++it_gen)
{
(*it_gen)->appendStimulation(l_oTemp);
}
}
for(vector<CFileGeneratorBase*>::iterator it_gen = l_oGeneratorList.begin(); it_gen != l_oGeneratorList.end(); ++it_gen)
{
(*it_gen)->closeFile();
}
return 0;
}
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include "defines.h"
#include "file_generator_base.h"
using namespace std;
string getBrutHexaCode(string l_oFormatedHexaCode)
{
string res = l_oFormatedHexaCode;
res.erase(res.begin(), res.begin()+2);
return res;
}
int main (int argc, char** argv)
{
if(argc < 3)
return -1;
vector<SStimulation> l_oStimulationList;
vector<CFileGeneratorBase*> l_oGeneratorList;
ifstream l_oStimulationFile(argv[1]);
string l_sName, l_sId, l_sHexaCode;
while(l_oStimulationFile >> l_sName >> l_sId >> l_sHexaCode)
{
SStimulation l_oTemp = {l_sName, l_sId, l_sHexaCode};
l_oStimulationList.push_back(l_oTemp);
}
CFileGeneratorBase* gen = new CCppDefineGenerator();
if(!gen->openFile(argv[2]))
{
cerr << "Unable to open " << argv[2] << endl;
}
l_oGeneratorList.push_back(gen);
gen = new CCppCodeGenerator();
if(!gen->openFile(argv[3]))
{
cerr << "Unable to open " << argv[3] << endl;
}
l_oGeneratorList.push_back(gen);
//Now we generate all files that needs to be done
for(vector<SStimulation>::iterator it = l_oStimulationList.begin(); it != l_oStimulationList.end(); ++it)
{
SStimulation &l_oTemp = *it;
//cout << l_oTemp.m_sName << "," << l_oTemp.m_sId << "," << l_oTemp.m_sHexaCode << endl;
for(vector<CFileGeneratorBase*>::iterator it_gen = l_oGeneratorList.begin(); it_gen != l_oGeneratorList.end(); ++it_gen)
{
(*it_gen)->appendStimulation(l_oTemp);
}
}
for(vector<CFileGeneratorBase*>::iterator it_gen = l_oGeneratorList.begin(); it_gen != l_oGeneratorList.end(); ++it_gen)
{
(*it_gen)->closeFile();
}
return 0;
}
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