OceanObject.C
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include "OceanObject.H"
00038
00039
00040
00041 OceanObject::OceanObject()
00042 {
00043 oceanObjectMutex = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
00044 pthread_mutex_init(oceanObjectMutex,NULL);
00045
00046 itsPosition = Point3D(-1,-1,-1);
00047 itsOrientation = 0.0;
00048 itsFrequency = 0.0;
00049 itsDistance = 0.0;
00050 itsMass = 0.0;
00051 }
00052
00053
00054 OceanObject::OceanObject(OceanObjectType type)
00055 {
00056
00057 oceanObjectMutex = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
00058 pthread_mutex_init(oceanObjectMutex,NULL);
00059
00060 itsType = type;
00061 itsPosition = Point3D(-1,-1,-1);
00062 itsOrientation = 0.0;
00063 itsFrequency = 0.0;
00064 itsDistance = 0.0;
00065 itsMass = 0.0;
00066 }
00067
00068
00069
00070
00071 void OceanObject::setStatus(OceanObjectStatus s)
00072 {
00073 pthread_mutex_lock(oceanObjectMutex);
00074 itsStatus = s;
00075 pthread_mutex_unlock(oceanObjectMutex);
00076 }
00077
00078
00079 void OceanObject::setType(OceanObjectType t)
00080 {
00081 pthread_mutex_lock(oceanObjectMutex);
00082 itsType = t;
00083 pthread_mutex_unlock(oceanObjectMutex);
00084 }
00085
00086
00087 void OceanObject::setPosition(Point3D pos)
00088 {
00089 pthread_mutex_lock(oceanObjectMutex);
00090 itsPosition = pos;
00091 pthread_mutex_unlock(oceanObjectMutex);
00092 }
00093
00094
00095 void OceanObject::setOrientation(Angle ori)
00096 {
00097 pthread_mutex_lock(oceanObjectMutex);
00098 itsOrientation = ori;
00099 pthread_mutex_unlock(oceanObjectMutex);
00100 }
00101
00102
00103 void OceanObject::setFrequency(float freq)
00104 {
00105 pthread_mutex_lock(oceanObjectMutex);
00106 itsFrequency = freq;
00107 pthread_mutex_unlock(oceanObjectMutex);
00108 }
00109
00110
00111 void OceanObject::setDistance(float dist)
00112 {
00113 pthread_mutex_lock(oceanObjectMutex);
00114 itsDistance = dist;
00115 pthread_mutex_unlock(oceanObjectMutex);
00116 }
00117
00118
00119 void OceanObject::setMass(float mass)
00120 {
00121 pthread_mutex_lock(oceanObjectMutex);
00122 itsMass = mass;
00123 pthread_mutex_unlock(oceanObjectMutex);
00124 }
00125
00126
00127 void OceanObject::setId(uint id)
00128 {
00129 pthread_mutex_lock(oceanObjectMutex);
00130 itsId = id;
00131 pthread_mutex_unlock(oceanObjectMutex);
00132 }
00133
00134
00135 Point3D OceanObject::getPosition()
00136 {
00137 pthread_mutex_lock(oceanObjectMutex);
00138 Point3D p = itsPosition;
00139 pthread_mutex_unlock(oceanObjectMutex);
00140 return p;
00141 }
00142
00143
00144 rutz::shared_ptr<Point3D> OceanObject::getPositionPtr()
00145 {
00146 pthread_mutex_lock(oceanObjectMutex);
00147 rutz::shared_ptr<Point3D> p (new Point3D(itsPosition));
00148 pthread_mutex_unlock(oceanObjectMutex);
00149 return p;
00150 }
00151
00152
00153 Angle OceanObject::getOrientation()
00154 {
00155 pthread_mutex_lock(oceanObjectMutex);
00156 Angle o = itsOrientation;
00157 pthread_mutex_unlock(oceanObjectMutex);
00158 return o;
00159 }
00160
00161
00162 rutz::shared_ptr<Angle> OceanObject::getOrientationPtr()
00163 {
00164 pthread_mutex_lock(oceanObjectMutex);
00165 rutz::shared_ptr<Angle> o (new Angle(itsOrientation));
00166 pthread_mutex_unlock(oceanObjectMutex);
00167 return o;
00168 }
00169
00170
00171
00172 float OceanObject::getFrequency()
00173 {
00174 pthread_mutex_lock(oceanObjectMutex);
00175 float f = itsFrequency;
00176 pthread_mutex_unlock(oceanObjectMutex);
00177 return f;
00178 }
00179
00180
00181 float OceanObject::getDistance()
00182 {
00183 pthread_mutex_lock(oceanObjectMutex);
00184 float d = itsDistance;
00185 pthread_mutex_unlock(oceanObjectMutex);
00186 return d;
00187 }
00188
00189
00190 float OceanObject::getMass()
00191 {
00192 pthread_mutex_lock(oceanObjectMutex);
00193 float m = itsMass;
00194 pthread_mutex_unlock(oceanObjectMutex);
00195 return m;
00196 }
00197
00198
00199 uint OceanObject::getId()
00200 {
00201 pthread_mutex_lock(oceanObjectMutex);
00202 uint id = itsId;
00203 pthread_mutex_unlock(oceanObjectMutex);
00204 return id;
00205 }
00206
00207
00208 OceanObject::OceanObjectStatus OceanObject::getStatus()
00209 {
00210 pthread_mutex_lock(oceanObjectMutex);
00211 OceanObjectStatus currentStatus = itsStatus;
00212 pthread_mutex_unlock(oceanObjectMutex);
00213 return currentStatus;
00214 }
00215
00216
00217 OceanObject::OceanObjectType OceanObject::getType()
00218 {
00219 pthread_mutex_lock(oceanObjectMutex);
00220 OceanObjectType currentType = itsType;
00221 pthread_mutex_unlock(oceanObjectMutex);
00222 return currentType;
00223 }
00224
00225
00226
00227
00228
00229