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