From: <sv...@ww...> - 2005-10-15 20:06:50
|
Author: mkrose Date: 2005-10-15 13:06:43 -0700 (Sat, 15 Oct 2005) New Revision: 1627 Modified: trunk/CSP/CSPSim/CHANGES.current trunk/CSP/CSPSim/Include/CockpitInterface.h trunk/CSP/CSPSim/Source/CockpitInterface.cpp Log: * Make the CockpitSwitch data channel a push channel and fix the constructor signature. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1627 Modified: trunk/CSP/CSPSim/CHANGES.current =================================================================== --- trunk/CSP/CSPSim/CHANGES.current 2005-10-15 20:02:50 UTC (rev 1626) +++ trunk/CSP/CSPSim/CHANGES.current 2005-10-15 20:06:43 UTC (rev 1627) @@ -11,6 +11,9 @@ * Add an osg::Group to SceneModel ("DynamicGroup") that can be used for attached objects such as external stores. + * Make the CockpitSwitch data channel a push channel and fix the + constructor signature. + 2005-08-27: onsight * Link against sigc-2.0, not sigc-1.2 for debug builds under MSVC. Modified: trunk/CSP/CSPSim/Include/CockpitInterface.h =================================================================== --- trunk/CSP/CSPSim/Include/CockpitInterface.h 2005-10-15 20:02:50 UTC (rev 1626) +++ trunk/CSP/CSPSim/Include/CockpitInterface.h 2005-10-15 20:06:43 UTC (rev 1627) @@ -62,8 +62,9 @@ */ class CockpitSwitch: public CockpitElement { public: + typedef simdata::Ref<CockpitSwitch> Ref; // if command == "", no input handlers will be registered. - CockpitSwitch(simdata::Enumeration *enumeration, std::string const &channel, std::string const &command, std::string const &initial); + CockpitSwitch(simdata::Enumeration const *enumeration, std::string const &channel, std::string const &command, std::string const &initial); CockpitSwitch(std::string const &enumeration, std::string const &channel, std::string const &command, std::string const &initial); CockpitSwitch(DataChannel<simdata::EnumLink> *channel, std::string const &command); simdata::EnumLink &state() { return m_State->value(); } @@ -90,7 +91,7 @@ public: virtual void registerChannels(Bus *bus); virtual void bindEvents(InputInterface *pInterface); - virtual void addElement(CockpitElement *element); + virtual CockpitElement* addElement(CockpitElement *element); private: std::vector<CockpitElement::Ref> m_Elements; Modified: trunk/CSP/CSPSim/Source/CockpitInterface.cpp =================================================================== --- trunk/CSP/CSPSim/Source/CockpitInterface.cpp 2005-10-15 20:02:50 UTC (rev 1626) +++ trunk/CSP/CSPSim/Source/CockpitInterface.cpp 2005-10-15 20:06:43 UTC (rev 1627) @@ -26,17 +26,17 @@ #include <CockpitInterface.h> -CockpitSwitch::CockpitSwitch(simdata::Enumeration *states, std::string const &channel, std::string const &command, std::string const &initial): m_Command(command) { +CockpitSwitch::CockpitSwitch(simdata::Enumeration const *states, std::string const &channel, std::string const &command, std::string const &initial): m_Command(command) { assert(states); simdata::EnumLink initial_value(*states, initial); - m_State = DataChannel<simdata::EnumLink>::newShared(channel, initial_value); + m_State = DataChannel<simdata::EnumLink>::newSharedPush(channel, initial_value); } CockpitSwitch::CockpitSwitch(std::string const &states, std::string const &channel, std::string const &command, std::string const &initial): m_Command(command) { assert(!states.empty()); simdata::Enumeration enumeration(states); simdata::EnumLink initial_value(enumeration, initial); - m_State = DataChannel<simdata::EnumLink>::newShared(channel, initial_value); + m_State = DataChannel<simdata::EnumLink>::newSharedPush(channel, initial_value); } CockpitSwitch::CockpitSwitch(DataChannel<simdata::EnumLink> *channel, std::string const &command): m_Command(command), m_State(channel) { @@ -66,21 +66,25 @@ void CockpitSwitch::onToggle() { std::cout << m_Command << " toggle\n"; m_State->value().cycle(); + m_State->push(); } void CockpitSwitch::onCycleNext() { std::cout << m_Command << " next\n"; m_State->value().cycle(); + m_State->push(); } void CockpitSwitch::onCyclePrev() { std::cout << m_Command << " prev\n"; m_State->value().cycleBack(); + m_State->push(); } void CockpitSwitch::onSelect(int state) { m_State->value().set(state); std::cout << m_Command << " select " << m_State->value().getToken() << "\n"; + m_State->push(); } void CockpitInterface::bindEvents(InputInterface *input) { @@ -90,8 +94,9 @@ } } -void CockpitInterface::addElement(CockpitElement *element) { +CockpitElement* CockpitInterface::addElement(CockpitElement *element) { m_Elements.push_back(element); + return element; } void CockpitInterface::registerChannels(Bus *bus) { |