#include <HxDefaultDataObjectManager.h>
Inheritance diagram for HxDefaultDataObjectManager::
Public Methods | |
HxDefaultDataObjectManager () | |
Constructor for default manager. More... | |
HxDefaultDataObjectManager (const char *repId, const char *objName) | |
This constructor can be called to register a HxDefaultDataObjectManager for a specific type. More... | |
virtual | ~HxDefaultDataObjectManager () |
Destructor. More... | |
virtual void | objectCreated (const PortableServer::ObjectId &oid) |
Called when an object is created. More... | |
virtual void | objectUsed (const PortableServer::ObjectId &oid) |
Called after an operation has been called in an object. More... | |
virtual void | objectAccessed (const PortableServer::ObjectId &oid) |
Called before an operation is called in an object. More... | |
virtual void | objectDeleted (const PortableServer::ObjectId &oid) |
Called when an object is deleted. More... | |
virtual void | setTotalLimit (HxString unit, int value) |
Set limit on given unit. More... | |
virtual int | getTotalLimit (HxString unit) |
virtual void | setObjectLimit (HxString unit, int value) |
Set limit (per object) on given unit. More... | |
virtual int | getObjectLimit (HxString unit) |
virtual int | getUsed (HxString unit) |
virtual void | getUnitList (HxStringListBackInserter slPtr) |
List unit names that this manager can handle. More... | |
Protected Methods | |
virtual HxDefaultObjectInfo * | createObjectInfo () |
Factory function that creates objectInfos. More... | |
virtual void | setObjectInfo (PortableServer::Servant servant, HxDefaultObjectInfo *info) |
Function called by "objectCreated". More... | |
virtual void | updateObjectInfo (PortableServer::Servant servant, HxDefaultObjectInfo *info) |
Function called by "objectUsed". More... | |
virtual void | removeObjectInfo (HxDefaultObjectInfo *info) |
virtual bool | objectExceedsLimit (HxDefaultObjectInfo *info) |
virtual bool | limitExceeded () |
virtual bool | objectCanGrow () |
Protected Attributes | |
HxString | _objName |
int | _totalObjLimit |
int | _usedObjects |
Can only handle "Object" units. This unit only has sense for totalLimits: you can limit the max amount of objects in a server, but not the max amount of objects per object :-)
This class can be used also as a base class of other managers.
|
Constructor for default manager.
00021 : _totalObjLimit(-1), _usedObjects(0), _objName("Objects") 00022 { 00023 } |
|
This constructor can be called to register a HxDefaultDataObjectManager for a specific type.
00027 : _totalObjLimit(-1), _usedObjects(0), _objName(objName) 00028 { 00029 HxDataObjectManager::put(this, repId); 00030 } |
|
Destructor.
00034 { 00035 } |
|
Called when an object is created.
Reimplemented from HxDataObjectManager.
00039 { 00040 // Retrieve dataPOA. Don't do it in the ctor, because 00041 // it has not been created yet. 00042 if(CORBA::is_nil(_dataPOA)) 00043 _dataPOA = HxServer::instance()->getDataPOA(); 00044 00045 HxDefaultObjectInfo* info = createObjectInfo(); 00046 PortableServer::Servant servant = _dataPOA->id_to_servant(oid); 00047 setObjectInfo(servant, info); 00048 info->oid = oid; 00049 00050 if(objectExceedsLimit(info)) { 00051 _dataPOA->deactivate_object(info->oid); 00052 removeObjectInfo(info); 00053 } 00054 else { 00055 _list.push_front(info); 00056 _map[oid] = _list.begin(); 00057 //cout << "created ("<< info->id <<") " << endl; 00058 checkLimit(); 00059 } 00060 servant->_remove_ref(); 00061 } |
|
Called after an operation has been called in an object. (Check if object has grown). Reimplemented from HxDataObjectManager.
00083 { 00084 if(!objectCanGrow()) return; 00085 00086 Map::iterator ptr; 00087 ptr = _map.find(oid); 00088 if(ptr == _map.end()) return; 00089 List::iterator iter = ptr->second; 00090 HxDefaultObjectInfo* info = *iter; 00091 00092 // check object limit (maybe the request has increased it) 00093 PortableServer::Servant servant = _dataPOA->id_to_servant(oid); 00094 updateObjectInfo(servant, info); 00095 if(objectExceedsLimit(info)) { 00096 _list.erase(iter); 00097 _map.erase(info->oid); 00098 _dataPOA->deactivate_object(info->oid); 00099 00100 removeObjectInfo(info); 00101 } 00102 else { 00103 checkLimit(); 00104 } 00105 servant->_remove_ref(); 00106 } |
|
Called before an operation is called in an object. (Manager marks object as used) Reimplemented from HxDataObjectManager.
00065 { 00066 //bring it to front of list 00067 00068 Map::iterator ptr; 00069 ptr = _map.find(oid); 00070 if(ptr == _map.end()) return; 00071 List::iterator iter = ptr->second; 00072 HxDefaultObjectInfo* info = *iter; 00073 00074 _list.erase(iter); 00075 _list.push_front(info); 00076 _map[oid] = _list.begin(); 00077 00078 //cout << "accessed ("<< info->id <<") " << endl; 00079 } |
|
Called when an object is deleted.
Reimplemented from HxDataObjectManager.
00110 { 00111 Map::iterator ptr; 00112 ptr = _map.find(oid); 00113 if(ptr == _map.end()) return; 00114 00115 List::iterator iter = ptr->second; 00116 _list.erase(iter); 00117 _map.erase(oid); 00118 00119 HxDefaultObjectInfo* info = *iter; 00120 removeObjectInfo(info); 00121 00122 //cout << "destroyed ("<< info->id <<")" << endl; 00123 } |
|
Set limit on given unit. All objects together don't have to exceed that limit. Reimplemented from HxDataObjectManager. Reimplemented in HxImageRepManager.
00157 { 00158 if(unit == _objName) _totalObjLimit = value; 00159 checkLimit(); 00160 } |
|
Reimplemented from HxDataObjectManager. Reimplemented in HxImageRepManager.
00164 { 00165 return (unit == _objName)? _totalObjLimit : 0; 00166 } |
|
Set limit (per object) on given unit. Any object can exceed that limit. Reimplemented from HxDataObjectManager. Reimplemented in HxImageRepManager.
00133 { 00134 if(unit == _objName) return; 00135 00136 List::iterator iter = _list.begin(); 00137 while(iter != _list.end()) { 00138 HxDefaultObjectInfo* info = *iter; 00139 if(objectExceedsLimit(info)) { 00140 iter = _list.erase(iter); 00141 _map.erase(info->oid); 00142 _dataPOA->deactivate_object(info->oid); 00143 removeObjectInfo(info); 00144 } 00145 else iter++; 00146 } 00147 } |
|
Reimplemented from HxDataObjectManager. Reimplemented in HxImageRepManager.
00151 { 00152 return (unit == _objName)? 1 : 0; 00153 } |
|
Reimplemented from HxDataObjectManager. Reimplemented in HxImageRepManager.
00170 { 00171 //cout << "list size = " << _list.size() << endl; 00172 //cout << "map size = " << _map.size() << endl; 00173 00174 return (unit == _objName)? _usedObjects : 0; 00175 } |
|
List unit names that this manager can handle.
Reimplemented from HxDataObjectManager. Reimplemented in HxImageRepManager.
00127 { 00128 *slPtr++ = _objName; 00129 } |
|
Factory function that creates objectInfos.
Reimplemented in HxImageRepManager.
00193 { 00194 return new HxDefaultObjectInfo(); 00195 } |
|
Function called by "objectCreated". Write object info on struct and update limits. Reimplemented in HxImageRepManager.
00200 { 00201 //update used limits based on new servant 00202 _usedObjects++; 00203 } |
|
Function called by "objectUsed". Write object info on struct (in case that the object has been modified) and update limits. Reimplemented in HxImageRepManager.
00215 { 00216 // check if object has grown 00217 } |
|
Reimplemented in HxImageRepManager.
00207 { 00208 _usedObjects--; 00209 delete info; 00210 } |
|
Reimplemented in HxImageRepManager.
00227 { 00228 return false; 00229 } |
|
Reimplemented in HxImageRepManager.
00233 { 00234 return (_totalObjLimit >= 0) && (_usedObjects > _totalObjLimit); 00235 } |
|
Reimplemented in HxImageRepManager.
00221 { 00222 return false; 00223 } |
|
|
|
|
|
|