SignalComponent.hpp

Go to the documentation of this file.
00001 /*
00002 SagaEngine library
00003 Copyright (c) 2002-2006 Skalden Studio AS
00004 
00005 This software is provided 'as-is', without any express or implied 
00006 warranty. In no event will the authors be held liable for any 
00007 damages arising from the use of this software.
00008 
00009 Permission is granted to distribute the library under the terms of the 
00010 Q Public License version 1.0. Be sure to read and understand the license
00011 before using the library. It should be included here, or you may read it
00012 at http://www.trolltech.com/products/qt/licenses/licensing/qpl
00013 
00014 The original version of this library can be located at:
00015 http://www.sagaengine.com/
00016 
00017 Rune Myrland
00018 rune@skalden.com
00019 */
00020 
00021 
00022 #ifndef SignalComponent_hpp
00023 #define SignalComponent_hpp
00024 
00025 #include "Signal.hpp"
00026 #include "comp/node/AreaChildComponent.hpp"
00027 #include "comp/Composite.hpp"
00028 #include "../action/ActionComponent.hpp"
00029 #include "../action/ActionFeed.hpp"
00030 #include "../action/sim_action.hpp"
00031 #include "../thing/sim_thing.hpp"
00032 #include "util/type/all.hpp"
00033 
00034 namespace se_core {
00035     class _SeCoreExport SignalComponent : public AreaChildComponent {
00036     public:
00037         typedef ComponentPtr<SignalComponent, sct_SIGNAL> Ptr;
00038 
00039         SignalComponent(Composite* owner, const ComponentFactory* factory = 0);
00040         virtual ~SignalComponent();
00041         const char* name() const { return "Signal"; }
00042 
00043         static SignalComponent* get(Composite& composite) {
00044             SignalComponent* c = static_cast<SignalComponent*>(composite.component(se_core::sct_SIGNAL));
00045             return c;
00046         }
00047 
00048         static SignalComponent* get(Component& component) {
00049             SignalComponent* c = static_cast<SignalComponent*>(component.owner()->component(se_core::sct_SIGNAL));
00050             return c;
00051         }
00052 
00053         void setSendId(int id) {
00054             sendId_ = id;
00055         }
00056 
00057         void setRecieveId(int id, const Signal* signal) {
00058             recieveMask_ = (1 << id);
00059             signal_ = signal;
00060         }
00061 
00062         void setDead();
00063 
00064         bool send(bool state);
00065         long sentAge() const;
00066         void recieve(int id, bool state);
00067         void zoneChanged(int type, Composite* newArea, Composite* oldArea);
00068         bool isOn() const {
00069             return sendState_;
00070         }
00071 
00072 
00073     protected:
00074         void cleanup();
00075 
00076         bool sendState_;
00077         int sendId_;
00078         long sentWhen_;
00079         unsigned long recieveMask_;
00080         const Signal* signal_;
00081     };
00082 
00083 
00084 }
00085 
00086 #endif

Home Page | SagaEngine trunk (updated nightly) reference generated Sun Dec 2 20:06:12 2007 by Doxygen version 1.3.9.1.

SourceForge.net Logo