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