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

Component.h

Go to the documentation of this file.
00001 
00057 #ifndef _AMIRE_COMPONENT_COMPONENT_H
00058 #define _AMIRE_COMPONENT_COMPONENT_H
00059 
00060 #include <amire/common/Defines.h>
00061 #include "amire/common/Category.h"
00062 #include <amire/property/StructProperty.h>
00063 #include <amire/property/PropertyType.h>
00064 #include <amire/component/ComponentState.h>
00065 #include <amire/component/Connection.h>
00066 
00067 namespace amire {
00068   namespace component {
00069     class AMIRE_EXPORT_API Connection;
00070     class AMIRE_EXPORT_API ConnectionFilter;
00071     class AMIRE_EXPORT_API ComponentManager;
00072     class AMIRE_EXPORT_API ComponentContext;
00073     class AMIRE_EXPORT_API MREngine;
00074     class AMIRE_EXPORT_API Component;
00075 
00081     class AMIRE_EXPORT_API Handler : public virtual osg::Referenced {
00082     public:
00083       virtual ~Handler();
00084 
00088       virtual osg::ref_ptr<Component> getComponent();
00089     };
00090 
00095     class AMIRE_EXPORT_API EmissionListener : public virtual osg::Referenced {
00096     public:
00097       virtual ~EmissionListener();
00098 
00102       virtual void emitted(const osg::ref_ptr<const Component> &component, int outSlotId, const osg::ref_ptr<const amire::property::Property> &property) = 0;
00103     };
00104 
00110     typedef STD_HASH_MAP(osg::ref_ptr<const ComponentState>, std::vector<int>, HashCompareComponentState) EmissionMap;
00111 
00131     class AMIRE_EXPORT_API Component : public virtual Handler { // TODO: synchronization
00132     private:
00133       long componentId;
00134       osg::ref_ptr<const ComponentState> state;
00135       mutable osg::ref_ptr<amire::property::StructProperty> configurationProperty;
00136       std::vector<std::string> inSlots;
00137       std::vector<std::string> outSlots;
00138       std::vector<osg::ref_ptr<const amire::property::PropertyType> > inSlotPropertyTypes;
00139       std::vector<osg::ref_ptr<const amire::property::PropertyType> > outSlotPropertyTypes;
00140       std::vector<std::vector<osg::ref_ptr<Connection> > > emitConnections;
00141       std::vector<std::vector<osg::ref_ptr<const Connection> > > receiveConnections;
00142       STD_HASH_MAP(osg::ref_ptr<const ComponentState>, std::vector<int>, HashCompareComponentState) emissionMap;
00143       ComponentManager *componentManager;
00144       std::string prototypeName;
00145       bool emitSynchronized;
00146       bool prototype;
00147       osg::ref_ptr<const amire::common::Category> category;
00148       ComponentContext *context;
00149       bool alive;
00150       osg::ref_ptr<Component> componentPrototype;
00151       amire::property::StringToPropertyMap metaInformation;
00152       std::string libraryName;
00153       std::vector<osg::ref_ptr<EmissionListener> > emissionListeners;
00154 
00155     public:
00160       virtual ~Component();
00161 
00170       virtual void reinitializeEngine(MREngine *engine);
00171 
00181       virtual void functionalCallback(MREngine *engine);
00182 
00192       virtual bool isConnectable(int outSlotId, const osg::ref_ptr<Component> &receiver,
00193                                  int inSlotId) const;
00194 
00207       void lock() const; // TODO: implementation
00208 
00217       void unlock() const;  // TODO: implementation
00218 
00225       virtual bool isConnected(const std::string &outSlotName,
00226                                const osg::ref_ptr<Component> &receiver,
00227                                const std::string &inSlotName);
00228 
00235       virtual bool isConnected(int outSlotId,
00236                                const osg::ref_ptr<Component> &receiver,
00237                                int inSlotId);
00238 
00243       virtual bool isOutSlotConnected(const std::string &outSlotName);
00244 
00249       virtual bool isOutSlotConnected(int outSlotId);
00250 
00255       virtual bool isInSlotConnected(const std::string &inSlotName);
00256 
00261       virtual bool isInSlotConnected(int inSlotId);
00262 
00267       virtual osg::ref_ptr<const amire::property::StructProperty> getConfigurationProperty() const;
00268 
00275       virtual osg::ref_ptr<amire::property::StructProperty> requestConfigurationProperty();
00276 
00283       virtual void releaseConfigurationProperty();
00284 
00290       void deleteComponent();
00291 
00295       bool isDeleted();
00296 
00307       bool connect(const std::string &outSlotName,
00308                    const osg::ref_ptr<Component> &receiver,
00309                    const std::string &inSlotName,
00310                    const osg::ref_ptr<const ConnectionFilter> &filter = NULL);
00311 
00322       bool connect(int outSlotId,
00323                    const osg::ref_ptr<Component> &receiver,
00324                    int inSlotId,
00325                    const osg::ref_ptr<const ConnectionFilter> &filter = NULL);
00326 
00334       void disconnect(const std::string &outSlotName, const osg::ref_ptr<Component> &receiver,
00335                       const std::string &inSlotName);
00336 
00344       void disconnect(int outSlotId, const osg::ref_ptr<Component> &receiver, int inSlotId);
00345 
00349       void disconnectInSlots();
00350 
00354       void disconnectOutSlots();
00355 
00359       void disconnect();
00360 
00367       const std::vector<int> &getStateEmissions(const osg::ref_ptr<const ComponentState> &state);
00368 
00372       const EmissionMap &getEmissionStates() const;
00373 
00381       void setStateEmissions(const osg::ref_ptr<const ComponentState> &state,
00382                              const std::vector<int> &outSlotIds);
00383 
00390       void addStateEmission(const osg::ref_ptr<const ComponentState> &state, int outSlotId);
00391 
00398       void removeStateEmission(const osg::ref_ptr<const ComponentState> &state, int outSlotId);
00399 
00407       void emit(int outSlotId);
00408 
00415       void setEmitSynchronized(bool synchronized = false); // TODO: implementation
00416 
00424       bool isEmitSynchronized(); // TODO: implementation
00425 
00430       int numberOfInSlots() const;
00431 
00436       int numberOfOutSlots() const;
00437 
00442       const std::vector<std::string> &getInSlotNames();
00443 
00448       const std::vector<std::string> &getOutSlotNames();
00449 
00454       const std::vector<osg::ref_ptr<const amire::property::PropertyType> > &getInSlotPropertyTypes();
00455 
00460       const std::vector<osg::ref_ptr<const amire::property::PropertyType> > &getOutSlotPropertyTypes();
00461 
00467       const std::string &getInSlotName(int inSlotId) const;
00468 
00474       const std::string &getOutSlotName(int outSlotId) const;
00475 
00481       const osg::ref_ptr<const amire::property::PropertyType> &getInSlotType(int inSlotId) const;
00482 
00488       const osg::ref_ptr<const amire::property::PropertyType> &getOutSlotType(int outSlotId) const;
00489 
00495       int getInSlotId(const std::string &inSlotName) const;
00496 
00502       int getOutSlotId(const std::string &outSlotName) const;
00503 
00510       void setState(const osg::ref_ptr<const ComponentState> &state);
00511 
00515       const osg::ref_ptr<const ComponentState> &getState() const;
00516 
00521       const std::string &getPrototypeName() const;
00522 
00526       int getId() const;
00527 
00533       const std::vector<std::vector<osg::ref_ptr<Connection> > > &getEmitConnections() const;
00534 
00540       const std::vector<std::vector<osg::ref_ptr<const Connection> > > &getReceiveConnections() const;
00541 
00546       ComponentManager *getComponentManager() const;
00547 
00552       amire::property::PropertyTypeManager *getPropertyTypeManager() const;
00553 
00559       void setPriority(int priority);
00560 
00565       int getPriority() const;
00566 
00571       void setName(const std::string &name);
00572 
00576       const std::string &getName() const;
00577 
00581       bool isPrototype() const;
00582 
00586       const osg::ref_ptr<const amire::common::Category> &getCategory() const;
00587 
00591       osg::ref_ptr<const Component> getProtoype() const;
00592 
00596       std::vector<std::string> getMetaInformationKeys() const;
00597 
00601       void setMetaInformation(const std::string &name, const osg::ref_ptr<amire::property::Property> &property);
00602 
00607       osg::ref_ptr<amire::property::Property> getMetaInformation(const std::string &name) const;
00608 
00612       void setPrototypeMetaInformation(const std::string &name, const osg::ref_ptr<amire::property::Property> &property);
00613 
00617       osg::ref_ptr<amire::property::Property> getPrototypeMetaInformation(const std::string &name) const;
00618 
00622       const std::string &getLibrary() const;
00623 
00627       void addEmissionListener(const osg::ref_ptr<EmissionListener> &emissionListener);
00628 
00632       void removeEmissionListener(const osg::ref_ptr<EmissionListener> &emissionListener);
00633 
00638       std::string getQualifiedName() const;
00639 
00640     protected:
00646       Component(ComponentManager *componentManager);
00647 
00654       virtual osg::ref_ptr<Component> clone(ComponentContext* context) const;
00655 
00660       virtual osg::ref_ptr<Component> newInstance() const;
00661 
00668       virtual void receiveInSlotProperty(int inSlotId,
00669                                          const osg::ref_ptr<const amire::property::Property> &property);
00678       virtual osg::ref_ptr<const amire::property::Property> emitOutSlotProperty(int outSlotId);
00679 
00686       virtual void configurationPropertyModified() = 0;
00687 
00692       virtual void deleted();
00693 
00698       virtual void initPrototypeMetaInformation();
00699 
00704       virtual void initMetaInformation();
00705 
00713       int registerInSlot(const std::string &inSlotName,
00714                          const osg::ref_ptr<const amire::property::PropertyType> &propertyType);
00715 
00723       int registerInSlot(const std::string &inSlotName, const std::string &propertyTypeName);
00724 
00733       int registerOutSlot(const std::string &outSlotName,
00734                           const osg::ref_ptr<const amire::property::PropertyType> &propertyType);
00735 
00744       int registerOutSlot(const std::string &outSlotName, const std::string &propertyTypeName);
00745 
00749       void clearInSlotRegistration();
00750 
00754       void clearOutSlotRegistration();
00755 
00759       void clearSlotRegistration();
00760 
00766       void setPrototypeName(const std::string &prototypeName);
00767 
00773       void setConfigurationProperty(const osg::ref_ptr<amire::property::StructProperty> &property);
00774 
00781       void setConfigurationProperty(const std::string &structPropertyTypeName);
00782 
00787       void removeInSlot(const std::string &inSlotName);
00788 
00793       void removeInSlot(int inSlotId);
00794 
00799       void removeOutSlot(const std::string &outSlotName);
00800 
00805       void removeOutSlot(int outSlotId);
00806 
00811       void renameInSlot(const std::string &inSlotName, const std::string &newInSlotName);
00812 
00817       void renameInSlot(int inSlotId, const std::string &newInSlotName);
00818 
00823       void renameOutSlot(const std::string &outSlotName, const std::string &outInSlotName);
00824 
00829       void renameOutSlot(int outSlotId, const std::string &outInSlotName);
00830 
00835       void changeInSlotType(const std::string &inSlotName, const std::string &propertyTypeName);
00836 
00841       void changeInSlotType(const std::string &inSlotName, const osg::ref_ptr<const amire::property::PropertyType> &propertyType);
00842 
00847       void changeInSlotType(int inSlotId, const osg::ref_ptr<const amire::property::PropertyType> &propertyType);
00848 
00853       void changeOutSlotType(const std::string &outSlotName, const std::string &propertyTypeName);
00854 
00859       void changeOutSlotType(const std::string &outSlotName, const osg::ref_ptr<const amire::property::PropertyType> &propertyType);
00860 
00865       void changeOutSlotType(int outSlotId, const osg::ref_ptr<const amire::property::PropertyType> &propertyType);
00866 
00871       virtual void setPrototype();
00872 
00873     private:
00874       friend class ComponentManager;
00875       friend class ComponentContext;
00876       friend class ComposedComponent;
00877       friend class Connection;
00878       friend class MREngine;
00879 
00880       void setLibrary(const std::string &libraryName);
00881       void setId(int componentId);
00882       void setCategory(const osg::ref_ptr<const amire::common::Category> &category);
00883     };
00884 
00889     typedef STD_HASH_MAP(std::string, osg::ref_ptr<Component> ,
00890                          amire::common::HashCompareString) ComponentMap;
00891   }
00892 }
00893 #endif

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