Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "mitkDataStorageAccessRule.h"
00019 #include <Poco/Exception.h>
00020
00021
00022
00023
00024
00025
00026 mitk::DataStorageAccessRule
00027 ::DataStorageAccessRule (mitk::DataStorage::Pointer myDataStorage, mitk::DataNode::Pointer myDataNode,
00028 mitk::DataStorageAccessRule::RuleType myRule)
00029 :m_Rule(myRule),
00030 m_sptrMyDataStorage(myDataStorage),
00031 m_sptrMyDataNode(myDataNode)
00032
00033 {
00034 mitk::DataStorage::SetOfObjects::ConstPointer
00035 sptr_parentsNodesFirstRule = m_sptrMyDataStorage->GetSources(m_sptrMyDataNode);
00036
00037
00038 bool exsists = false ;
00039 for(mitk::DataStorage::SetOfObjects::const_iterator it =
00040 sptr_parentsNodesFirstRule->begin(); it != sptr_parentsNodesFirstRule->end(); ++ it)
00041 {
00042 if (*it == m_sptrMyDataNode ) exsists = true ;
00043 }
00044 if (exsists == false) throw Poco::NotFoundException() ;
00045
00046 }
00047
00048
00049
00050 bool
00051 mitk::DataStorageAccessRule
00052 ::Contains(berry::ISchedulingRule::Pointer rule)
00053 {
00054 DataStorageAccessRule::Pointer sptr_temp = rule.Cast<DataStorageAccessRule>();
00055
00056 if( sptr_temp == 0 ) return false ;
00057
00058 else {
00059 if ( this == sptr_temp.GetPointer() ) return true ;
00060
00061 return false ;
00062 }
00063 }
00064
00065
00066
00067 bool
00068 mitk::DataStorageAccessRule
00069 ::IsConflicting(berry::ISchedulingRule::Pointer sptr_otherISchedulingRule)
00070 {
00071
00072
00073 DataStorageAccessRule::Pointer sptr_DataStorageAccessRule = sptr_otherISchedulingRule.Cast<DataStorageAccessRule>();
00074
00075 if(sptr_DataStorageAccessRule == 0) return false ;
00076
00077
00078 else
00079 {
00080
00081 if( !CompareDataStorages(sptr_DataStorageAccessRule->GetDataStorage()) ) return false ;
00082
00083
00084 if (m_Rule == ADD_RULE && m_Rule == sptr_DataStorageAccessRule->GetRuleType())
00085 return CompareTwoAddorRemoveRules() ;
00086
00087
00088 if(m_Rule == REMOVE_RULE && m_Rule == sptr_DataStorageAccessRule->GetRuleType())
00089 return CompareTwoAddorRemoveRules() ;
00090
00091
00092 else
00093 {
00094 return CompareAddandRemoveRules(sptr_DataStorageAccessRule) ;
00095 }
00096
00097 }
00098
00099 }
00100
00101 bool
00102 mitk::DataStorageAccessRule
00103 ::CompareAddandRemoveRules(mitk::DataStorageAccessRule::Pointer sptr_otherDataStorageAccessRule) const
00104 {
00105
00106 mitk::DataStorage::SetOfObjects::ConstPointer
00107 sptr_parentsNodesFirstRule = m_sptrMyDataStorage->GetSources(m_sptrMyDataNode);
00108
00109
00110 for(mitk::DataStorage::SetOfObjects::const_iterator it =
00111 sptr_parentsNodesFirstRule->begin(); it != sptr_parentsNodesFirstRule->end(); ++ it)
00112 {
00113 if (*it == sptr_otherDataStorageAccessRule->GetDataNode()) return true ;
00114 }
00115 mitk::DataStorage::SetOfObjects::ConstPointer
00116 sptr_derivedNodesRule = m_sptrMyDataStorage->GetDerivations(m_sptrMyDataNode);
00117
00118
00119 for(mitk::DataStorage::SetOfObjects::const_iterator it =
00120 sptr_derivedNodesRule->begin(); it != sptr_derivedNodesRule->end(); ++it)
00121 {
00122 if(*it == sptr_otherDataStorageAccessRule->GetDataNode()) return true ;
00123 }
00124
00125
00126
00127 return false ;
00128 }
00129
00130
00131
00132 bool
00133 mitk::DataStorageAccessRule
00134 ::CompareDataStorages(mitk::DataStorage::Pointer otherDataStorage) const
00135 {
00136 if(m_sptrMyDataStorage == otherDataStorage) return true ;
00137 else return false;
00138 }
00139
00140
00141
00142 bool
00143 mitk::DataStorageAccessRule
00144 ::CompareTwoAddorRemoveRules() const
00145 {
00146 return false ;
00147 }
00148
00149
00150
00151 bool
00152 mitk::DataStorageAccessRule
00153 ::TestDataNode(mitk::DataNode::Pointer ) const
00154 {
00155 mitk::DataStorage::SetOfObjects::ConstPointer tempAllNodes = m_sptrMyDataStorage->GetAll();
00156 for(mitk::DataStorage::SetOfObjects::const_iterator it = tempAllNodes->begin(); it !=tempAllNodes->end(); ++ it){
00157 if (m_sptrMyDataNode == *it ) return true ;
00158
00159 }
00160 return false ;
00161
00162 }
00163
00164
00165
00166 mitk::DataNode::Pointer
00167 mitk::DataStorageAccessRule
00168 ::GetDataNode() const
00169 {
00170 return mitk::DataStorageAccessRule::m_sptrMyDataNode ;
00171 }
00172
00173
00174
00175 mitk::DataStorage::Pointer
00176 mitk::DataStorageAccessRule
00177 ::GetDataStorage() const
00178 {
00179 return mitk::DataStorageAccessRule::m_sptrMyDataStorage ;
00180 }
00181
00182
00183 mitk::DataStorageAccessRule::RuleType
00184 mitk::DataStorageAccessRule
00185 ::GetRuleType() const
00186 {
00187 if (m_Rule == ADD_RULE)
00188 return ( mitk::DataStorageAccessRule::ADD_RULE ) ;
00189 else {
00190 return ( mitk::DataStorageAccessRule::REMOVE_RULE ) ;
00191
00192 }
00193 }
00194
00195
00196
00197