00001 #include <pthread.h>
00002
00003 #include "FCam/Shot.h"
00004 #include "FCam/Action.h"
00005 #include "FCam/Sensor.h"
00006
00007 #include "Debug.h"
00008
00009
00010 namespace FCam {
00011
00012 pthread_mutex_t Shot::_idLock = PTHREAD_MUTEX_INITIALIZER;
00013 int Shot::_id = 0;
00014
00015 Shot::Shot(): exposure(0), frameTime(0), gain(0), whiteBalance(5000) {
00016 pthread_mutex_lock(&_idLock);
00017 id = ++_id;
00018 pthread_mutex_unlock(&_idLock);
00019
00020
00021 wanted = true;
00022
00023 };
00024
00025 Shot::~Shot() {
00026 clearActions();
00027 }
00028
00029 void Shot::clearActions() {
00030 for (std::set<Action*>::iterator i = _actions.begin();
00031 i != _actions.end(); i++) {
00032 delete *i;
00033 }
00034 _actions.clear();
00035 }
00036
00037 void Shot::addAction(const Action &action) {
00038 _actions.insert(action.copy());
00039 }
00040
00041 Shot::Shot(const Shot &other) :
00042 image(other.image),
00043 exposure(other.exposure),
00044 frameTime(other.frameTime),
00045 gain(other.gain),
00046 whiteBalance(other.whiteBalance),
00047 histogram(other.histogram),
00048 sharpness(other.sharpness),
00049 wanted(other.wanted) {
00050
00051 pthread_mutex_lock(&_idLock);
00052 id = ++_id;
00053 pthread_mutex_unlock(&_idLock);
00054
00055 clearActions();
00056
00057 for (std::set<Action*>::iterator i = other._actions.begin();
00058 i != other._actions.end(); i++) {
00059 Action *a = (*i)->copy();
00060 _actions.insert(a);
00061 }
00062 };
00063
00064 const Shot &Shot::operator=(const Shot &other) {
00065 clearActions();
00066
00067 for (std::set<Action*>::iterator i = other._actions.begin();
00068 i != other._actions.end(); i++) {
00069 Action *a = (*i)->copy();
00070 _actions.insert(a);
00071 }
00072
00073 pthread_mutex_lock(&_idLock);
00074 id = ++_id;
00075 pthread_mutex_unlock(&_idLock);
00076
00077 exposure = other.exposure;
00078 frameTime = other.frameTime;
00079 whiteBalance = other.whiteBalance;
00080 gain = other.gain;
00081 histogram = other.histogram;
00082 sharpness = other.sharpness;
00083 image = other.image;
00084 wanted = other.wanted;
00085
00086 return *this;
00087 }
00088 };