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 #include "ObjectAttribute.hh"
00028 #include "RTIRegion.hh"
00029 #include "PrettyDebug.hh"
00030
00031 #include <iostream>
00032
00033 using std::cout ;
00034 using std::endl ;
00035 using std::list ;
00036
00037 namespace certi {
00038
00039 static pdCDebug D("OBJECTATTRIBUTE", "(Obj_Attr) - ");
00040
00041
00043 ObjectAttribute::ObjectAttribute(AttributeHandle new_handle,
00044 FederateHandle new_owner,
00045 ObjectClassAttribute *associated_attribute)
00046 : handle(new_handle), owner(new_owner), divesting(false), space(0),
00047 source(associated_attribute), region(0)
00048 {
00049 }
00050
00051
00053 ObjectAttribute::~ObjectAttribute()
00054 {
00055 }
00056
00057
00059 void
00060 ObjectAttribute::display() const
00061 {
00062 if (handle != 0)
00063 cout << "Attribute " << handle << " ; Owner " << owner << endl ;
00064 }
00065
00066
00068 FederateHandle
00069 ObjectAttribute::getOwner() const
00070 {
00071 return owner ;
00072 }
00073
00074
00076 void
00077 ObjectAttribute::setOwner(FederateHandle newOwner)
00078 {
00079 owner = newOwner ;
00080 }
00081
00082
00084 bool
00085 ObjectAttribute::beingDivested() const
00086 {
00087 return divesting ;
00088 }
00089
00090
00092 void
00093 ObjectAttribute::setDivesting(bool divestingState)
00094 {
00095 divesting = divestingState ;
00096 }
00097
00098
00100 int
00101 ObjectAttribute::isCandidate(FederateHandle candidate) const
00102 {
00103 list<FederateHandle>::const_iterator i = ownerCandidates.begin();
00104 for (int j = 1 ; i != ownerCandidates.end(); i++, j++) {
00105 if ((*i) == candidate)
00106 return j ;
00107 }
00108
00109 return 0 ;
00110 }
00111
00112
00114 void
00115 ObjectAttribute::addCandidate(FederateHandle candidate)
00116 {
00117 ownerCandidates.push_front(candidate);
00118 }
00119
00120
00121
00122 void
00123 ObjectAttribute::removeCandidate(FederateHandle candidate)
00124 {
00125 ownerCandidates.remove(candidate);
00126 }
00127
00128
00129
00130 FederateHandle
00131 ObjectAttribute::getCandidate(unsigned int indice) const
00132 throw (RTIinternalError)
00133 {
00134 if ((indice <= 0) || (indice > ownerCandidates.size()))
00135 throw RTIinternalError("");
00136
00137 list<FederateHandle>::const_iterator i = ownerCandidates.begin();
00138 for (unsigned int j = 1 ; i != ownerCandidates.end(); i++, j++) {
00139 if (j == indice)
00140 return (*i);
00141 }
00142 throw RTIinternalError("");
00143 }
00144
00145
00146 bool
00147 ObjectAttribute::hasCandidates() const
00148 {
00149 return (!ownerCandidates.empty());
00150 }
00151
00152
00153 AttributeHandle
00154 ObjectAttribute::getHandle() const
00155 {
00156 return handle ;
00157 }
00158
00159
00160 void
00161 ObjectAttribute::setHandle(AttributeHandle h)
00162 {
00163 handle = h ;
00164 }
00165
00166
00167 SpaceHandle
00168 ObjectAttribute::getSpace() const
00169 {
00170 return space ;
00171 }
00172
00173
00174 void
00175 ObjectAttribute::setSpace(SpaceHandle h)
00176 {
00177 space = h ;
00178 }
00179
00180
00181
00182
00183 void
00184 ObjectAttribute::associate(RTIRegion *r)
00185 {
00186 region = r ;
00187 }
00188
00189
00190
00191
00192
00193 void
00194 ObjectAttribute::unassociate(RTIRegion *r)
00195 {
00196 if (region == r)
00197 region = 0 ;
00198 }
00199
00200 }
00201
00202