2010-11-12 16:16:22 +01:00
|
|
|
#include "Buffers.h"
|
|
|
|
|
|
|
|
Buffers::Buffers()
|
|
|
|
{
|
2010-11-12 21:37:12 +01:00
|
|
|
id = "";
|
2010-11-12 16:16:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Buffers::Buffers(int _bufnum)
|
|
|
|
{
|
2010-11-12 21:37:12 +01:00
|
|
|
id = "";
|
2010-11-12 16:16:22 +01:00
|
|
|
for( int i = 0; i < _bufnum; i++)
|
|
|
|
add();
|
|
|
|
}
|
|
|
|
|
|
|
|
Buffers::~Buffers()
|
|
|
|
{
|
|
|
|
Glib::Mutex::Lock lock(mutex_);
|
|
|
|
buffers.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
Buffer* Buffers::get(int index)
|
|
|
|
{
|
|
|
|
Glib::Mutex::Lock lock(mutex_);
|
|
|
|
return buffers[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
void Buffers::add()
|
|
|
|
{
|
|
|
|
Glib::Mutex::Lock lock(mutex_);
|
2010-11-12 21:37:12 +01:00
|
|
|
id += "1";
|
|
|
|
buffers.push_back( new Buffer( id ) );
|
2010-11-12 16:16:22 +01:00
|
|
|
}
|
|
|
|
|
2010-11-12 21:37:12 +01:00
|
|
|
void Buffers::remove(std::string _id)
|
2010-11-12 16:16:22 +01:00
|
|
|
{
|
|
|
|
Glib::Mutex::Lock lock(mutex_);
|
|
|
|
int size = buffers.size();
|
|
|
|
for( int i = 0; i < size; i++ )
|
|
|
|
{
|
|
|
|
if( buffers[i]->get_id() == _id )
|
|
|
|
buffers.erase( buffers.begin()+i );
|
|
|
|
}
|
|
|
|
}
|