00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __freSessionComponentCache_h
00023 #define __freSessionComponentCache_h
00024
00025 #include "freComponentSetup.h"
00026 #include "freComponentCacheCollection.h"
00027
00028 #include "itkLightObject.h"
00029
00030 namespace FREE
00031 {
00032
00033
00034 class DirectSessionComponentAccessor;
00035 class ComponentControllerInterface;
00036
00037 typedef ComponentControllerInterface GenericComponentController;
00038
00049 class SessionComponentCache : public itk::LightObject
00050 {
00051 public:
00052 typedef SessionComponentCache Self;
00053 typedef itk::LightObject Superclass;
00054 typedef itk::SmartPointer<Self> Pointer;
00055 typedef itk::SmartPointer<const Self> ConstPointer;
00056
00057 typedef itk::LightObject GenericComponentType;
00058 typedef itk::SmartPointer<GenericComponentType> GenericComponentPointer;
00059
00060 itkTypeMacro(SessionComponentCache, LightObject);
00061 itkNewMacro(SessionComponentCache);
00062 static Pointer New(SessionComponentCache* pParentCache, ComponentSetup* pSetup,
00063 const GenericComponentController* pController,
00064 GenericComponentType* pComponent, bool bIsPassive = false);
00065
00066 typedef ComponentCacheCollection<SessionComponentCache> ComponentCacheCollectionType;
00067
00068 inline bool ControllerIsAssigned() const { return m_pComponentController!=0; };
00069 inline bool SetupIsAssigned() const { return m_smpComponentSetup.IsNotNull(); };
00070
00073 std::string GetControllerID() const;
00074
00077 const ComponentID& GetComponentID() const;
00078
00079 friend class DirectSessionComponentAccessor;
00080
00081 typedef std::map<std::string, GenericComponentPointer> CacheRepositoryType;
00082
00083 typedef ComponentCacheCollection<SessionComponentCache> ComponentCacheCollectionType;
00084
00085 inline bool ComponentIsAssigned() const { return m_smpComponent.IsNotNull(); };
00086
00090 bool IsActive() const;
00091
00095 bool IsPassiveCache() const;
00096
00099 ComponentCacheCollectionType& SubCaches() { return m_SubCaches; };
00100 const ComponentCacheCollectionType& SubCaches() const { return m_SubCaches; };
00101
00104 GenericComponentPointer Component() const;
00105 void SetComponent(GenericComponentType* pComponent);
00106
00110 ComponentSetup* Setup() const;
00111
00115 const GenericComponentController* Controller() const;
00116
00118 bool HasParentCache() const;
00119
00122 const SessionComponentCache* GetParentCache() const;
00124 SessionComponentCache* GetParentCache();
00125
00130 const SessionComponentCache* GetRootCache() const;
00132 SessionComponentCache* GetRootCache();
00133
00138 SessionComponentCache* GetCacheByIDPath(const IDPath& idPath);
00140 const SessionComponentCache* GetConstCacheByIDPath(const IDPath& idPath) const;
00141
00144 IDPath GetIDPath() const;
00145
00147 virtual SessionComponentCache& operator = (const SessionComponentCache& rSessionComponentCache);
00148
00149 protected:
00156 SessionComponentCache(SessionComponentCache* pParentCache, ComponentSetup* pSetup,
00157 const GenericComponentController* pController, GenericComponentType* pComponent,
00158 bool bIsPassive = false);
00159
00160 SessionComponentCache();
00161
00162 virtual ~SessionComponentCache();
00163
00165 SessionComponentCache* m_pParent;
00166
00168 ComponentSetup::Pointer m_smpComponentSetup;
00169
00171 const GenericComponentController* m_pComponentController;
00172
00174 ComponentCacheCollectionType m_SubCaches;
00175
00177 GenericComponentPointer m_smpComponent;
00178
00182 CacheRepositoryType m_Repository;
00183
00184 bool m_bPassive;
00185
00186 private:
00188 SessionComponentCache( const SessionComponentCache& rSessionComponentCache );
00189
00190 };
00191
00206 class DirectSessionComponentAccessor
00207 {
00208 public:
00209 static SessionComponentCache::GenericComponentType* GetComponent(const SessionComponentCache* pCache);
00210 static void SetComponent(SessionComponentCache::GenericComponentType* pComponent, SessionComponentCache* pCache);
00211
00212 static SessionComponentCache::CacheRepositoryType& GetRepository(SessionComponentCache* pCache);
00213 static const SessionComponentCache::CacheRepositoryType& GetRepository(const SessionComponentCache* pCache);
00214
00215 static SessionComponentCache::GenericComponentType* GetRepositoryElement(const std::string& sElementKey, const SessionComponentCache* pCache);
00216 static void SetRepositoryElement(const std::string& sElementKey, SessionComponentCache::GenericComponentType* pElement, SessionComponentCache* pCache);
00217 static void DeleteRepositoryElement(const std::string& sElementKey, SessionComponentCache* pCache);
00218 };
00219
00228 class SessionComponentRepositoryKeys
00229 {
00230 public:
00236 static std::string ParameterValidity(const std::string& sParameterName);
00241 static std::string MediaValidity(const MediaID& id);
00247 static std::string Validity(const std::string& id);
00248 };
00249
00250 }
00251
00252 #endif