syndilights/frameserver/Buffers.cpp

44 lines
665 B
C++
Raw Normal View History

#include "Buffers.h"
Buffers::Buffers()
{
2010-11-12 21:37:12 +01:00
id = "";
}
Buffers::Buffers(int _bufnum)
{
2010-11-12 21:37:12 +01:00
id = "";
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 21:37:12 +01:00
void Buffers::remove(std::string _id)
{
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 );
}
}