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 #include "localmetaobject.hh"
00029 #include "localsite.hh"
00030 #include "accesscontrol.hh"
00031
00032 using namespace VOS;
00033
00034 LocalMetaObject::LocalMetaObject(const string& name, LocalSite* localsite, VobjectAccessControl* ac)
00035 : VobjectImplementation(name, localsite, true), LocalVobject(name, localsite, ac),
00036 MetaObject(0)
00037 {
00038 }
00039
00040 LocalMetaObject::~LocalMetaObject()
00041 {
00042 }
00043
00044 const string& LocalMetaObject::getName()
00045 {
00046 if(superobject != 0) return superobject->getName();
00047 else return LocalVobject::getName();
00048 }
00049
00050 Site& LocalMetaObject::getSite()
00051 {
00052 if(superobject != 0) return superobject->getSite();
00053 else return LocalVobject::getSite();
00054 }
00055
00056 const URL& LocalMetaObject::getURL()
00057 {
00058 if(superobject != 0) return superobject->getURL();
00059 else return LocalVobject::getURL();
00060 }
00061
00062 bool LocalMetaObject::isLocal()
00063 {
00064 if(superobject != 0) return superobject->isLocal();
00065 else return LocalVobject::isLocal();
00066 }
00067
00068 bool LocalMetaObject::isRemote()
00069 {
00070 if(superobject != 0) return superobject->isRemote();
00071 else return LocalVobject::isRemote();
00072 }
00073
00074 const set<string>& LocalMetaObject::getTypes() throw (AccessControlError)
00075 {
00076 if(superobject != 0) return superobject->getTypes();
00077 else return LocalVobject::getTypes();
00078 }
00079
00080 void LocalMetaObject::addType(const string& s)
00081 {
00082 if(getTypes().count(s)) return;
00083 if(superobject !=0) superobject->addType(s);
00084 else LocalVobject::addType(s);
00085 bool hasalready=false;
00086 for(deque<MetaObject*>::const_iterator i = getTypeHandlers().begin(); i != getTypeHandlers().end(); i++) {
00087 if((*i)->getType() == s) {
00088 hasalready=true;
00089 break;
00090 }
00091 }
00092 if(! hasalready)
00093 LocalSite::extendMetaObject(this, s.c_str());
00094 }
00095
00096
00097 void LocalMetaObject::addType(const string& s, MetaObject& add_requester)
00098 {
00099 if(getTypes().count(s)) return;
00100 if(superobject !=0) superobject->addType(s);
00101 else LocalVobject::addType(s);
00102
00103 for(deque<MetaObject*>::const_iterator i = getTypeHandlers().begin(); i != getTypeHandlers().end(); i++) {
00104 if((*i)->getType() == s) {
00105 return;
00106 }
00107 }
00108
00109 LocalSite::extendMetaObject(this, s.c_str());
00110
00111
00112 bool hastype=false;
00113 for(deque<MetaObject*>::const_iterator i = getTypeHandlers().begin(); i != getTypeHandlers().end(); i++) {
00114 if((*i)->getType() == s) {
00115 hastype=true;
00116 }
00117 }
00118
00119 string t = s;
00120
00121
00122
00123 for(size_t i = t.size(); !hastype; ) {
00124 for(i--; i > 0 && s[i] != '.'; i--);
00125 if(i == 0) break;
00126
00127 t = t.substr(0, i);
00128
00129 LocalSite::extendMetaObject(this, t.c_str());
00130
00131 hastype=false;
00132 for(deque<MetaObject*>::const_iterator i = getTypeHandlers().begin(); i != getTypeHandlers().end(); i++) {
00133 if((*i)->getType() == t) {
00134 hastype=true;
00135 }
00136 }
00137 if(hastype) {
00138 if(superobject !=0) superobject->addType(t);
00139 else LocalVobject::addType(t);
00140 }
00141 }
00142 for(deque<MetaObject*>::const_iterator i = getTypeHandlers().begin(); i != getTypeHandlers().end(); i++) {
00143 if((*i)->getType() == t) {
00144 (*i)->initializeSecurity(add_requester);
00145 }
00146 }
00147 }
00148
00149 const set<Vobject::ParentChildRelation*, Vobject::ParentChildRelation::Cmp>& LocalMetaObject::getParents()
00150 throw (AccessControlError)
00151 {
00152 if(superobject != 0) return superobject->getParents();
00153 else return LocalVobject::getParents();
00154 }
00155
00156 const deque<Vobject::ParentChildRelation*>& LocalMetaObject::getChildren()
00157 throw (AccessControlError, RemoteError)
00158 {
00159 if(superobject != 0) return superobject->getChildren();
00160 else return LocalVobject::getChildren();
00161 }
00162
00163 void LocalMetaObject::sendMessage(Message* m)
00164 {
00165 MetaObject::sendMessage(m);
00166
00167 if(superobject == 0)
00168 {
00169 LocalVobject::sendMessage(m);
00170 }
00171 }
00172
00173 void LocalMetaObject::sendMessage(MessageBlock* m)
00174 {
00175 MetaObject::sendMessage(m);
00176
00177 if(superobject == 0) {
00178 LocalVobject::sendMessage(m);
00179 }
00180 }
00181
00182 Message* LocalMetaObject::receiveMessage() throw (MessageQueueEmptyError)
00183 {
00184 if(superobject != 0) return superobject->receiveMessage();
00185 else return LocalVobject::receiveMessage();
00186 }
00187
00188 bool LocalMetaObject::hasMessageAvailable()
00189 {
00190 if(superobject != 0) return superobject->hasMessageAvailable();
00191 else return LocalVobject::hasMessageAvailable();
00192 }
00193
00194 void LocalMetaObject::sendUpdateMessage(Message* m)
00195 {
00196 if(superobject != 0) sendUpdateMessage(m);
00197 else LocalVobject::sendUpdateMessage(m);
00198 }
00199
00200 Message* LocalMetaObject::receiveUpdateMessage() throw (MessageQueueEmptyError)
00201 {
00202 if(superobject != 0) return superobject->receiveUpdateMessage();
00203 else return LocalVobject::receiveUpdateMessage();
00204 }
00205
00206 bool LocalMetaObject::hasUpdateMessageAvailable()
00207 {
00208 if(superobject != 0) return superobject->hasUpdateMessageAvailable();
00209 else return LocalVobject::hasUpdateMessageAvailable();
00210 }
00211
00212 Vobject& LocalMetaObject::findObject(const string& path) throw (NoSuchSiteError, NoSuchObjectError,
00213 URL::BadURLError, AccessControlError, RemoteError)
00214 {
00215 if(superobject != 0) return superobject->findObject(path);
00216 else return LocalVobject::findObject(path);
00217 }
00218
00219 Vobject::ParentChildRelation& LocalMetaObject::findChild(const string& path) throw (NoSuchObjectError, AccessControlError, RemoteError)
00220 {
00221
00222 if(superobject != 0) return superobject->findChild(path);
00223 else return LocalVobject::findChild(path);
00224 }
00225
00226 Vobject::ParentChildRelation& LocalMetaObject::findParent(Vobject& parent) throw (NoSuchObjectError, AccessControlError)
00227 {
00228 if(superobject != 0) return superobject->findParent(parent);
00229 else return LocalVobject::findParent(parent);
00230 }
00231
00232 void LocalMetaObject::setChild(int position, const string& contextual_name, Vobject* child)
00233 throw (AccessControlError, RemoteError)
00234 {
00235 if(superobject != 0) return superobject->setChild(position, contextual_name, child);
00236 else return LocalVobject::setChild(position, contextual_name, child);
00237 }
00238
00239 void LocalMetaObject::insertChild(int position, const string& contextual_name, Vobject* child)
00240 throw (AccessControlError, RemoteError)
00241 {
00242 if(superobject != 0) return superobject->insertChild(position, contextual_name, child);
00243 else return LocalVobject::insertChild(position, contextual_name, child);
00244 }
00245
00246 void LocalMetaObject::removeChild(int position)
00247 throw (AccessControlError, RemoteError)
00248 {
00249 if(superobject != 0) return superobject->removeChild(position);
00250 else return LocalVobject::removeChild(position);
00251 }
00252
00253 void LocalMetaObject::addTypeListener(TypeChangeListener* tl, bool refresh)
00254 {
00255 if(superobject != 0) superobject->addTypeListener(tl, refresh);
00256 else LocalVobject::addTypeListener(tl, refresh);
00257 }
00258
00259 void LocalMetaObject::addParentListener(ParentChangeListener* pl, bool refresh)
00260 {
00261 if(superobject != 0) superobject->addParentListener(pl, refresh);
00262 else LocalVobject::addParentListener(pl, refresh);
00263 }
00264
00265 void LocalMetaObject::addChildListener(ChildChangeListener* cl, bool refresh)
00266 {
00267 if(superobject != 0) superobject->addChildListener(cl, refresh);
00268 else LocalVobject::addChildListener(cl, refresh);
00269 }
00270
00271 void LocalMetaObject::removeTypeListener(TypeChangeListener* tl)
00272 {
00273 if(superobject != 0) superobject->removeTypeListener(tl);
00274 else LocalVobject::removeTypeListener(tl);
00275 }
00276
00277 void LocalMetaObject::removeParentListener(ParentChangeListener* pl)
00278 {
00279 if(superobject != 0) superobject->removeParentListener(pl);
00280 else LocalVobject::removeParentListener(pl);
00281 }
00282
00283 void LocalMetaObject::removeChildListener(ChildChangeListener* cl)
00284 {
00285 if(superobject != 0) superobject->removeChildListener(cl);
00286 else LocalVobject::removeChildListener(cl);
00287 }
00288
00289 void LocalMetaObject::excise()
00290 {
00291 MetaObject::excise();
00292 VobjectImplementation::excise();
00293 }
00294
00295 void LocalMetaObject::acquire() {
00296 if(superobject !=0) superobject->acquire();
00297 else LocalVobject::acquire();
00298 }
00299
00300 void LocalMetaObject::release() {
00301 if(superobject !=0) superobject->release();
00302 else LocalVobject::release();
00303 }
00304
00305 int LocalMetaObject::getCount() {
00306 if(superobject !=0) return superobject->getCount();
00307 else return LocalVobject::getCount();
00308 }
00309
00310 void LocalMetaObject::saveState(MessageBlock& output, set<string>& types, bool portable)
00311 {
00312 if(superobject !=0) return superobject->saveState(output, types, portable);
00313 else {
00314 LocalVobject::saveState(output, types, portable);
00315 doSaveState(output, types, portable);
00316 }
00317 }
00318
00319 void LocalMetaObject::addFlag(const string& flag)
00320 {
00321 if(superobject) superobject->addFlag(flag);
00322 else LocalVobject::addFlag(flag);
00323 }
00324
00325 void LocalMetaObject::removeFlag(const string& flag)
00326 {
00327 if(superobject) superobject->removeFlag(flag);
00328 else LocalVobject::removeFlag(flag);
00329 }
00330
00331 bool LocalMetaObject::checkFlag(const string& flag)
00332 {
00333 if(superobject) return superobject->checkFlag(flag);
00334 else return LocalVobject::checkFlag(flag);
00335 }
00336