Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ComponentContext.h

Go to the documentation of this file.
00001 
00039 #ifndef _AMIRE_COMPONENT_COMPONENT_CONTEXT_H
00040 #define _AMIRE_COMPONENT_COMPONENT_CONTEXT_H
00041 
00042 #include <amire/common/Defines.h>
00043 #include "amire/component/Component.h"
00044 
00045 namespace amire {
00046   namespace component {
00050     typedef std::hash_map<long, int> LongToIntMap;
00051 
00055     typedef std::hash_map<long, std::string> LongToStringMap;
00056 
00060     typedef STD_HASH_MAP(std::string, long, amire::common::HashCompareString) StringToLongMap;
00061 
00065     typedef STD_HASH_MAP(std::string, osg::ref_ptr<Component>, amire::common::HashCompareString) StringToComponentMap;
00066 
00089     class AMIRE_EXPORT_API ComponentContext : public virtual osg::Referenced {
00090     protected:
00091       std::vector<osg::ref_ptr<Component> > components;
00092 
00093     private:
00094       long nextId;
00095       LongToIntMap priorityMap;
00096       StringToLongMap nameIdMap;
00097       LongToStringMap nameMap;
00098       StringToLongMap nameReverseMap;
00099 
00100     public:
00101       virtual ~ComponentContext();
00102 
00107       virtual osg::ref_ptr<const Component> getComponentPrototype(const std::string &name) = 0;
00108 
00116       osg::ref_ptr<Component> newComponent(const std::string &prototypeName);
00117 
00124       osg::ref_ptr<Component> newComponent(const std::string &prototypeName, const std::string &identifier);
00125 
00131       bool connect(const std::string &emitter, const std::string &outSlot, const std::string &receiver, const std::string &inSlot, const osg::ref_ptr<const ConnectionFilter> &filter = NULL);
00132 
00137       const osg::ref_ptr<Component> &getComponent(long id) const;
00138 
00143       const osg::ref_ptr<Component> &getComponent(const std::string &name) const;
00144 
00145       /*
00146        * Returns all components that are available in this context.
00147        */
00148       const std::vector<osg::ref_ptr<Component> > &getComponents() const;
00149 
00150       /*
00151        * Sets the priority of the component (specified by its id) to the given value.
00152        * NOTE: The global priotiy of the component depends on the context local priority
00153        * of the component and the priority of the context itself.
00154        * An exception is thrown when the id is unknown for this context.
00155        * IMPORTANT: Don't use this method directly. Use the setPriority method of the
00156        * component itself instead of this mehtod.
00157        */
00158       void setPriority(long id, int priority);
00159 
00160       /*
00161        * Returns the priority of the component (specified by its id).
00162        * NOTE: The global priotiy of the component depends on the context local priority
00163        * of the component and the priority of the context itself.
00164        * An exception is thrown when the id is unknown for this context.
00165        * IMPORTANT: Don't use this method directly. Use the getPriority method of the
00166        * component itself instead of this mehtod.
00167        */
00168       int getPriority(long id) const;
00169 
00170       /*
00171        * Sets the name of the component (specified by its id) to the given value.
00172        * NOTE: The global name of the component depends on the context local name
00173        * of the component and the name of the context itself.
00174        * An exception is thrown when the id is unknown for this context.
00175        * IMPORTANT: Don't use this method directly. Use the setName method of the
00176        * component itself instead of this mehtod.
00177        */
00178       void setName(long id, const std::string &name);
00179 
00180       /*
00181        * Returns the name of the component (specified by its id).
00182        * NOTE: The global name of the component depends on the context local name
00183        * of the component and the name of the context itself.
00184        * An exception is thrown when the id is unknown for this context.
00185        * IMPORTANT: Don't use this method directly. Use the getName method of the
00186        * component itself instead of this mehtod.
00187        */
00188       const std::string &getName(long id) const;
00189 
00190       /*
00191        * Deletes the given component and all connections, which it's part of.
00192        * An exception is thrown when the component is part of another context.
00193        * IMPORTANT: Don't use this method directly. Use the deleteComponent method
00194        * of the component itself instead of this mehtod.
00195        */
00196       void deleteComponent(const osg::ref_ptr<Component> &component);
00197 
00198     protected:
00199       friend class Component;
00200       friend class ComposedComponent;
00201 
00202       ComponentContext();
00203 
00207       virtual void changedInSlots(const osg::ref_ptr<const Component> &component);
00208 
00212       virtual void changedOutSlots(const osg::ref_ptr<const Component> &component);
00213 
00217       virtual void removedInSlot(const osg::ref_ptr<const Component> &component, int inSlotId, const std::string &inSlotName, const osg::ref_ptr<const amire::property::PropertyType> &inSlotType);
00218 
00222       virtual void removedOutSlot(const osg::ref_ptr<const Component> &component, int outSlotId, const std::string &outSlotName, const osg::ref_ptr<const amire::property::PropertyType> &outSlotType);
00223 
00227       virtual void renamedInSlot(const osg::ref_ptr<const Component> &component, int inSlotId, const std::string &oldInSlotName, const std::string &newInSlotName);
00228 
00232       virtual void renamedOutSlot(const osg::ref_ptr<const Component> &component, int outSlotId, const std::string &oldOutSlotName, const std::string &newOutSlotName);
00233 
00237       virtual void changedInSlotType(const osg::ref_ptr<const Component> &component, int inSlotId, const std::string &inSlotName, const osg::ref_ptr<const amire::property::PropertyType> &oldInSlotType, const osg::ref_ptr<const amire::property::PropertyType> &newInSlotType);
00238 
00242       virtual void changedOutSlotType(const osg::ref_ptr<const Component> &component, int outSlotId, const std::string &outSlotName, const osg::ref_ptr<const amire::property::PropertyType> &oldOutSlotType, const osg::ref_ptr<const amire::property::PropertyType> &newOutSlotType);
00243 
00247       virtual std::string getQualifier() const;
00248 
00252       long nextComponentId();
00253     };
00254   }
00255 }
00256 
00257 #endif

Generated on Tue May 20 17:23:52 2003 for AMIRE-Framework by doxygen1.3