diff --git a/FSM/FSM_vs120.sln b/FSM/FSM_vs120.sln
deleted file mode 100644
index db593c606..000000000
--- a/FSM/FSM_vs120.sln
+++ /dev/null
@@ -1,33 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Express 2013 for Windows Desktop
-VisualStudioVersion = 12.0.40629.0
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FMSc", "FSMc_vs120.vcxproj", "{E12E5C71-79A4-495A-848F-F1710111E610}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- debug_shared|Win32 = debug_shared|Win32
- debug_static_md|Win32 = debug_static_md|Win32
- debug_static_mt|Win32 = debug_static_mt|Win32
- release_shared|Win32 = release_shared|Win32
- release_static_md|Win32 = release_static_md|Win32
- release_static_mt|Win32 = release_static_mt|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {E12E5C71-79A4-495A-848F-F1710111E610}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
- {E12E5C71-79A4-495A-848F-F1710111E610}.debug_shared|Win32.Build.0 = debug_shared|Win32
- {E12E5C71-79A4-495A-848F-F1710111E610}.debug_static_md|Win32.ActiveCfg = debug_static_md|Win32
- {E12E5C71-79A4-495A-848F-F1710111E610}.debug_static_md|Win32.Build.0 = debug_static_md|Win32
- {E12E5C71-79A4-495A-848F-F1710111E610}.debug_static_mt|Win32.ActiveCfg = debug_static_mt|Win32
- {E12E5C71-79A4-495A-848F-F1710111E610}.debug_static_mt|Win32.Build.0 = debug_static_mt|Win32
- {E12E5C71-79A4-495A-848F-F1710111E610}.release_shared|Win32.ActiveCfg = release_shared|Win32
- {E12E5C71-79A4-495A-848F-F1710111E610}.release_shared|Win32.Build.0 = release_shared|Win32
- {E12E5C71-79A4-495A-848F-F1710111E610}.release_static_md|Win32.ActiveCfg = release_static_md|Win32
- {E12E5C71-79A4-495A-848F-F1710111E610}.release_static_md|Win32.Build.0 = release_static_md|Win32
- {E12E5C71-79A4-495A-848F-F1710111E610}.release_static_mt|Win32.ActiveCfg = release_static_mt|Win32
- {E12E5C71-79A4-495A-848F-F1710111E610}.release_static_mt|Win32.Build.0 = release_static_mt|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/FSM/FSMc_vs120.vcxproj b/FSM/FSMc_vs120.vcxproj
deleted file mode 100644
index de878caa1..000000000
--- a/FSM/FSMc_vs120.vcxproj
+++ /dev/null
@@ -1,367 +0,0 @@
-
-
-
-
- debug_shared
- Win32
-
-
- debug_static_md
- Win32
-
-
- debug_static_mt
- Win32
-
-
- release_shared
- Win32
-
-
- release_static_md
- Win32
-
-
- release_static_mt
- Win32
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- FSMc
- {E12E5C71-79A4-495A-848F-F1710111E610}
- FSMc
- Win32Proj
-
-
-
- Application
- MultiByte
- v120
-
-
- Application
- MultiByte
- v120
-
-
- Application
- MultiByte
- v120
-
-
- Application
- MultiByte
- v120
-
-
- Application
- MultiByte
- v120
-
-
- Application
- MultiByte
- v120
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <_ProjectFileVersion>12.0.30501.0
- $(ProjectName)d
- $(ProjectName)d
- $(ProjectName)d
- $(ProjectName)
- $(ProjectName)
- $(ProjectName)
-
-
- bin\
- obj\$(ProjectName)\$(Configuration)\
- true
-
-
- bin\
- obj\$(ProjectName)\$(Configuration)\
- false
-
-
- bin\static_mt\
- obj\$(ProjectName)\$(Configuration)\
- true
-
-
- bin\static_mt\
- obj\$(ProjectName)\$(Configuration)\
- false
-
-
- bin\static_md\
- obj\$(ProjectName)\$(Configuration)\
- true
-
-
- bin\static_md\
- obj\$(ProjectName)\$(Configuration)\
- false
-
-
-
- Disabled
- src;.\include;..\Foundation\include;..\XML\include;..\Util\include;..\Net\include;%(AdditionalIncludeDirectories)
- WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;%(PreprocessorDefinitions)
- true
- true
- EnableFastChecks
- MultiThreadedDebugDLL
- true
- true
- true
- true
-
- Level3
- ProgramDatabase
- Default
-
-
- ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)
- bin\$(TargetName)$(TargetExt)
- ..\lib;%(AdditionalLibraryDirectories)
- true
- true
- bin\$(TargetName).pdb
- Console
- MachineX86
-
-
-
-
- MaxSpeed
- OnlyExplicitInline
- true
- Speed
- true
- src;.\include;..\Foundation\include;..\XML\include;..\Util\include;..\Net\include;%(AdditionalIncludeDirectories)
- WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;%(PreprocessorDefinitions)
- true
- MultiThreadedDLL
- false
- true
- true
- true
-
- Level3
-
- Default
-
-
- ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)
- bin\$(TargetName)$(TargetExt)
- ..\lib;%(AdditionalLibraryDirectories)
- false
- Console
- true
- true
- MachineX86
-
-
-
-
- Disabled
- src;.\include;..\Foundation\include;..\XML\include;..\Util\include;..\Net\include;%(AdditionalIncludeDirectories)
- WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)
- true
- true
- EnableFastChecks
- MultiThreadedDebug
- true
- true
- true
- true
-
- Level3
- ProgramDatabase
- Default
-
-
- iphlpapi.lib;winmm.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)
- bin\static_mt\$(TargetName)$(TargetExt)
- ..\lib;%(AdditionalLibraryDirectories)
- true
- true
- bin\static_mt\$(TargetName).pdb
- Console
- MachineX86
-
-
-
-
- MaxSpeed
- OnlyExplicitInline
- true
- Speed
- true
- src;.\include;..\Foundation\include;..\XML\include;..\Util\include;..\Net\include;%(AdditionalIncludeDirectories)
- WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)
- true
- MultiThreaded
- false
- true
- true
- true
-
- Level3
-
- Default
-
-
- iphlpapi.lib;winmm.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)
- bin\static_mt\$(TargetName)$(TargetExt)
- ..\lib;%(AdditionalLibraryDirectories)
- false
- Console
- true
- true
- MachineX86
-
-
-
-
- Disabled
- src;.\include;..\Foundation\include;..\XML\include;..\Util\include;..\Net\include;%(AdditionalIncludeDirectories)
- WIN32;_DEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)
- true
- true
- EnableFastChecks
- MultiThreadedDebugDLL
- true
- true
- true
- true
-
- Level3
- ProgramDatabase
- Default
-
-
- iphlpapi.lib;winmm.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)
- bin\static_md\$(TargetName)$(TargetExt)
- ..\lib;%(AdditionalLibraryDirectories)
- true
- true
- bin\static_md\$(TargetName).pdb
- Console
- MachineX86
-
-
-
-
- MaxSpeed
- OnlyExplicitInline
- true
- Speed
- true
- src;.\include;..\Foundation\include;..\XML\include;..\Util\include;..\Net\include;%(AdditionalIncludeDirectories)
- WIN32;NDEBUG;_WINDOWS;WINVER=0x0500;POCO_STATIC;%(PreprocessorDefinitions)
- true
- MultiThreadedDLL
- false
- true
- true
- true
-
- Level3
-
- Default
-
-
- iphlpapi.lib;winmm.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)
- bin\static_md\$(TargetName)$(TargetExt)
- ..\lib;%(AdditionalLibraryDirectories)
- false
- Console
- true
- true
- MachineX86
-
-
-
-
-
\ No newline at end of file
diff --git a/FSM/FSMc_vs120.vcxproj.filters b/FSM/FSMc_vs120.vcxproj.filters
deleted file mode 100644
index 336dae463..000000000
--- a/FSM/FSMc_vs120.vcxproj.filters
+++ /dev/null
@@ -1,75 +0,0 @@
-
-
-
-
- {60fd8794-fb4f-47a7-822e-b7eeaedaa5bc}
-
-
- {718e55ba-57a5-460a-b9d6-2cc3e8e17da9}
-
-
- {a8451f20-ad5b-42c6-8137-7d9f5f4dc222}
-
-
-
-
- parser
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/FSM/Makefile b/FSM/Makefile
deleted file mode 100644
index da2de86bc..000000000
--- a/FSM/Makefile
+++ /dev/null
@@ -1,77 +0,0 @@
-#
-# Makefile
-#
-# $Id: //poco/1.4/FSM/Makefile#1 $
-#
-# Makefile for Poco C++ Finite State Machine Compiler
-#
-
-include $(POCO_BASE)/build/rules/global
-INCLUDE += -Isrc
-CXXFLAGS += -std=c++11 -fno-operator-names
-
-objects = \
-Action \
-ActionForCpp \
-Actions \
-Argument \
-ArgumentForCpp \
-BinaryOperation \
-BinaryOperationForCpp \
-Character \
-Comment \
-CompilableForCpp \
-Dumper \
-Element \
-ElementForCpp \
-Entry \
-EntryForCpp \
-Exit \
-ExitForCpp \
-Expression \
-ExpressionForCpp \
-FactoryForCpp \
-FSM \
-fsmc \
-FSMForCpp \
-Function \
-FunctionForCpp \
-Guard \
-GuardForCpp \
-Identifier \
-IndentStream \
-Keyword \
-Literal \
-LiteralForCpp \
-Map \
-MapForCpp \
-Number \
-Operation \
-Operator \
-Parameter \
-ParameterForCpp \
-Parser \
-Print \
-Reference \
-ReferenceForCpp \
-State \
-StateForCpp \
-String \
-Token \
-Tokenizer \
-Transition \
-TransitionForCpp \
-UnaryOperation \
-UnaryOperationForCpp \
-Variable \
-VariableForCpp
-
-ifdef POCO_UNBUNDLED
- SYSLIBS += -lz -lpcre -lexpat
-endif
-
-target = fsmc
-target_version = 1
-target_libs = PocoUtil PocoXML PocoJSON PocoFoundation
-
-include $(POCO_BASE)/build/rules/exec
diff --git a/FSM/SMC Manual_6_6_0.pdf b/FSM/SMC Manual_6_6_0.pdf
deleted file mode 100644
index 555f488b2..000000000
Binary files a/FSM/SMC Manual_6_6_0.pdf and /dev/null differ
diff --git a/FSM/SmcMan_6_6_0.tgz b/FSM/SmcMan_6_6_0.tgz
deleted file mode 100644
index 93aa86a5b..000000000
Binary files a/FSM/SmcMan_6_6_0.tgz and /dev/null differ
diff --git a/FSM/fsmc.properties b/FSM/fsmc.properties
deleted file mode 100644
index d17343599..000000000
--- a/FSM/fsmc.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-logging.loggers.root.channel.class = ConsoleChannel
-
-logging.formatters.full.class = PatternFormatter
-logging.formatters.full.pattern = %Y-%m-%d %H:%M:%S %s: [%q] %t
-
-logging.channels.console.class = ConsoleChannel
-logging.channels.console.formatter = full
-
-logging.channels.fsmc.class = FileChannel
-logging.channels.fsmc.path = fsmc.log
-logging.channels.fsmc.formatter = full
-
-logging.channels.log.class = SplitterChannel
-logging.channels.log.channels = console,fsmc
-
-logging.loggers.fsmc.name = fsmc
-logging.loggers.fsmc.channel = fsmc
-logging.loggers.fsmc.level = debug
-
diff --git a/FSM/include/Poco/FSM/statemap.h b/FSM/include/Poco/FSM/statemap.h
deleted file mode 100644
index 558dbf3f3..000000000
--- a/FSM/include/Poco/FSM/statemap.h
+++ /dev/null
@@ -1,712 +0,0 @@
-#ifndef _H_STATEMAP
-#define _H_STATEMAP
-
-//
-// The contents of this file are subject to the Mozilla Public
-// License Version 1.1 (the "License"); you may not use this file
-// except in compliance with the License. You may obtain a copy
-// of the License at http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an
-// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-// implied. See the License for the specific language governing
-// rights and limitations under the License.
-//
-// The Original Code is State Machine Compiler (SMC).
-//
-// The Initial Developer of the Original Code is Charles W. Rapp.
-// Portions created by Charles W. Rapp are
-// Copyright (C) 2000 - 2007. Charles W. Rapp.
-// All Rights Reserved.
-//
-// Contributor(s):
-//
-// Namespace
-// statemap
-//
-// Description
-// This namespace contains the finite state machine context
-// class. The user can derive FSM contexts from this class and
-// interface to them with the methods of this class.
-//
-// Notes
-// The finite state machine needs to be initialized to the
-// starting state of the FSM. This must be done manually in
-// the constructor of the derived class.
-//
-// Author
-// C. W. Rapp
-//
-// RCS ID
-// Id: statemap.h,v 1.19 2014/09/06 19:31:28 fperrad Exp
-//
-// CHANGE LOG
-// (See bottom of file)
-//
-#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
-#if defined(SMC_USES_IOSTREAMS)
-#include
-#endif // SMC_USES_IOSTREAMS
-#if defined(SMC_NO_EXCEPTIONS)
-#include
-#endif // SMC_NO_EXCEPTIONS
-#include
-#elif defined(WIN32)
-#if defined(SMC_NO_EXCEPTIONS)
-#include
-#endif // SMC_NO_EXCEPTIONS
-#else
-#if defined(SMC_NO_EXCEPTIONS)
-#include
-#endif // SMC_NO_EXCEPTIONS
-#include
-#endif
-#if ! defined(SMC_NO_EXCEPTIONS)
-#include
-#include
-#endif
-
-#define MAX_NAME_LEN 32
-
-namespace statemap {
-//---------------------------------------------------------------
-// Routines.
-//
-
-#ifdef SMC_FIXED_STACK
-// When static memory is used, a string has only one copy.
-inline char* copyString(const char *s) {
- // Cast your const upon the waters and see what blows up.
- return (const_cast(s));
-}
-#else
-inline char* copyString(const char *s) {
- char *retval = nullptr;
-
- if (s != nullptr) {
- retval = new char[MAX_NAME_LEN + 1];
- retval[MAX_NAME_LEN] = '\0';
- (void) std::strncpy(retval, s, MAX_NAME_LEN);
- }
-
- return (retval);
-}
-#endif
-//---------------------------------------------------------------
-// Exception Classes.
-//
-
-//#define SMC_NO_EXCEPTIONS
-#ifndef SMC_NO_EXCEPTIONS
-// Base class for all SMC exceptions.
-class SmcException : public std::runtime_error {
- public:
-
- virtual ~SmcException() throw() {
- };
-
- protected:
- SmcException(const std::string& reason)
- : std::runtime_error(reason) {
- };
-
- private:
- SmcException();
-};
-
-#ifdef SMC_FIXED_STACK
-class PushOnFullStateStackException :
- public SmcException {
- //-----------------------------------------------------------
- // Member methods.
- //
- public:
-
- // Default constructor.
- PushOnFullStateStackException()
- : SmcException("cannot push on full state stack") {
- };
-
- // Destructor.
- virtual ~PushOnFullStateStackException() throw() {
- };
-
- protected:
- private:
-
- //-----------------------------------------------------------
- // Member data.
- //
- public:
- protected:
- private:
-};
-#endif
-
-// This class is thrown when a pop is issued on an empty
-// state stack.
-class PopOnEmptyStateStackException :
- public SmcException {
- public:
-
- // Default constructor.
- PopOnEmptyStateStackException()
- : SmcException("no state to pop from state stack") {
- };
-
- // Destructor.
- virtual ~PopOnEmptyStateStackException() throw() {
- };
-
-};
-
-// This class is thrown when a transition is issued
-// but there is no current state. This happens when
-// a transition is issued from within a transition
-// action.
-class StateUndefinedException :
- public SmcException {
- public:
-
- // Default constructor.
- StateUndefinedException()
- : SmcException("transition invoked while in transition") {
- };
-
- // Destructor.
- virtual ~StateUndefinedException() throw() {
- };
-
-};
-
-// This class is thrown when a transition is issued
-// but there is no code to handle it.
-class TransitionUndefinedException :
- public SmcException {
- public:
-
- // Default constructor.
- TransitionUndefinedException()
- : SmcException("no such transition in current state"),
- _state(nullptr),
- _transition(nullptr) {
- };
-
- // Construct an exception using the specified state
- // and transition.
- TransitionUndefinedException(const char *state,
- const char *transition)
- : SmcException("no such transition in current state"),
- _state(copyString(state)),
- _transition(copyString(transition)) {
- };
-
- // Copy constructor.
- TransitionUndefinedException(
- const TransitionUndefinedException& ex)
- : SmcException("no such transition in current state"),
- _state(copyString(ex._state)),
- _transition(copyString(ex._transition)) {
- };
-
- virtual ~TransitionUndefinedException() throw() {
- if (_state != nullptr) {
- delete[] _state;
- _state = nullptr;
- }
-
- if (_transition != nullptr) {
- delete[] _transition;
- _transition = nullptr;
- }
- };
-
- const TransitionUndefinedException&
- operator=(const TransitionUndefinedException& ex) {
- // Don't do self assignment.
- if (this != &ex) {
- if (_state != nullptr) {
- delete[] _state;
- _state = nullptr;
- }
-
- if (_transition != nullptr) {
- delete[] _transition;
- _transition = nullptr;
- }
-
- _state = copyString(ex._state);
- _transition = copyString(ex._transition);
- }
-
- return (*this);
- };
-
- // Returns the state. May be nullptr.
- const char* getState() const {
- return(_state);
- };
-
- // Returns the transition. May be nullptr.
- const char* getTransition() const {
- return (_transition);
- };
-
- private:
- char *_state;
- char *_transition;
-};
-
-// This class is thrown when a state ID is either less than
-// the minimal value or greater than the maximal value.
-class IndexOutOfBoundsException :
- public SmcException {
- public:
-
- IndexOutOfBoundsException()
- : SmcException("index out of bounds"),
- _index(0),
- _minIndex(0),
- _maxIndex(0) {
- };
-
- // Constructs an exception using the specified index,
- // minimum index and maximum index.
- IndexOutOfBoundsException(const int index,
- const int minIndex,
- const int maxIndex)
- : SmcException("index out of bounds"),
- _index(index),
- _minIndex(minIndex),
- _maxIndex(maxIndex) {
- };
-
- // Copy constructor.
- IndexOutOfBoundsException(
- const IndexOutOfBoundsException& ex)
- : SmcException("index out of bounds"),
- _index(ex._index),
- _minIndex(ex._minIndex),
- _maxIndex(ex._maxIndex) {
- };
-
- virtual ~IndexOutOfBoundsException() throw() {
- };
-
- const IndexOutOfBoundsException&
- operator=(const IndexOutOfBoundsException& ex) {
- // Don't do self assignment.
- if (this != &ex) {
- _index = ex._index;
- _minIndex = ex._minIndex;
- _maxIndex = ex._maxIndex;
- }
-
- return (*this);
- };
-
- // Returns the out-of-bounds index.
- int getIndex() const {
- return(_index);
- };
-
- // Returns the minimum allowed index value.
- int getMinIndex() const {
- return (_minIndex);
- };
-
- // Returns the maximum allowed index value.
- int getMaxIndex() const {
- return (_maxIndex);
- };
-
- private:
- int _index;
- int _minIndex;
- int _maxIndex;
-};
-#endif
-//
-// end of Exception Classes.
-//---------------------------------------------------------------
-
-class State {
-public:
- const char* getName() const {
- return (_name);
- };
-
- int getId() const {
- return (_stateId);
- }
-
-protected:
- State() = delete;
- State(const State&) = delete;
-
- State(const char *name, int stateId)
- : _name(nullptr),
- _stateId(stateId) {
- if (name != nullptr) {
- _name = copyString(name);
- } else {
- _name = copyString("NAME NOT SET");
- }
- };
-
- virtual ~State() {
-#ifndef SMC_FIXED_STACK
- if (_name != nullptr) {
- delete[] _name;
- _name = nullptr;
- }
-#endif
- };
-
- private:
- public:
- protected:
- char *_name; // This state's printable name.
- int _stateId; // This state's unique identifier.
-
- private:
-};
-
-enum class Event {
- Enter,
- Leave,
- Switch,
- Transition,
- Push,
- Pop
-};
-
-class Notifier {
- public:
- virtual void operator()(const Event& event, const char* s) = 0;
- virtual void operator()(const Event& event, const State* state) = 0;
- virtual void operator()(const Event& event, const State* previous, const State* next) = 0;
-};
-class FSMContext {
- private:
- class StateEntry {
- public:
- StateEntry(State *state, StateEntry *next)
- : _state(state),
- _next(next) {
- };
-
- ~StateEntry() {
- _state = nullptr;
- _next = nullptr;
- };
-
- State* getState() {
- return(_state);
- };
-
- const State* getState() const {
- return(_state);
- };
-
- StateEntry* getNext() {
- return(_next);
- };
-
- private:
- State *_state;
- StateEntry *_next;
-
- friend class FSMContext;
- };
-
- public:
-
- virtual ~FSMContext() {
-#ifdef SMC_FIXED_STACK
- _transition = nullptr;
-#else // ! SMC_FIXED_STACK
- StateEntry *state;
-
- if (_transition != nullptr) {
- delete[] _transition;
- _transition = nullptr;
- }
-
- // But we did allocate the state stack.
- while (_state_stack != nullptr) {
- state = _state_stack;
- _state_stack = _state_stack->_next;
- delete state;
- }
-#endif // ! SMC_FIXED_STACK
- };
-
- FSMContext& operator=(const FSMContext& fsm) {
- // Don't do the assignment if the left and right
- // hand sides are the same object.
- if (this != &fsm) {
- _state = fsm._state;
- }
-
- return(*this);
- };
-
- // Starts the finite state machine running by executing
- // the initial state's entry actions.
- virtual void enterStartState()=0;
-
- // Exact same object (is it me?)
- int same(const FSMContext& fsm) const {
- return(this == &fsm);
- };
-
- bool getDebugFlag() {
- return(_debug_flag);
- };
-
- void setDebugFlag(bool flag) {
- _debug_flag = flag;
- };
-
- // Is this state machine already inside a transition?
- // Yes if state is null.
- bool isInTransition() const {
- return(_state == nullptr ? true : false);
- };
-
- // Returns the current transition's name.
- // Used only for debugging purposes.
- char* getTransition() const {
- return (_transition);
- };
-
- // Saves away the transition name only if debugging
- // is turned on.
- void setTransition(const char *transition) {
-#ifndef SMC_FIXED_STACK
- if (_transition != nullptr) {
- delete[] _transition;
- _transition = nullptr;
- }
-#endif // ! SMC_FIXED_STACK
-
- _transition = copyString(transition);
- if (getDebugFlag() && transition)
- _notify(Event::Transition, transition);
-
- return;
- };
-
- // Clears the current state.
- void clearState() {
- _previous_state = _state;
- _state = nullptr;
- };
-
- // Returns the state which a transition left.
- // May be nullptr.
- State* getPreviousState() {
- return (_previous_state);
- }
-
- // Sets the current state to the specified state.
- void setState(const State& state) {
- // clearState() is not called when a transition has
- // no actions, so set _previous_state to _state in
- // that situation. We know clearState() was not
- // called when _state is not null.
- if (_state != nullptr) {
- if (_debug_flag) {
- _notify(Event::Leave, _state);
- }
- _previous_state = _state;
- }
-
- _state = const_cast(&state);
-
- if (_debug_flag) {
- _notify(Event::Switch, _previous_state, _state);
- }
- };
-
-#ifdef SMC_FIXED_STACK
- // Returns true if the state stack is empty and false
- // otherwise.
- bool isStateStackEmpty() const {
- return (_state_stack_depth == 0);
- }
-
- // Returns the state stack's depth.
- int getStateStackDepth() const {
- return (_state_stack_depth);
- }
-
- // Push the current state on top of the state stack
- // and make the specified state the current state.
- void pushState(const State& state) {
-#ifdef SMC_NO_EXCEPTIONS
- assert (_state_stack_depth < SMC_STATE_STACK_SIZE);
-#else
- if (_state_stack_depth == SMC_STATE_STACK_SIZE) {
- throw PushOnFullStateStackException();
- }
-#endif
-
- // Do the push only if there is a state to be pushed
- // on the stack.
- if (_state != nullptr) {
- _state_stack[_state_stack_depth] = _state;
- ++_state_stack_depth;
- }
-
- _previous_state = _state;
- _state = const_cast(&state);
-
- if (_debug_flag == true) {
- _notify(Event::PUSH_STATE, _state);
- }
- };
-
- // Make the state on top of the state stack the
- // current state.
- void popState() {
- // Popping when there was no previous push is an error.
-#ifdef SMC_NO_EXCEPTIONS
- poco_assert(_state_stack_depth > 0);
-#else
- if (_state_stack_depth == 0) {
- throw PopOnEmptyStateStackException();
- }
-#endif
-
- _previous_state = _state;
- --_state_stack_depth;
- _state = _state_stack[_state_stack_depth];
-
- if (_debug_flag == true) {
- _notify(Event::POP, _state);
- }
- };
-
- // Remove all states from the state stack.
- void emptyStateStack() {
- _state_stack_depth = 0;
- };
-#else // ! SMC_FIXED_STACK
- // Returns true if the state stack is empty and false
- // otherwise.
- bool isStateStackEmpty() const {
- return (_state_stack == nullptr);
- }
-
- // Returns the state stack's depth.
- int getStateStackDepth() const {
- StateEntry *state_ptr;
- int retval;
-
- for (state_ptr = _state_stack, retval = 0;
- state_ptr != nullptr;
- state_ptr = state_ptr->getNext(), ++retval)
- ;
-
- return (retval);
- }
-
- // Push the current state on top of the state stack
- // and make the specified state the current state.
- void pushState(const State& state) {
- StateEntry *new_entry;
-
- // Do the push only if there is a state to be pushed
- // on the stack.
- if (_state != nullptr) {
- new_entry = new StateEntry(_state, _state_stack);
- _state_stack = new_entry;
- }
-
- _previous_state = _state;
- _state = const_cast(&state);
-
- if (_debug_flag == true) {
- _notify(Event::Push, _state);
- }
- };
-
- // Make the state on top of the state stack the
- // current state.
- void popState() {
- StateEntry *entry;
-
- // Popping when there was no previous push is an error.
-#ifdef SMC_NO_EXCEPTIONS
- poco_assert(_state_stack != nullptr);
-#else
- if (_state_stack == nullptr) {
- throw PopOnEmptyStateStackException();
- }
-#endif // SMC_NO_EXCEPTIONS
-
- _previous_state = _state;
- _state = _state_stack->getState();
- entry = _state_stack;
- _state_stack = _state_stack->getNext();
- delete entry;
-
- if (_debug_flag == true) {
- _notify(Event::Pop, _state);
- }
- };
-
- // Remove all states from the state stack.
- void emptyStateStack() {
- StateEntry *state_ptr, *next_ptr;
-
- for (state_ptr = _state_stack; state_ptr != nullptr; state_ptr = next_ptr) {
- next_ptr = state_ptr->getNext();
- delete state_ptr;
- }
- _state_stack = nullptr;
- };
-#endif
-
- protected:
- FSMContext(const FSMContext&) = delete;
- // Default constructor.
- FSMContext(Notifier& notifier, const State& state)
- : _state(const_cast(&state)),
- _previous_state(nullptr),
-#ifdef SMC_FIXED_STACK
- _state_stack_depth(0),
-#else
- _state_stack(nullptr),
-#endif
- _transition(nullptr),
- _debug_flag(false),
- _notify(notifier)
- {};
-
- public:
- protected:
-
- // The current state of the finite state machine.
- State *_state;
-
- // Remember which state a transition left.
- State *_previous_state;
-
- // The stack of pushed states.
-#ifdef SMC_FIXED_STACK
- State* _state_stack[SMC_STATE_STACK_SIZE];
- int _state_stack_depth;
-#else
- StateEntry *_state_stack;
-#endif
- char *_transition;
-
- private:
- bool _debug_flag;
- Notifier& _notify;
-};
-}
-#endif
diff --git a/FSM/samples/Makefile b/FSM/samples/Makefile
deleted file mode 100644
index 27105cd41..000000000
--- a/FSM/samples/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-#
-# Makefile
-#
-# $Id: //poco/1.4/PageCompiler/samples/Makefile#1 $
-#
-# Makefile for Poco PageCompiler Samples
-#
-
-.PHONY: projects
-clean all: projects
-projects:
- $(MAKE) -C TrafficLight $(MAKECMDGOALS)
diff --git a/FSM/samples/TCP/AppClient.cpp b/FSM/samples/TCP/AppClient.cpp
deleted file mode 100644
index 1c7f2a45a..000000000
--- a/FSM/samples/TCP/AppClient.cpp
+++ /dev/null
@@ -1,377 +0,0 @@
-//
-// The contents of this file are subject to the Mozilla Public
-// License Version 1.1 (the "License"); you may not use this file
-// except in compliance with the License. You may obtain a copy
-// of the License at http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an
-// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-// implied. See the License for the specific language governing
-// rights and limitations under the License.
-//
-// The Original Code is State Machine Compiler (SMC).
-//
-// The Initial Developer of the Original Code is Charles W. Rapp.
-// Portions created by Charles W. Rapp are
-// Copyright (C) 2000 - 2007. Charles W. Rapp.
-// All Rights Reserved.
-//
-// Contributor(s):
-//
-// Name
-// AppClient.cpp
-//
-// Description
-// TcpClient listener object.
-//
-// RCS ID
-// $Id: AppClient.cpp,v 1.6 2007/12/28 12:34:40 cwrapp Exp $
-//
-// CHANGE LOG
-// $Log: AppClient.cpp,v $
-// Revision 1.6 2007/12/28 12:34:40 cwrapp
-// Version 5.0.1 check-in.
-//
-// Revision 1.5 2005/05/28 13:31:18 cwrapp
-// Updated C++ examples.
-//
-// Revision 1.0 2003/12/14 19:34:34 charlesr
-// Initial revision
-//
-
-#include "AppClient.h"
-#include "AppServer.h"
-#include "Eventloop.h"
-#if defined(WIN32)
-#include
-#include
-#include
-#else
-#include
-#endif
-#include
-#include
-
-using namespace std;
-
-// Externally defined global variables.
-extern Eventloop *Gevent_loop;
-
-// Class variables.
-int AppClient::_initFlag = 0;
-const long AppClient::MIN_SLEEP_TIME = 100;
-const long AppClient::MAX_SLEEP_TIME = 30000;
-
-//---------------------------------------------------------------
-// AppClient() (Public)
-// Default constructor.
-//
-AppClient::AppClient()
-: _client_socket(NULL),
- _owner(NULL),
- _host(),
- _messageCount(0)
-{}
-
-//---------------------------------------------------------------
-// AppClient(const char*, TcpClient&, AppServer&) (Public)
-// An "accept" construct.
-//
-AppClient::AppClient(const string& host,
- TcpClient& tcp_client,
- AppServer& owner)
-: _client_socket(&tcp_client),
- _owner(&owner),
- _host(host),
- _messageCount(0)
-{
- // Tell the client that this object is now listening to it.
- tcp_client.setListener(*this);
-
- // Since this client is already connected, set the
- // random transmit timer.
- setTransmitTimer();
- return;
-} // end of AppClient::AppClient(TcpClient&, AppServer&)
-
-//---------------------------------------------------------------
-// ~AppClient() (Public)
-// Destructor.
-//
-AppClient::~AppClient()
-{
- if (_client_socket != NULL)
- {
- delete _client_socket;
- _client_socket = NULL;
- }
-
- return;
-} // end of AppClient::~AppClient()
-
-//---------------------------------------------------------------
-// getHost() const (Public)
-// Return the host name.
-//
-const string& AppClient::getHost() const
-{
- return(_host);
-} // end of AppClient::getHost() const
-
-//---------------------------------------------------------------
-// open(const string&, const sockaddr_in&) (Public)
-// Open a connection to the named TCP service.
-//
-void AppClient::open(const string& host,
- const sockaddr_in& address)
-{
- if (_client_socket == NULL)
- {
- // Store away the host name.
- _host = host;
-
- cout << "Opening connection to "
- << host
- << ":"
- << ntohs(address.sin_port)
- << " ... ";
-
- // Create the client object and open it.
- _client_socket = new TcpClient(*this);
- _client_socket->open(address);
- }
-
- return;
-} // end of AppClient::open(const string&, const sockaddr_in&)
-
-//---------------------------------------------------------------
-// close() (Public)
-// Close the client connection.
-//
-void AppClient::close()
-{
- if (_client_socket != NULL)
- {
- cout << "Closing connection to "
- << _host
- << ":"
- << ntohs((_client_socket->getServerAddress()).sin_port)
- << " ... ";
-
- _client_socket->doClose();
- }
-
- return;
-} // end of AppClient::close()
-
-//---------------------------------------------------------------
-// opened(TcpConnection&) (Public)
-// TCP client connection successful.
-//
-void AppClient::opened(TcpConnection&)
-{
- cout << "open successful." << endl;
-
- // Set the transmit timer.
- setTransmitTimer();
-
- return;
-} // end of AppClient::opened(TcpConnection&)
-
-//---------------------------------------------------------------
-// openFailed(const char*, TcpConnection&) (Public)
-// TCP client connection failed.
-//
-void AppClient::openFailed(const char *reason, TcpConnection&)
-{
- void socketClosed();
-
- cout << "open failed";
- if (reason == NULL)
- {
- cout << "." << endl;
- }
- else
- {
- cout << " - "
- << reason
- << endl;
- }
-
- // Let the application know that the socket is closed.
- socketClosed();
-
- return;
-} // end of AppClient::openFailed(const char*, TcpConnection&)
-
-//---------------------------------------------------------------
-// transmitted(TcpConnection&) (Public)
-// Data successfully transmitted.
-//
-void AppClient::transmitted(TcpConnection&)
-{
- // Set the timer for the next transmission.
- setTransmitTimer();
-
- cout << "transmit successful." << endl;
- return;
-} // end of AppClient::transmitted(TcpConnection&)
-
-//---------------------------------------------------------------
-// transmitFailed(const char*, TcpConnection&) (Public)
-// Failed to send data to far-end.
-//
-void AppClient::transmitFailed(const char *reason, TcpConnection&)
-{
- cout << "transmit failed - " << reason << "." << endl;
- return;
-} // end of AppClient::transmitFailed(const char*, TcpConnection&)
-
-//---------------------------------------------------------------
-// receive(const char*, int, TcpConnection&) (Public)
-// Received data from far end.
-//
-void AppClient::receive(const char *data,
- int size,
- TcpConnection&)
-{
- const sockaddr_in& address = _client_socket->getServerAddress();
- char *string = new char[size + 1];
-
- // Turn the data into a string.
- (void) memcpy(string, data, size);
- string[size] = '\0';
-
- cout << "Received data from "
- << inet_ntoa(address.sin_addr)
- << ":"
- << ntohs(address.sin_port)
- << ": \""
- << string
- << "\""
- << endl;
-
- delete[] string;
-
- return;
-} // end of AppClient::receive(const char*, int, TcpConnection&)
-
-//---------------------------------------------------------------
-// halfClosed(TcpConnection&) (Public)
-// This far end has closed its connection. Close down this side.
-//
-void AppClient::halfClosed(TcpConnection&)
-{
- const sockaddr_in& address = _client_socket->getServerAddress();
-
- cout << "Connection from "
- << _host
- << ":"
- << address.sin_port
- << " has closed its side."
- << endl
- << "Closing connection to "
- << _host
- << ":"
- << ntohs(address.sin_port)
- << " ... ";
-
- // Stop the transmit timer if running.
- Gevent_loop->stopTimer("TRANSMIT_TIMER", *this);
-
- // When this timer expires, close this end of the connection,
- // after waiting one millisecond.
- Gevent_loop->startTimer("CLOSE_TIMER", 1, *this);
-
- return;
-} // end of AppClient::halfClosed(TcpConnection&)
-
-//---------------------------------------------------------------
-// closed(const char*, TcpConnection&) (Public)
-// This client connection is closed.
-//
-void AppClient::closed(const char*, TcpConnection&)
-{
- void socketClosed();
-
- cout << "closed." << endl;
-
- // Stop the transmit timer if running.
- Gevent_loop->stopTimer("TRANSMIT_TIMER", *this);
-
- // If this is an accepted connection, tell the service owner
- // that this connection is gone.
- if (_owner != NULL)
- {
- _owner->clientClosed(*this);
- }
- else
- {
- // Tell the client application that this connection is
- // closed.
- socketClosed();
- }
-
- return;
-} // end of AppClient::closed(const char*, TcpConnection&)
-
-//---------------------------------------------------------------
-// handleTimeout(const char*) (Public)
-// Time to send another message.
-//
-void AppClient::handleTimeout(const char *name)
-{
- if (strcmp(name, "TRANSMIT_TIMER") == 0)
- {
- char message[30];
- const sockaddr_in& address = _client_socket->getServerAddress();
-
- (void) sprintf(message,
- "This is message #%d.",
- ++_messageCount);
-
- cout << "Transmitting to "
- << _host
- << ":"
- << ntohs(address.sin_port)
- << ": \""
- << message
- << "\" ... ";
-
- _client_socket->transmit(message, 0, strlen(message));
- }
- else if (strcmp(name, "CLOSE_TIMER") == 0)
- {
- _client_socket->doClose();
- }
-
- return;
-} // end of AppClient::handleTimeout(const char*)
-
-//---------------------------------------------------------------
-// setTransmitTimer() (Private)
-// Set the transmit timer to expire some random time in the
-// future.
-//
-void AppClient::setTransmitTimer()
-{
- long duration;
-
- // Initialize the random number generator, if necessary.
- if (_initFlag == 0)
- {
- srand(time(NULL));
- _initFlag = 1;
- }
-
- // Set the next tranmission to some random time.
- duration = ((long) rand()) % MAX_SLEEP_TIME;
- if (duration < MIN_SLEEP_TIME)
- {
- duration = MIN_SLEEP_TIME;
- }
-
- Gevent_loop->startTimer("TRANSMIT_TIMER", duration, *this);
-
- return;
-} // end of AppClient::setTransmitTimer()
diff --git a/FSM/samples/TCP/AppClient.h b/FSM/samples/TCP/AppClient.h
deleted file mode 100644
index 8188a3738..000000000
--- a/FSM/samples/TCP/AppClient.h
+++ /dev/null
@@ -1,135 +0,0 @@
-#ifndef _H_APPCLIENT
-#define _H_APPCLIENT
-
-//
-// The contents of this file are subject to the Mozilla Public
-// License Version 1.1 (the "License"); you may not use this file
-// except in compliance with the License. You may obtain a copy
-// of the License at http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an
-// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-// implied. See the License for the specific language governing
-// rights and limitations under the License.
-//
-// The Original Code is State Machine Compiler (SMC).
-//
-// The Initial Developer of the Original Code is Charles W. Rapp.
-// Portions created by Charles W. Rapp are
-// Copyright (C) 2000 - 2007. Charles W. Rapp.
-// All Rights Reserved.
-//
-// Contributor(s):
-//
-// Name
-// AppClient.h
-//
-// Description
-// Encapsulates a TcpClient object.
-//
-// RCS ID
-// $Id: AppClient.h,v 1.6 2009/03/01 18:20:38 cwrapp Exp $
-//
-// CHANGE LOG
-// $Log: AppClient.h,v $
-// Revision 1.6 2009/03/01 18:20:38 cwrapp
-// Preliminary v. 6.0.0 commit.
-//
-// Revision 1.5 2007/12/28 12:34:40 cwrapp
-// Version 5.0.1 check-in.
-//
-// Revision 1.4 2005/05/28 13:31:18 cwrapp
-// Updated C++ examples.
-//
-// Revision 1.0 2003/12/14 19:34:49 charlesr
-// Initial revision
-//
-
-#include "TcpClient.h"
-#include "TcpServer.h"
-#include "TcpConnectionListener.h"
-#include
-
-// Foward declarations.
-class AppServer;
-
-class AppClient :
- /* implements */ public TcpConnectionListener,
- /* implements */ public TimerListener
-{
-// Member functions.
-public:
-
- // Default constructor.
- AppClient();
-
- // Create a client around an accepted connection.
- AppClient(const std::string& host,
- TcpClient& client,
- AppServer& owner);
-
- virtual ~AppClient();
-
- const std::string& getHost() const;
-
- // Create a TCP client object and open a connection to the
- // specified service.
- void open(const std::string& host,
- const sockaddr_in& address);
-
- // Close the TCP service.
- void close();
-
- // TCP connection listener callback methods.
- void opened(TcpConnection& connection);
- void openFailed(const char *reason,
- TcpConnection& connection);
- void transmitted(TcpConnection& connection);
- void transmitFailed(const char *reason,
- TcpConnection& connection);
- void receive(const char *data,
- int size,
- TcpConnection& connection);
- void halfClosed(TcpConnection& connection);
- void closed(const char *reason,
- TcpConnection& connection);
-
- // Clients never receive this event.
- void accepted(TcpClient&, TcpServer&) {};
-
- // Timer listener callback method.
- void handleTimeout(const char *name);
-
-protected:
-private:
-
- // Randomly set the transmit time.
- void setTransmitTimer();
-
-// Member data.
-public:
-protected:
-private:
-
- // The TCP service itself.
- TcpClient *_client_socket;
-
- // If this was an accepted client connection, _owner points
- // to the parent TCP service. This will be NULL otherwise.
- AppServer *_owner;
-
- // The host to which we are connected.
- std::string _host;
-
- // Every time a message is sent, increment this counter.
- int _messageCount;
-
- // Initialize the random number generator once per process.
- static int _initFlag;
-
- // Class constants. Minimum and Maximum transmit timeout.
- const static long MIN_SLEEP_TIME;
- const static long MAX_SLEEP_TIME;
-};
-
-#endif
diff --git a/FSM/samples/TCP/AppServer.cpp b/FSM/samples/TCP/AppServer.cpp
deleted file mode 100644
index 92a3d1ec5..000000000
--- a/FSM/samples/TCP/AppServer.cpp
+++ /dev/null
@@ -1,285 +0,0 @@
-//
-// The contents of this file are subject to the Mozilla Public
-// License Version 1.1 (the "License"); you may not use this file
-// except in compliance with the License. You may obtain a copy
-// of the License at http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an
-// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-// implied. See the License for the specific language governing
-// rights and limitations under the License.
-//
-// The Original Code is State Machine Compiler (SMC).
-//
-// The Initial Developer of the Original Code is Charles W. Rapp.
-// Portions created by Charles W. Rapp are
-// Copyright (C) 2000 - 2007. Charles W. Rapp.
-// All Rights Reserved.
-//
-// Contributor(s):
-//
-// Name
-// AppServer.cpp
-//
-// Description
-// Encapsulates a TcpServer object.
-//
-// RCS ID
-// $Id: AppServer.cpp,v 1.5 2007/12/28 12:34:40 cwrapp Exp $
-//
-// CHANGE LOG
-// $Log: AppServer.cpp,v $
-// Revision 1.5 2007/12/28 12:34:40 cwrapp
-// Version 5.0.1 check-in.
-//
-// Revision 1.4 2005/05/28 13:31:18 cwrapp
-// Updated C++ examples.
-//
-// Revision 1.0 2003/12/14 19:35:08 charlesr
-// Initial revision
-//
-
-#include "AppServer.h"
-#include "AppClient.h"
-#include "Eventloop.h"
-#if defined(WIN32)
-#include
-#else
-#include
-#endif
-#include
-
-using namespace std;
-
-// Externally defined global variables.
-extern Eventloop *Gevent_loop;
-
-// Constants.
-const static char *DELETE_TIMER = "DeleteTimer";
-
-//---------------------------------------------------------------
-// AppServer() (Public)
-// Default constructor.
-//
-AppServer::AppServer()
-: _server(NULL),
- _clientList(NULL),
- _deleteList(NULL)
-{}
-
-//---------------------------------------------------------------
-// ~AppServer() (Public)
-// Destructor. Close and delete all accepted client connections.
-//
-AppServer::~AppServer()
-{
- ClientEntry *client,
- *nextClient;
-
- // Close and delete the server if necessary.
- if (_server != NULL)
- {
- _server->doClose();
- delete _server;
- _server = NULL;
- }
-
- for (client = _clientList;
- client != NULL;
- client = nextClient)
- {
- nextClient = client->getNext();
- (client->getClient())->close();
- delete client;
- }
- _clientList = NULL;
-
- for (client = _deleteList;
- client != NULL;
- client = nextClient)
- {
- nextClient = client->getNext();
- delete client;
- }
- _deleteList = NULL;
-
- return;
-} // end of AppServer::~AppServer()
-
-//---------------------------------------------------------------
-// open(unsigned short) (Public)
-// Create a TCP service object and have it start opening.
-//
-void AppServer::open(unsigned short port)
-{
- if (_server == NULL)
- {
- _server = new TcpServer(*this);
- _server->open(port);
- }
-
- return;
-} // end of AppServer::open(unsigned short)
-
-//---------------------------------------------------------------
-// close() (Public)
-// Have the TCP service start the close process.
-//
-void AppServer::close()
-{
- if (_server != NULL)
- {
- _server->doClose();
- }
-
- return;
-} // end of AppServer::close()
-
-//---------------------------------------------------------------
-// clientClosed(const AppClient&) (Public)
-// One of the accepted client connections is now closed. Remove
-// it from the client list.
-//
-void AppServer::clientClosed(const AppClient& client)
-{
- ClientEntry **entry,
- *remove_entry;
-
- for (entry = &_clientList;
- *entry != NULL;
- entry = &((*entry)->_next))
- {
- if ((*entry)->getClient() == &client)
- {
- remove_entry = *entry;
- *entry = (*entry)->getNext();
-
- // Now put the client on the delete list and
- // start the delete timer.
- remove_entry->setNext(_deleteList);
- _deleteList = remove_entry;
-
- if (Gevent_loop->doesTimerExist(DELETE_TIMER) == true)
- {
- Gevent_loop->startTimer(DELETE_TIMER, 1, *this);
- }
-
- break;
- }
- }
-
- return;
-} // end of AppServer::clientClosed(const AppClient&)
-
-//---------------------------------------------------------------
-// opened(TcpConnection&) (Public)
-// TCP service successfully opened.
-//
-void AppServer::opened(TcpConnection&)
-{
- sockaddr_in address;
-
- address.sin_family = AF_INET;
- address.sin_port = _server->getPort();
- address.sin_addr.s_addr = _server->getAddress();
-
- cout << "Service opened on "
- << inet_ntoa(address.sin_addr)
- << ":"
- << ntohs(address.sin_port)
- << "."
- << endl;
-
- return;
-} // end of AppServer::opened(TcpConnection&)
-
-//---------------------------------------------------------------
-// openFailed(const char*, TcpConnection&) (Public)
-// TCP service failed to open.
-//
-void AppServer::openFailed(const char *reason, TcpConnection&)
-{
- void socketClosed();
-
- cout << "Service failed to open on port "
- << _server->getPort()
- << ", reason: "
- << reason
- << endl;
-
- // Tell the application that the TCP service is closed.
- socketClosed();
-
- return;
-} // end of AppServer::openFailed(const char*, TcpConnection&)
-
-//---------------------------------------------------------------
-// closed(const char*, TcpConnection&) (Public)
-// TCP service is now closed.
-//
-void AppServer::closed(const char *reason, TcpConnection&)
-{
- void socketClosed();
-
- cout << "Service closed: "
- << reason
- << endl;
-
- // Tell the application that the TCP service is closed.
- socketClosed();
-
- return;
-} // end of AppServer::closed(TcpConnection&)
-
-//---------------------------------------------------------------
-// accepteded(TcpClient&, TcpServer&) (Public)
-// TCP service has accepted a new connection.
-//
-void AppServer::accepted(TcpClient& client, TcpServer&)
-{
- AppClient *new_client;
- ClientEntry *new_entry;
- const sockaddr_in& address = client.getServerAddress();
- string host;
-
- host = inet_ntoa(address.sin_addr);
-
- cout << "Accepted new connection from "
- << host
- << ":"
- << ntohs(address.sin_port)
- << "."
- << endl;
-
- // Create a new client handler and put in the client list.
- new_client = new AppClient(host, client, *this);
- new_entry = new ClientEntry(*new_client);
- new_entry->setNext(_clientList);
- _clientList = new_entry;
-
- return;
-} // end of AppServer::accepted(TcpClient&, TcpServer&)
-
-//---------------------------------------------------------------
-// handleTimeout(const char*) (Public)
-// Time to delete the zombie clients.
-//
-void AppServer::handleTimeout(const char *name)
-{
- if (strcmp(name, DELETE_TIMER) == 0)
- {
- ClientEntry *it;
- ClientEntry *next;
-
- for (it = _deleteList; it != NULL; it = next)
- {
- next = it->getNext();
- it->setNext(NULL);
- delete it;
- }
-
- _deleteList = NULL;
- }
-
- return;
-} // end of AppServer::handleTimeout(const char*)
diff --git a/FSM/samples/TCP/AppServer.h b/FSM/samples/TCP/AppServer.h
deleted file mode 100644
index a2bea9658..000000000
--- a/FSM/samples/TCP/AppServer.h
+++ /dev/null
@@ -1,147 +0,0 @@
-#ifndef _H_APPSERVER
-#define _H_APPSERVER
-
-//
-// The contents of this file are subject to the Mozilla Public
-// License Version 1.1 (the "License"); you may not use this file
-// except in compliance with the License. You may obtain a copy
-// of the License at http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an
-// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-// implied. See the License for the specific language governing
-// rights and limitations under the License.
-//
-// The Original Code is State Machine Compiler (SMC).
-//
-// The Initial Developer of the Original Code is Charles W. Rapp.
-// Portions created by Charles W. Rapp are
-// Copyright (C) 2000 - 2003 Charles W. Rapp.
-// All Rights Reserved.
-//
-// Contributor(s):
-//
-// Name
-// AppServer.h
-//
-// Description
-// Encapsulates a TcpServer object.
-//
-// RCS ID
-// $Id: AppServer.h,v 1.6 2009/03/01 18:20:38 cwrapp Exp $
-//
-// CHANGE LOG
-// $Log: AppServer.h,v $
-// Revision 1.6 2009/03/01 18:20:38 cwrapp
-// Preliminary v. 6.0.0 commit.
-//
-// Revision 1.5 2007/12/28 12:34:40 cwrapp
-// Version 5.0.1 check-in.
-//
-// Revision 1.4 2005/05/28 13:31:18 cwrapp
-// Updated C++ examples.
-//
-// Revision 1.0 2003/12/14 19:35:24 charlesr
-// Initial revision
-//
-
-#include "TcpServer.h"
-#include "TcpClient.h"
-#include "TcpConnectionListener.h"
-#include "TimerListener.h"
-
-// Foward declarations.
-class AppClient;
-
-class AppServer :
- /* implements */ public TcpConnectionListener,
- /* implements */ public TimerListener
-{
-// Member functions.
-public:
-
- // Default constructor.
- AppServer();
-
- // Destructor.
- virtual ~AppServer();
-
- // Create a TCP server object and open it.
- void open(unsigned short port);
-
- // Close the TCP service.
- void close();
-
- // Accepted client socket closed.
- void clientClosed(const AppClient& client);
-
- // TCP connection listener callback methods.
- void opened(TcpConnection& connection);
- void openFailed(const char *reason,
- TcpConnection& connection);
- inline void halfClosed(TcpConnection&)
- {};
- void closed(const char *reason,
- TcpConnection& connection);
- void accepted(TcpClient& client, TcpServer& server);
-
- // These callbacks are never generated by a TCP server.
- void transmitted(TcpConnection&) {};
- void transmitFailed(const char*, TcpConnection&) {};
- void receive(const char*, int, TcpConnection&) {};
-
- // The "delete clients" timer has expired.
- void handleTimeout(const char *name);
-
-protected:
-private:
-
-// Nested classes.
-public:
-protected:
-private:
-
- class ClientEntry
- {
- public:
- ClientEntry(AppClient& client)
- : _client(&client),
- _next(NULL)
- {};
-
- ~ClientEntry() {};
-
- AppClient* getClient() const
- { return(_client);};
-
- ClientEntry* getNext() const
- { return(_next);};
-
- void setNext(ClientEntry *entry)
- { _next = entry; };
-
- private:
- AppClient *_client;
- ClientEntry *_next;
-
- friend class AppServer;
- };
-
-// Member data.
-public:
-protected:
-private:
-
- // The TCP service itself.
- TcpServer *_server;
-
- // Keep track of all the accepted client connections.
- // When this application terminates, they will all be
- // closed and deleted.
- ClientEntry *_clientList;
-
- // Delete these clients when the timer expires.
- ClientEntry *_deleteList;
-};
-
-#endif
diff --git a/FSM/samples/TCP/Eventloop.cpp b/FSM/samples/TCP/Eventloop.cpp
deleted file mode 100644
index 05e511bb8..000000000
--- a/FSM/samples/TCP/Eventloop.cpp
+++ /dev/null
@@ -1,621 +0,0 @@
-//
-// The contents of this file are subject to the Mozilla Public
-// License Version 1.1 (the "License"); you may not use this file
-// except in compliance with the License. You may obtain a copy
-// of the License at http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an
-// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-// implied. See the License for the specific language governing
-// rights and limitations under the License.
-//
-// The Original Code is State Machine Compiler (SMC).
-//
-// The Initial Developer of the Original Code is Charles W. Rapp.
-// Portions created by Charles W. Rapp are
-// Copyright (C) 2000 - 2007. Charles W. Rapp.
-// All Rights Reserved.
-//
-// Contributor(s):
-//
-// Name
-// Eventloop.h
-//
-// Description
-// Encapsulates the select-based event loop and timer table.
-//
-// RCS ID
-// $Id: Eventloop.cpp,v 1.6 2008/02/04 12:45:07 fperrad Exp $
-//
-// CHANGE LOG
-// $Log: Eventloop.cpp,v $
-// Revision 1.6 2008/02/04 12:45:07 fperrad
-// fix build on linux (gcc 4.1.3)
-//
-// Revision 1.5 2007/12/28 12:34:40 cwrapp
-// Version 5.0.1 check-in.
-//
-// Revision 1.4 2005/05/28 13:31:18 cwrapp
-// Updated C++ examples.
-//
-// Revision 1.0 2003/12/14 19:35:40 charlesr
-// Initial revision
-//
-
-#include "Eventloop.h"
-#include
-#if !defined(WIN32)
-#include
-#include
-#include
-#include
-#include
-#endif
-
-const static long USECS_PER_SEC = 1000000;
-const static long USECS_PER_MSEC = 1000;
-const static int WIN32_MAX_SOCKET = 1024;
-
-//---------------------------------------------------------------
-// Eventloop() (Public)
-// Default constructor.
-//
-Eventloop::Eventloop()
-: _continueRunning(1),
- _maxFD(-1),
- _fdCount(0),
- _timerTable(NULL)
-{
-#if !defined(WIN32)
- rlimit limit;
-#endif
-
- FD_ZERO(&_fdSet);
-
- // Allocate the file descriptor callback table. First, find
- // out the max file descriptor value.
-#if defined(WIN32)
- _fdTable = new InputListener*[WIN32_MAX_SOCKET];
- (void) memset(_fdTable,
- 0,
- (FD_SETSIZE * sizeof(InputListener*)));
-#else
- (void) getrlimit(RLIMIT_NOFILE, &limit);
- _fdTable = new InputListener*[limit.rlim_cur];
- (void) memset(_fdTable,
- 0,
- (limit.rlim_cur * sizeof(InputListener*)));
-#endif
-
- return;
-} // end of Eventloop::Eventloop()
-
-//---------------------------------------------------------------
-// ~Eventloop() (Public)
-// Destructor.
-//
-Eventloop::~Eventloop()
-{
- Eventloop::Timer *timerIt,
- *nextTimer;
-
- // Just in case the event loop is still running.
- _continueRunning = 0;
-
- if (_fdTable != NULL)
- {
- delete[] _fdTable;
- _fdTable = NULL;
- }
-
- for (timerIt = _timerTable;
- timerIt != NULL;
- timerIt = nextTimer)
- {
- nextTimer = timerIt->getNext();
- timerIt->setNext(NULL);
- delete timerIt;
- }
-
- return;
-} // end of Eventloop::~Eventloop()
-
-//---------------------------------------------------------------
-// start() (Public)
-// Start the event loop running.
-//
-int Eventloop::start()
-{
- timeval timeout,
- currTime,
- *timeoutPtr;
- Timer *timer;
- fd_set readSet;
- int i,
- fdCount,
- retcode;
- TimerListener *listener;
- char *timerName;
-
- _continueRunning = 1;
- retcode = 0;
- while (_continueRunning == 1)
- {
- // Figure out how long to wait. If there are no timers,
- // then set timeoutPtr to NULL and wait forever.
- // Otherwise, put the timeout in the timeval struct and
- // point timeoutPtr to it.
- if (_timerTable == NULL)
- {
- timeoutPtr = NULL;
- }
- else
- {
- // Get the current time and figure out how long until
- // the next timeout.
- gettime(currTime);
-
- // If we have passed the current timeout value, then
- // don't sleep at all.
- if (*_timerTable < currTime)
- {
- timeout.tv_sec = 0;
- timeout.tv_usec = 0;
- }
- else
- {
- timeout.tv_sec =
- (_timerTable->getExpiration()).tv_sec - currTime.tv_sec;
- timeout.tv_usec =
- (_timerTable->getExpiration()).tv_usec - currTime.tv_usec;
-
- // If the microseconds are less than 0, then subtract
- // a second and add 1,000,000 microseconds.
- if (timeout.tv_usec < 0)
- {
- --(timeout.tv_sec);
- timeout.tv_usec += USECS_PER_SEC;
- }
- }
-
- timeoutPtr = &timeout;
- }
-
- // Since select modifies the FD sets, pass in a copy.
- FD_ZERO(&readSet);
- for (i = 0; i < _maxFD; ++i)
- {
- if (FD_ISSET(i, &_fdSet))
- {
-#if defined(WIN32)
- FD_SET((u_int) i, &readSet);
-#else
- FD_SET(i, &readSet);
-#endif
- }
- }
-
- if ((fdCount = select(_maxFD, &readSet, NULL, NULL, timeoutPtr)) < 0)
- {
- // If select() was interrupted, ignore the error.
- if (errno != EINTR)
- {
- _continueRunning = 0;
- retcode = errno;
- }
- }
- else
- {
- // Issue read events first.
- for (i = 0; i < _maxFD && fdCount > 0; ++i)
- {
- if (FD_ISSET(i, &readSet))
- {
- --fdCount;
-
- if (_fdTable[i] != NULL)
- {
- _fdTable[i]->handleReceive(i);
- }
- }
- }
-
- // Issue timeouts.
- gettime(currTime);
- while (_timerTable != NULL &&
- *_timerTable <= currTime)
- {
- // Remove the timer from the timer table *before*
- // issuing the callback 'cause the callback may
- // set this same timer again before returning
- // (and the set will fail if the timer is already
- // in the table).
- timer = _timerTable;
- _timerTable = timer->getNext();
- timer->setNext(NULL);
-
- // Save away the necessary timer info.
- listener = &(timer->getListener());
- timerName = new char[strlen(timer->getName()) + 1];
- strcpy(timerName, timer->getName());
-
- // Now delete the defunct timer.
- delete timer;
-
- listener->handleTimeout(timerName);
- delete[] timerName;
- }
- }
- }
-
- return(retcode);
-} // end of Eventloop::start()
-
-//---------------------------------------------------------------
-// stop() (Public)
-// Stop the event loop.
-//
-void Eventloop::stop()
-{
- _continueRunning = 0;
- return;
-} // end of Eventloop::stop()
-
-//---------------------------------------------------------------
-// addFD(int, InputListener&) (Public)
-// Start watching a file descriptor and route the callback to the
-// given connection.
-//
-void Eventloop::addFD(int fd, InputListener& listener)
-{
- if (!FD_ISSET(fd, &_fdSet))
- {
-#if defined(WIN32)
- FD_SET((u_int) fd, &_fdSet);
-#else
- FD_SET(fd, &_fdSet);
-#endif
- ++_fdCount;
- }
-
- _fdTable[fd] = &listener;
-
- if (fd >= _maxFD)
- {
- _maxFD = fd + 1;
- }
-
- return;
-} // end of Eventloop::addFD(int, InputListener&)
-
-//---------------------------------------------------------------
-// removeFD(int) (Public)
-// Stop watching a file descriptor.
-//
-void Eventloop::removeFD(int fd)
-{
- int i;
-
-#if defined(WIN32)
- FD_CLR((u_int) fd, &_fdSet);
-#else
- FD_CLR(fd, &_fdSet);
-#endif
- _fdTable[fd] = NULL;
- --_fdCount;
-
- // Are we watching any file descriptors?
- if (_fdCount == 0)
- {
- _maxFD = -1;
- }
- // Are we removing the max fd?
- else if (fd == (_maxFD - 1))
- {
- // Yes. Then look for the next max fd.
- for (i = (fd -1); i >= 0; --i)
- {
- if (FD_ISSET(i, &_fdSet))
- {
- _maxFD = i + 1;
- break;
- }
- }
- }
-
- return;
-} // end of Eventloop::removeFD(int)
-
-//---------------------------------------------------------------
-// startTimer(const char*, unsigned long, TimerListener&) (Public)
-// Start the named timer.
-//
-void Eventloop::startTimer(const char *name,
- long duration,
- TimerListener& listener)
-{
- timeval expiration;
- Eventloop::Timer *timer,
- **timerIt;
-
- // Get the current time and add the duration to it.
- gettime(expiration);
- expiration.tv_usec += duration * USECS_PER_MSEC;
- if (expiration.tv_usec >= USECS_PER_SEC)
- {
- expiration.tv_sec += (expiration.tv_usec / USECS_PER_SEC);
- expiration.tv_usec = (expiration.tv_usec % USECS_PER_SEC);
- }
-
- // Check if this timer already exists. If yes, then remove the
- // timer from the list and update its duration and expiration.
- timer = NULL;
- for (timerIt = &_timerTable;
- *timerIt != NULL;
- timerIt = &((*timerIt)->_next))
- {
- if (strcmp((*timerIt)->getName(), name) == 0 &&
- &((*timerIt)->getListener()) == &listener)
- {
- timer = *timerIt;
- *timerIt = timer->getNext();
- timer->setNext(NULL);
-
- timer->setDuration(duration);
- timer->setExpiration(expiration);
-
- break;
- }
- }
-
- if (timer == NULL)
- {
- timer = new Timer(name, duration, expiration, listener);
- }
-
- // Find out where to put this timer in the list.
- for (timerIt = &_timerTable;
- *timerIt != NULL && **timerIt <= expiration;
- timerIt = &((*timerIt)->_next))
- ;
-
- timer->setNext(*timerIt);
- *timerIt = timer;
-
- return;
-} // end of Eventloop::startTimer(const char*, long, TimerListener&)
-
-//---------------------------------------------------------------
-// stopTimer(const char*, const TimerListener&) (Public)
-// Stop the named timer.
-//
-void Eventloop::stopTimer(const char *name,
- const TimerListener& listener)
-{
- Eventloop::Timer **timerIt,
- *timer;
-
- for (timerIt = &_timerTable;
- *timerIt != NULL;
- timerIt = &((*timerIt)->_next))
- {
- if (strcmp((*timerIt)->getName(), name) == 0 &&
- &((*timerIt)->getListener()) == &listener)
- {
- timer = *timerIt;
- *timerIt = timer->getNext();
- timer->setNext(NULL);
- delete timer;
-
- break;
- }
- }
-
- return;
-} // end of Eventloop::stopTimer(const char*, const TimerListener&)
-
-//---------------------------------------------------------------
-// doesTimerExist(const char*) const (Public)
-// Return true if the named timer exists.
-//
-bool Eventloop::doesTimerExist(const char *name) const
-{
- Eventloop::Timer **timerIt;
- bool retval;
-
- for (timerIt = const_cast(&_timerTable),
- retval = false;
- *timerIt != NULL && retval == false;
- timerIt = &((*timerIt)->_next))
- {
- if (strcmp((*timerIt)->getName(), name) == 0)
- {
- retval = true;
- }
- }
-
- return (retval);
-} // end of Eventloop::doesTimerExist(const char*) const
-
-//---------------------------------------------------------------
-// Timer(const char*, long, const timeval&, TimerListener&)
-// (Public)
-// Constructor.
-//
-Eventloop::Timer::Timer(const char *name,
- long duration,
- const timeval& expiration,
- TimerListener& listener)
-: _name(NULL),
- _duration(duration),
- _listener(listener),
- _next(NULL)
-{
- _name = new char[strlen(name) + 1];
- (void) strcpy(_name, name);
- (void) memcpy(&_expiration, &expiration, sizeof(_expiration));
-} // end of Eventloop::Timer::Timer(...)
-
-//---------------------------------------------------------------
-// ~Timer() (Public)
-// Destructor.
-//
-Eventloop::Timer::~Timer()
-{
- if (_name != NULL)
- {
- delete[] _name;
- _name = NULL;
- }
-
- return;
-} // end of Eventloop::Timer::~Timer()
-
-//---------------------------------------------------------------
-// operator<(const timeval&) (Public)
-// Is the expiration time less than the given time?
-//
-int Eventloop::Timer::operator<(const timeval& time)
-{
- return(_expiration.tv_sec < time.tv_sec ||
- (_expiration.tv_sec == time.tv_sec &&
- _expiration.tv_usec < time.tv_usec));
-} // end of Eventloop::Timer::operator<(const timeval&)
-
-//---------------------------------------------------------------
-// operator<=(const timeval&) (Public)
-// Is the expiration time less than or equal to the given time?
-//
-int Eventloop::Timer::operator<=(const timeval& time)
-{
- return(_expiration.tv_sec < time.tv_sec ||
- (_expiration.tv_sec == time.tv_sec &&
- _expiration.tv_usec <= time.tv_usec));
-} // end of Eventloop::Timer::operator<=(const timeval&)
-
-//---------------------------------------------------------------
-// operator==(const timeval&) (Public)
-// Is the expiration time equal to the given time?
-//
-int Eventloop::Timer::operator==(const timeval& time)
-{
- return(_expiration.tv_sec == time.tv_sec &&
- _expiration.tv_usec == time.tv_usec);
-} // end of Eventloop::Timer::operator==(const timeval&)
-
-//---------------------------------------------------------------
-// operator>=(const timeval&) (Public)
-// Is the expiration time greater than or equal to the given
-// time?
-//
-int Eventloop::Timer::operator>=(const timeval& time)
-{
- return(_expiration.tv_sec > time.tv_sec ||
- (_expiration.tv_sec == time.tv_sec &&
- _expiration.tv_usec >= time.tv_usec));
-} // end of Eventloop::Timer::operator>=(const timeval&)
-
-//---------------------------------------------------------------
-// operator>(const timeval&) (Public)
-// Is the expiration time greater than the given time?
-//
-int Eventloop::Timer::operator>(const timeval& time)
-{
- return(_expiration.tv_sec > time.tv_sec ||
- (_expiration.tv_sec == time.tv_sec &&
- _expiration.tv_usec > time.tv_usec));
-} // end of Eventloop::Timer::operator>(const timeval&)
-
-//---------------------------------------------------------------
-// getName() const (Public)
-// Return the timer's name.
-//
-const char* Eventloop::Timer::getName() const
-{
- return(_name);
-} // end of Eventloop::Timer::getName() const
-
-//---------------------------------------------------------------
-// getDuration() const (Public)
-// Return the timer's duration in milliseconds.
-//
-long Eventloop::Timer::getDuration() const
-{
- return(_duration);
-} // end of Eventloop::Timer::getDuration() const
-
-//---------------------------------------------------------------
-// setDuration(long) (Public)
-// Set the timer's duration.
-//
-void Eventloop::Timer::setDuration(long duration)
-{
- _duration = duration;
- return;
-} // end of Eventloop::Timer::setDuration(long)
-
-//---------------------------------------------------------------
-// getExpiration() const (Public)
-// Return the timer's expiration.
-//
-const timeval& Eventloop::Timer::getExpiration() const
-{
- return(_expiration);
-} // end of Eventloop::Timer::getExpiration() const
-
-//---------------------------------------------------------------
-// setExpiration(const timeval&) (Public)
-// Set the timer's expiration.
-//
-void Eventloop::Timer::setExpiration(const timeval& expiration)
-{
- (void) memcpy(&_expiration, &expiration, sizeof(_expiration));
- return;
-} // end of Eventloop::Timer::setExpiration(const timeval&)
-
-//---------------------------------------------------------------
-// getListener() const (Public)
-// Return timer's callback connection object.
-//
-TimerListener& Eventloop::Timer::getListener() const
-{
- return(_listener);
-} // end of Eventloop::Timer::getListener() const
-
-//---------------------------------------------------------------
-// getNext() const (Public)
-// Return the next pointer.
-//
-Eventloop::Timer* Eventloop::Timer::getNext() const
-{
- return(_next);
-} // end of Eventloop::Timer::getNext() const
-
-//---------------------------------------------------------------
-// setNext(Timer*) (Public)
-// Set the next pointer.
-//
-void Eventloop::Timer::setNext(Eventloop::Timer *timer)
-{
- _next = timer;
- return;
-} // end of Eventloop::Timer::setNext(Eventloop::Timer*)
-
-//---------------------------------------------------------------
-// gettime(timeval&) const (Private)
-// Get the current time.
-//
-void Eventloop::gettime(timeval& timeval) const
-{
-#if defined(WIN32)
- _timeb currTime;
-
- _ftime(&currTime);
- timeval.tv_sec = currTime.time;
- timeval.tv_usec = currTime.millitm * USECS_PER_MSEC;
-#else
- (void) gettimeofday(&timeval, NULL);
-#endif
-
- return;
-} // end of Eventloop::gettime(timeval&) const
diff --git a/FSM/samples/TCP/Eventloop.h b/FSM/samples/TCP/Eventloop.h
deleted file mode 100644
index 014c3ce14..000000000
--- a/FSM/samples/TCP/Eventloop.h
+++ /dev/null
@@ -1,163 +0,0 @@
-#ifndef _EVENTLOOP_H
-#define _EVENTLOOP_H
-//
-// The contents of this file are subject to the Mozilla Public
-// License Version 1.1 (the "License"); you may not use this file
-// except in compliance with the License. You may obtain a copy
-// of the License at http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an
-// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-// implied. See the License for the specific language governing
-// rights and limitations under the License.
-//
-// The Original Code is State Machine Compiler (SMC).
-//
-// The Initial Developer of the Original Code is Charles W. Rapp.
-// Portions created by Charles W. Rapp are
-// Copyright (C) 2000 - 2007. Charles W. Rapp.
-// All Rights Reserved.
-//
-// Contributor(s):
-//
-// Name
-// Eventloop.h
-//
-// Description
-// Encapsulates the select-based event loop and timer table.
-//
-// RCS ID
-// $Id: Eventloop.h,v 1.5 2007/12/28 12:34:40 cwrapp Exp $
-//
-// CHANGE LOG
-// $Log: Eventloop.h,v $
-// Revision 1.5 2007/12/28 12:34:40 cwrapp
-// Version 5.0.1 check-in.
-//
-// Revision 1.4 2005/05/28 13:31:18 cwrapp
-// Updated C++ examples.
-//
-// Revision 1.0 2003/12/14 19:35:56 charlesr
-// Initial revision
-//
-
-#include "InputListener.h"
-#include "TimerListener.h"
-#include
-#if defined(WIN32)
-#include
-#include
-#else
-#include
-#endif
-
-class Eventloop
-{
-// Member functions.
-public:
-
- Eventloop();
- ~Eventloop();
-
- // Enter the event loop and continue running until told to
- // stop. If the event loop terminated normally, 0 is
- // returned; otherwise a return value greater than 0 is
- // returned.
- int start();
-
- // Stop the event loop.
- void stop();
-
- // Methods for adding and removing file descriptors.
- void addFD(int fd, InputListener& listener);
- void removeFD(int fd);
-
- // Methods for starting and stopping timers.
- void startTimer(const char *name,
- long duration,
- TimerListener& listener);
- void stopTimer(const char *name, const TimerListener& listener);
- bool doesTimerExist(const char *name) const;
-
-protected:
-private:
-
- void gettime(timeval& timeval) const;
-
-// Inner classes.
-
- class Timer
- {
- // Member functions.
- public:
-
- Timer(const char *name,
- long duration,
- const timeval& expiration,
- TimerListener& listener);
-
- ~Timer();
-
- int operator<(const timeval& time);
- int operator<=(const timeval& time);
- int operator==(const timeval& time);
- int operator>=(const timeval& time);
- int operator>(const timeval& time);
-
- const char* getName() const;
- long getDuration() const;
- void setDuration(long duration);
- const timeval& getExpiration() const;
- void setExpiration(const timeval& expiration);
- TimerListener& getListener() const;
- Timer* getNext() const;
- void setNext(Timer *timer);
-
- // Member data.
- private:
-
- char *_name;
-
- // Duration is in milliseconds.
- long _duration;
-
- // When the timer is expected to expire.
- timeval _expiration;
-
- // The TcpConnection receiving this callback.
- TimerListener& _listener;
-
- Timer *_next;
-
- // Friends.
- friend class Eventloop;
- };
-
-// Member data.
-public:
-protected:
-private:
-
- // Set to true while event loop is running and false when
- // event loop is to stop.
- int _continueRunning;
-
- // The file descriptors to watch.
- fd_set _fdSet;
-
- // Keep track of the maximum file descriptor.
- int _maxFD;
-
- // Keep track of the number of file descriptors being
- // watched.
- int _fdCount;
-
- // The TCP connection associated with each file descriptor.
- InputListener **_fdTable;
-
- // This table is sorted by expiration time - from earliest
- // to latest.
- Timer *_timerTable;
-};
-
-#endif
diff --git a/FSM/samples/TCP/InputListener.h b/FSM/samples/TCP/InputListener.h
deleted file mode 100644
index 42aefaffa..000000000
--- a/FSM/samples/TCP/InputListener.h
+++ /dev/null
@@ -1,68 +0,0 @@
-#ifndef _H_INPUTLISTENER
-#define _H_INPUTLISTENER
-
-//
-// The contents of this file are subject to the Mozilla Public
-// License Version 1.1 (the "License"); you may not use this file
-// except in compliance with the License. You may obtain a copy
-// of the License at http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an
-// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-// implied. See the License for the specific language governing
-// rights and limitations under the License.
-//
-// The Original Code is State Machine Compiler (SMC).
-//
-// The Initial Developer of the Original Code is Charles W. Rapp.
-// Portions created by Charles W. Rapp are
-// Copyright (C) 2000 - 2007. Charles W. Rapp.
-// All Rights Reserved.
-//
-// Contributor(s):
-//
-// Name
-// InputListener.h
-//
-// Description
-// Input event handler.
-//
-// RCS ID
-// $Id: InputListener.h,v 1.5 2007/12/28 12:34:40 cwrapp Exp $
-//
-// CHANGE LOG
-// $Log: InputListener.h,v $
-// Revision 1.5 2007/12/28 12:34:40 cwrapp
-// Version 5.0.1 check-in.
-//
-// Revision 1.4 2005/05/28 13:31:18 cwrapp
-// Updated C++ examples.
-//
-// Revision 1.0 2003/12/14 19:38:51 charlesr
-// Initial revision
-//
-
-class InputListener
-{
-// Member functions.
-public:
-
- // Default constructor.
- InputListener() {};
-
- // Destructor.
- virtual ~InputListener() {};
-
- // Input callback method.
- virtual void handleReceive(int fd)=0;
-
-protected:
-private:
-
-// Member data.
-public:
-protected:
-private:
-};
-
-#endif
diff --git a/FSM/samples/TCP/TCP.sm b/FSM/samples/TCP/TCP.sm
deleted file mode 100644
index 278ea858a..000000000
--- a/FSM/samples/TCP/TCP.sm
+++ /dev/null
@@ -1,630 +0,0 @@
-// -*- tab-width: 4; -*-
-
-%{
-//
-// The contents of this file are subject to the Mozilla Public
-// License Version 1.1 (the "License"); you may not use this file
-// except in compliance with the License. You may obtain a copy
-// of the License at http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an
-// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-// implied. See the License for the specific language governing
-// rights and limitations under the License.
-//
-// The Original Code is State Machine Compiler (SMC).
-//
-// The Initial Developer of the Original Code is Charles W. Rapp.
-// Portions created by Charles W. Rapp are
-// Copyright (C) 2000 - 2007. Charles W. Rapp.
-// All Rights Reserved.
-//
-// Contributor(s):
-//
-// Name
-// TCP.sm
-//
-// Description
-// The TCP/IP state transition diagram.
-//
-%}
-
-%class TcpConnection
-%header TcpConnection.h
-%include "TcpSegment.h"
-%start TCP::CLOSED
-
-%map TCP
-%%
-CLOSED
-{
- PassiveOpen(port: unsigned short) ServiceOpening { openServerSocket(port); }
- ActiveOpen(address: const sockaddr_in*) ClientOpening { openClientSocket(address); }
- AcceptOpen(segment: const TcpSegment&) SYN_RCVD { sendSynAck(segment);setNearAddress(); }
- // Ignore close requests when closed.
- Close nil {}
-}
-
-// Wait here until service open has either succeeded or failed.
-ServiceOpening
-{
- ServerOpened LISTEN { openSuccess(); }
- OpenFailed(reason: const char*) CLOSED { closeSocket(); openFailed(reason); }
-}
-
-// Wait here until client open has either succeeded or failed.
-ClientOpening
-{
- ClientOpened(address: const sockaddr_in*)SYN_SENT { sendOpenSyn(address); }
-
- OpenFailed(reason: const char*) CLOSED { closeSocket();openFailed(reason); }
-}
-
-// Server sockets just sit here, creating new client sockets when
-// a SYN is received.
-LISTEN
-{
- // Create a new client socket and send its port number in
- // the SYN/ACK response.
- SYN(segment: const TcpSegment&) nil { accept(segment);deleteSegment(segment); }
- Close CLOSED { closeSocket();closed(""); }
-
- // But don't reset a reset message because there is no
- // connection to reset.
- RST(segment: const TcpSegment&) nil { deleteSegment(segment); }
-
- // Don't die on an undefined segment either.
- UNDEF(segment: const TcpSegment&) nil { doSend(TcpSegment::RST, NULL, 0, 0, &segment);deleteSegment(segment); }
-}
-
-// An "accepted" client socket starts life in this state.
-SYN_RCVD
-Entry
-{
- startTimer("ACK_TIMER", TcpConnection::ACK_TIMEOUT);
-}
-Exit
-{
- stopTimer("ACK_TIMER");
-}
-{
- // The connection was reset before it was established.
- // Close the datagram socket but don't tell anybody.
- RST(segment: const TcpSegment&) CLOSED { closeSocket();clearListener(); deleteSegment(segment); }
-
- // The TCP state transition diagram shows the server socket
- // taking an ACK transtion to the ESTABLISHED state but that
- // is not quite true. The accepted client socket goes to
- // the ESTABLISHED state while the server socket goes back to
- // LISTEN.
- ACK(segment: const TcpSegment&)
- [segment.getSrcAddress() == ctxt.getFarAddress() &&
- segment.getSrcPort() == ctxt.getFarPort() &&
- segment.getAcknowledgeNumber() == ctxt.getSequenceNumber()]
- ESTABLISHED { accepted();deleteSegment(segment); }
- Close FIN_WAIT_1 { doSend(TcpSegment::FIN, NULL, 0, 0, NULL); }
- AckTimeout CLOSED { doSend(TcpSegment::RST, NULL, 0, 0, NULL);closeSocket(); }
-}
-
-// A application-created client starts life in this state.
-SYN_SENT
-Entry
-{ startTimer("CONN_ACK_TIMER", TcpConnection::ACK_TIMEOUT); }
-Exit
-{ stopTimer("CONN_ACK_TIMER"); }
-{
- // When a TCP service accepts a new connection, it creates
- // a new client to handle this connection.
- SYN_ACK(segment: const TcpSegment&)
- [segment.getSrcAddress() == ctxt.getFarAddress() &&
- segment.getSrcPort() == ctxt.getFarPort() &&
- segment.getAcknowledgeNumber() == ctxt.getSequenceNumber()]
- ESTABLISHED { setFarAddress(segment);sendSynAckAck(segment);openSuccess();deleteSegment(segment); }
-
- Close CLOSED { closeSocket();closed(""); }
- ConnAckTimeout CLOSED { closeSocket();openFailed("acknowledge timeout"); }
-}
-
-ESTABLISHED
-{
- FIN(segment: const TcpSegment&)
- [segment.getSrcAddress() == ctxt.getFarAddress() &&
- segment.getSrcPort() == ctxt.getFarPort()]
- CLOSE_WAIT { doSend(TcpSegment::ACK, NULL, 0, 0, &segment);halfClosed();deleteSegment(segment); }
-
- PSH(segment: const TcpSegment&)
- [segment.getSrcAddress() == ctxt.getFarAddress() &&
- segment.getSrcPort() == ctxt.getFarPort()]
- nil { doSend(TcpSegment::ACK, NULL, 0, 0, &segment);receive(segment);deleteSegment(segment); }
-
- Transmit(data: const char*, offset: int, size: int)
- Transmitting
- {
- doSend(TcpSegment::PSH, data, offset, size, NULL);
- }
-
- Close
- FIN_WAIT_1
- {
- doSend(TcpSegment::FIN, NULL, 0, 0, NULL); }
-}
-
-Transmitting
-Entry
-{
- startTimer("TRANS_ACK_TIMER",
- TcpConnection::ACK_TIMEOUT);
-}
-Exit
-{
- stopTimer("TRANS_ACK_TIMER");
-}
-{
- ACK(segment: const TcpSegment&)
- [segment.getSrcAddress() == ctxt.getFarAddress() &&
- segment.getSrcPort() == ctxt.getFarPort() &&
- segment.getAcknowledgeNumber() == ctxt.getSequenceNumber()]
- ESTABLISHED
- {
- transmitted();
- deleteSegment(segment);
- }
-
- PSH_ACK(segment: const TcpSegment&)
- [segment.getSrcAddress() == ctxt.getFarAddress() &&
- segment.getSrcPort() == ctxt.getFarPort() &&
- segment.getAcknowledgeNumber() == ctxt.getSequenceNumber()]
- ESTABLISHED
- {
- doSend(TcpSegment::ACK, NULL, 0, 0, &segment);
- transmitted();
- receive(segment);
- deleteSegment(segment);
- }
-
- // If a push is received now, that means the far end sent
- // data at exactly the same time as we sent it. Send an ack
- // but don't go anywhere.
- PSH(segment: const TcpSegment&)
- [segment.getSrcAddress() == ctxt.getFarAddress() &&
- segment.getSrcPort() == ctxt.getFarPort()]
- nil
- {
- doSend(TcpSegment::ACK, NULL, 0, 0, &segment);
- receive(segment);
- deleteSegment(segment);
- }
-
- FIN(segment: const TcpSegment&)
- [segment.getSrcAddress() == ctxt.getFarAddress() &&
- segment.getSrcPort() == ctxt.getFarPort()]
- CLOSE_WAIT
- {
- doSend(TcpSegment::ACK, NULL, 0, 0, &segment);
- halfClosed();
- deleteSegment(segment);
- }
-
- Close
- FIN_WAIT_1
- {
- doSend(TcpSegment::FIN, NULL, 0, 0, NULL);
- }
-
- TransAckTimeout
- CLOSED
- {
- transmitFailed("peer did not acknowledge");
- closed("connection lost");
- }
-}
-
-CLOSE_WAIT
-{
- Close
- LAST_ACK
- {
- doSend(TcpSegment::FIN, NULL, 0, 0, NULL);
- }
-}
-
-LAST_ACK
-Entry
-{
- startTimer("CLOSE_ACK_TIMER", TcpConnection::ACK_TIMEOUT);
-}
-Exit
-{
- stopTimer("CLOSE_ACK_TIMER");
-}
-{
- ACK(segment: const TcpSegment&)
- [segment.getSrcAddress() == ctxt.getFarAddress() &&
- segment.getSrcPort() == ctxt.getFarPort() &&
- segment.getAcknowledgeNumber() == ctxt.getSequenceNumber()]
- CLOSED
- {
- doSend(TcpSegment::FIN, NULL, 0, 0, &segment);
- closeSocket();
- closed("");
- deleteSegment(segment);
- }
-
- CloseAckTimeout
- CLOSED
- {
- closeSocket();
- closed("");
- }
-}
-
-FIN_WAIT_1
-Entry
-{
- startTimer("CLOSE_ACK_TIMER", TcpConnection::ACK_TIMEOUT);
-}
-Exit
-{
- stopTimer("CLOSE_ACK_TIMER");
-}
-{
- ACK(segment: const TcpSegment&)
- [segment.getSrcAddress() == ctxt.getFarAddress() &&
- segment.getSrcPort() == ctxt.getFarPort() &&
- segment.getAcknowledgeNumber() == ctxt.getSequenceNumber()]
- FIN_WAIT_2
- {
- deleteSegment(segment);
- }
-
- FIN(segment: const TcpSegment&)
- [segment.getSrcAddress() == ctxt.getFarAddress() &&
- segment.getSrcPort() == ctxt.getFarPort()]
- CLOSING
- {
- doSend(TcpSegment::ACK, NULL, 0, 0, &segment);
- deleteSegment(segment);
- }
-
- FIN_ACK(segment: const TcpSegment&)
- [segment.getSrcAddress() == ctxt.getFarAddress() &&
- segment.getSrcPort() == ctxt.getFarPort() &&
- segment.getAcknowledgeNumber() == ctxt.getSequenceNumber()]
- TIME_WAIT
- {
- doSend(TcpSegment::ACK, NULL, 0, 0, &segment);
- deleteSegment(segment);
- }
-
- CloseAckTimeout
- FIN_WAIT_2
- {
- closeSocket();
- closed("");
- }
-}
-
-FIN_WAIT_2
-Entry
-{
- startTimer("CLOSE_ACK_TIMER", TcpConnection::ACK_TIMEOUT);
-}
-Exit
-{
- stopTimer("CLOSE_ACK_TIMER");
-}
-{
- FIN(segment: const TcpSegment&)
- [segment.getSrcAddress() == ctxt.getFarAddress() &&
- segment.getSrcPort() == ctxt.getFarPort()]
- TIME_WAIT
- {
- doSend(TcpSegment::ACK, NULL, 0, 0, &segment);
- deleteSegment(segment);
- }
-
- CloseAckTimeout
- CLOSED
- {
- closeSocket();
- }
-
- // Ignore undefined transitions.
- UNDEF(segment: const TcpSegment&)
- nil
- {
- deleteSegment(segment);
- }
-}
-
-CLOSING
-Entry
-{
- startTimer("CLOSE_ACK_TIMER", TcpConnection::ACK_TIMEOUT);
-}
-Exit
-{
- stopTimer("CLOSE_ACK_TIMER");
-}
-{
- ACK(segment: const TcpSegment&)
- [segment.getSrcAddress() == ctxt.getFarAddress() &&
- segment.getSrcPort() == ctxt.getFarPort() &&
- segment.getAcknowledgeNumber() == ctxt.getSequenceNumber()]
- TIME_WAIT
- {
- deleteSegment(segment);
- }
-
- CloseAckTimeout
- TIME_WAIT
- {
- closeSocket();
- closed("");
- }
-
- // Ignore undefined transitions.
- UNDEF(segment: const TcpSegment&)
- nil
- {
- deleteSegment(segment);
- }
-}
-
-TIME_WAIT
-Entry
-{
- startTimer("CLOSE_TIMER", TcpConnection::CLOSE_TIMEOUT);
-}
-Exit
-{
- stopTimer("CLOSE_TIMER");
-}
-{
- FIN_ACK(segment: const TcpSegment&)
- [segment.getSrcAddress() == ctxt.getFarAddress() &&
- segment.getSrcPort() == ctxt.getFarPort() &&
- segment.getAcknowledgeNumber() == ctxt.getSequenceNumber()]
- CLOSED
- {
- closeSocket();
- deleteSegment(segment);
- }
-
- CloseTimeout
- CLOSED
- {
- closeSocket();
- closed("");
- }
-
- // Ignore undefined transitions.
- UNDEF(segment: const TcpSegment&)
- nil
- {
- deleteSegment(segment);
- }
-}
-
-Default
-{
- PassiveOpen(port : unsigned short)
- nil
- {
- openFailed("already open");
- }
-
- ActiveOpen(address: const sockaddr_in*)
- nil
- {
- openFailed("already open");
- }
-
- Transmit(data: const char*, offset: int, size: int)
- nil
- {
- transmitFailed("connection not established");
- }
-
- // The default action when an unknown client sends us a
- // segment is to reset the unknown client but remain in
- // the current state for a segment from the real client.
- FIN(segment: const TcpSegment&)
- [segment.getSrcAddress() != ctxt.getFarAddress() ||
- segment.getSrcPort() != ctxt.getFarPort()]
- nil
- {
- doSend(TcpSegment::RST, NULL, 0, 0, &segment);
- closed("connection reset");
- deleteSegment(segment);
- }
-
- SYN(segment: const TcpSegment&)
- [segment.getSrcAddress() != ctxt.getFarAddress() ||
- segment.getSrcPort() != ctxt.getFarPort()]
- nil
- {
- doSend(TcpSegment::RST, NULL, 0, 0, &segment);
- closed("connection reset");
- deleteSegment(segment);
- }
-
- PSH(segment: const TcpSegment&)
- [segment.getSrcAddress() != ctxt.getFarAddress() ||
- segment.getSrcPort() != ctxt.getFarPort()]
- nil
- {
- doSend(TcpSegment::RST, NULL, 0, 0, &segment);
- closed("connection reset");
- deleteSegment(segment);
- }
-
- ACK(segment: const TcpSegment&)
- [segment.getSrcAddress() != ctxt.getFarAddress() ||
- segment.getSrcPort() != ctxt.getFarPort()]
- nil
- {
- doSend(TcpSegment::RST, NULL, 0, 0, &segment);
- closed("connection reset");
- deleteSegment(segment);
- }
-
- URG(segment: const TcpSegment&)
- [segment.getSrcAddress() != ctxt.getFarAddress() ||
- segment.getSrcPort() != ctxt.getFarPort()]
- nil
- {
- doSend(TcpSegment::RST, NULL, 0, 0, &segment);
- closed("connection reset");
- deleteSegment(segment);
- }
-
- FIN_ACK(segment: const TcpSegment&)
- [segment.getSrcAddress() != ctxt.getFarAddress() ||
- segment.getSrcPort() != ctxt.getFarPort()]
- nil
- {
- doSend(TcpSegment::RST, NULL, 0, 0, &segment);
- closed("connection reset");
- deleteSegment(segment);
- }
-
- SYN_ACK(segment: const TcpSegment&)
- [segment.getSrcAddress() != ctxt.getFarAddress() ||
- segment.getSrcPort() != ctxt.getFarPort()]
- nil
- {
- doSend(TcpSegment::RST, NULL, 0, 0, &segment);
- closed("connection reset");
- deleteSegment(segment);
- }
-
- PSH_ACK(segment: const TcpSegment&)
- [segment.getSrcAddress() != ctxt.getFarAddress() ||
- segment.getSrcPort() != ctxt.getFarPort()]
- nil
- {
- doSend(TcpSegment::RST, NULL, 0, 0, &segment);
- closed("connection reset");
- deleteSegment(segment);
- }
-
- UNDEF(segment: const TcpSegment&)
- [segment.getSrcAddress() != ctxt.getFarAddress() ||
- segment.getSrcPort() != ctxt.getFarPort()]
- nil
- {
- doSend(TcpSegment::RST, NULL, 0, 0, &segment);
- closed("connection reset");
- deleteSegment(segment);
- }
-
- // Do not reset a reset. Just go to closed.
- RST(segment: const TcpSegment&)
- CLOSED
- {
- closed("connection reset by peer");
- deleteSegment(segment);
- }
-
- RST_ACK(segment: const TcpSegment&)
- CLOSED
- {
- closed("connection reset by peer");
- deleteSegment(segment);
- }
-
- // The remain transitions represent segments received
- // when they were not expected from the peer. The
- // connection is reset.
- FIN(segment: const TcpSegment&)
- CLOSED
- {
- doSend(TcpSegment::RST, NULL, 0, 0, &segment);
- closed("connection reset");
- deleteSegment(segment);
- }
-
- SYN(segment: const TcpSegment&)
- CLOSED
- {
- doSend(TcpSegment::RST, NULL, 0, 0, &segment);
- closed("connection reset");
- deleteSegment(segment);
- }
-
- PSH(segment: const TcpSegment&)
- CLOSED
- {
- doSend(TcpSegment::RST, NULL, 0, 0, &segment);
- closed("connection reset");
- deleteSegment(segment);
- }
-
- ACK(segment: const TcpSegment&)
- CLOSED
- {
- doSend(TcpSegment::RST, NULL, 0, 0, &segment);
- closed("connection reset");
- deleteSegment(segment);
- }
-
- URG(segment: const TcpSegment&)
- CLOSED
- {
- doSend(TcpSegment::RST, NULL, 0, 0, &segment);
- closed("connection reset");
- deleteSegment(segment);
- }
-
- FIN_ACK(segment: const TcpSegment&)
- CLOSED
- {
- doSend(TcpSegment::RST, NULL, 0, 0, &segment);
- closed("connection reset");
- deleteSegment(segment);
- }
-
- SYN_ACK(segment: const TcpSegment&)
- CLOSED
- {
- doSend(TcpSegment::RST, NULL, 0, 0, &segment);
- closed("connection reset");
- deleteSegment(segment);
- }
-
- PSH_ACK(segment: const TcpSegment&)
- CLOSED
- {
- doSend(TcpSegment::RST, NULL, 0, 0, &segment);
- closed("connection reset");
- deleteSegment(segment);
- }
-
- UNDEF(segment: const TcpSegment&)
- nil
- {
- doSend(TcpSegment::RST, NULL, 0, 0, &segment);
- closed("connection reset");
- deleteSegment(segment);
- }
-
- // Ignore timeouts which occur when not expected.
- ConnAckTimeout
- nil
- {}
-
- TransAckTimeout
- nil
- {}
-
- CloseAckTimeout
- nil
- {}
-
- CloseTimeout
- nil
- {}
-}
-
-%%
diff --git a/FSM/samples/TCP/TCP_vs120.vcxproj b/FSM/samples/TCP/TCP_vs120.vcxproj
deleted file mode 100644
index a9e0d7a2d..000000000
--- a/FSM/samples/TCP/TCP_vs120.vcxproj
+++ /dev/null
@@ -1,127 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {11E01C5F-683C-4290-B520-D3D248327DE1}
- Win32Proj
- TrafficLight
- TCP
-
-
-
- Application
- true
- v120
- Unicode
-
-
- Application
- false
- v120
- true
- Unicode
-
-
-
-
-
-
-
-
-
-
-
-
- true
- ClCompile
-
-
- false
- $(IncludePath)
- ClCompile
-
-
-
-
-
- Level3
- Disabled
- WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
- ..\..\..\FSM\include;..\..\..\Util\include;..\..\..\Foundation\include
-
-
- Console
- true
- ..\..\..\lib
-
-
- set PATH=..\..\..\bin;%PATH% && ..\..\bin\fsmc TCP.sm
- SpotLight_sm.h;SpotLight_sm.cpp
-
-
-
-
- Level3
-
-
- MaxSpeed
- true
- true
- WIN32;NDEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
- ..\..\..\FSM\include;..\..\..\Util\include;..\..\..\Foundation\include
-
-
- Console
- true
- true
- true
- ..\..\..\lib
-
-
- set PATH=..\..\..\bin;%PATH% && ..\..\bin\fsmc TCP.sm
- SpotLight_sm.h;SpotLight_sm.cpp
-
-
-
-
-
-
\ No newline at end of file
diff --git a/FSM/samples/TCP/TcpClient.cpp b/FSM/samples/TCP/TcpClient.cpp
deleted file mode 100644
index c320d03a3..000000000
--- a/FSM/samples/TCP/TcpClient.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-//
-// The contents of this file are subject to the Mozilla Public
-// License Version 1.1 (the "License"); you may not use this file
-// except in compliance with the License. You may obtain a copy
-// of the License at http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an
-// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-// implied. See the License for the specific language governing
-// rights and limitations under the License.
-//
-// The Original Code is State Machine Compiler (SMC).
-//
-// The Initial Developer of the Original Code is Charles W. Rapp.
-// Portions created by Charles W. Rapp are
-// Copyright (C) 2000 - 2003 Charles W. Rapp.
-// All Rights Reserved.
-//
-// Contributor(s):
-//
-// Name
-// TcpClient.cpp
-//
-// Description
-// TCP client connection class implementation.
-//
-// RCS ID
-// $Id: TcpClient.cpp,v 1.5 2007/12/28 12:34:40 cwrapp Exp $
-//
-// CHANGE LOG
-// $Log: TcpClient.cpp,v $
-// Revision 1.5 2007/12/28 12:34:40 cwrapp
-// Version 5.0.1 check-in.
-//
-// Revision 1.4 2005/05/28 13:31:18 cwrapp
-// Updated C++ examples.
-//
-// Revision 1.0 2003/12/14 19:39:43 charlesr
-// Initial revision
-//
-
-#include "TcpClient.h"
-#if defined (WIN32)
-#include
-#else
-# if defined(__sun)
-#include
-# else
-#include
-# endif
-#include
-#endif
-
-// Const declarations.
-const static long MAX_HOSTNAME_LEN = 257;
-
-//---------------------------------------------------------------
-// TcpClient(TcpConnectionListener&) (Public)
-// Create an unconnected TCP client.
-//
-TcpClient::TcpClient(TcpConnectionListener& listener)
-: TcpConnection(listener)
-{}
-
-//---------------------------------------------------------------
-// ~TcpClient() (Public)
-// Destructor.
-//
-TcpClient::~TcpClient()
-{}
-
-//---------------------------------------------------------------
-// getServerAddress() const (Public)
-// This client is connected to this TCP service.
-//
-const sockaddr_in& TcpClient::getServerAddress() const
-{
- return(_farAddress);
-} // end of TcpClient::getServerAddress() const
-
-//---------------------------------------------------------------
-// getClientPort() const (Public)
-// This client's TCP port.
-//
-unsigned short TcpClient::getClientPort() const
-{
- return(_nearAddress.sin_port);
-} // end of TcpClient::getClientPort() const
-
-//---------------------------------------------------------------
-// open(unsigned short) (Public)
-// Open a client connection to a local TCP service.
-//
-void TcpClient::open(unsigned short port)
-{
- sockaddr_in address;
- char hostname[MAX_HOSTNAME_LEN];
- hostent *hostentry;
-
- // Get the local address.
-#if defined(__sun)
- (void) sysinfo(SI_HOSTNAME, hostname, MAX_HOSTNAME_LEN);
-#else
- (void) gethostname(hostname, MAX_HOSTNAME_LEN);
-#endif
- hostentry = gethostbyname(hostname);
-
- // Fill in the destination address.
- address.sin_port = port;
- (void) memcpy(&(address.sin_addr.s_addr),
- hostentry->h_addr_list[0],
- 4);
-
- activeOpen(address);
-
- return;
-} // end of TcpClient::open(unsigned short)
-
-//---------------------------------------------------------------
-// open(const sockaddr_in&) (Public)
-// Open a client connection to a remove TCP service.
-//
-void TcpClient::open(const sockaddr_in& address)
-{
- activeOpen(address);
- return;
-} // end of TcpClient::open(const sockaddr_in&)
-
-//---------------------------------------------------------------
-// TcpClient(const sockaddr_in&, ...) (Private)
-// Create an "accepted" client connection.
-//
-TcpClient::TcpClient(const sockaddr_in& far_address,
- const sockaddr_in& near_address,
-#if defined(WIN32)
- unsigned short actual_port,
- SOCKET udp_socket,
- HANDLE udp_handle,
-#else
- int udp_socket,
-#endif
- unsigned long sequence_number,
- TcpServer& server,
- TcpConnectionListener& listener)
-: TcpConnection(far_address,
- near_address,
-#if defined(WIN32)
- actual_port,
- udp_socket,
- udp_handle,
-#else
- udp_socket,
-#endif
- sequence_number,
- server,
- listener)
-{}
diff --git a/FSM/samples/TCP/TcpClient.h b/FSM/samples/TCP/TcpClient.h
deleted file mode 100644
index df00679b3..000000000
--- a/FSM/samples/TCP/TcpClient.h
+++ /dev/null
@@ -1,104 +0,0 @@
-#ifndef _H_TCPCLIENT
-#define _H_TCPCLIENT
-
-//
-// The contents of this file are subject to the Mozilla Public
-// License Version 1.1 (the "License"); you may not use this file
-// except in compliance with the License. You may obtain a copy
-// of the License at http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an
-// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-// implied. See the License for the specific language governing
-// rights and limitations under the License.
-//
-// The Original Code is State Machine Compiler (SMC).
-//
-// The Initial Developer of the Original Code is Charles W. Rapp.
-// Portions created by Charles W. Rapp are
-// Copyright (C) 2000 - 2007. Charles W. Rapp.
-// All Rights Reserved.
-//
-// Contributor(s):
-//
-// Name
-// TcpClient.h
-//
-// Description
-// TCP client connection class header.
-//
-// RCS ID
-// $Id: TcpClient.h,v 1.5 2007/12/28 12:34:40 cwrapp Exp $
-//
-// CHANGE LOG
-// $Log: TcpClient.h,v $
-// Revision 1.5 2007/12/28 12:34:40 cwrapp
-// Version 5.0.1 check-in.
-//
-// Revision 1.4 2005/05/28 13:31:18 cwrapp
-// Updated C++ examples.
-//
-// Revision 1.0 2003/12/14 19:40:04 charlesr
-// Initial revision
-//
-
-#include "TcpConnection.h"
-
-// Forward declarations.
-class TcpServer;
-
-class TcpClient: public TcpConnection
-{
-// Member functions.
-public:
-
- // Create an unconnected client.
- TcpClient(TcpConnectionListener& listener);
-
- // Destructor.
- ~TcpClient();
-
- // This client is connected to this TCP service.
- const sockaddr_in& getServerAddress() const;
-
- // This client's TCP port.
- unsigned short getClientPort() const;
-
- // Open a client connection to a local TCP service.
- void open(unsigned short port);
-
- // Open a client connection to a remote TCP service.
- void open(const sockaddr_in& address);
-
-protected:
-private:
-
- // Create an "accepted" client connection. This constructor
- // may only be called by TcpConnection.
- TcpClient(const sockaddr_in& far_address,
- const sockaddr_in& near_address,
-#if defined(WIN32)
- unsigned short actual_port,
- SOCKET udp_socket,
- HANDLE udp_handle,
-#else
- int udp_socket,
-#endif
- unsigned long sequence_number,
- TcpServer& server,
- TcpConnectionListener& listener);
-
- // Don't allow default or copy constructors.
- TcpClient();
- TcpClient(const TcpClient&);
-
-// Member data.
-public:
-protected:
-private:
-
-// Friends.
- friend class TcpConnection;
-};
-
-#endif
diff --git a/FSM/samples/TCP/TcpConnection.cpp b/FSM/samples/TCP/TcpConnection.cpp
deleted file mode 100644
index bf17956c8..000000000
--- a/FSM/samples/TCP/TcpConnection.cpp
+++ /dev/null
@@ -1,1428 +0,0 @@
-//
-// The contents of this file are subject to the Mozilla Public
-// License Version 1.1 (the "License"); you may not use this file
-// except in compliance with the License. You may obtain a copy
-// of the License at http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an
-// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-// implied. See the License for the specific language governing
-// rights and limitations under the License.
-//
-// The Original Code is State Machine Compiler (SMC).
-//
-// The Initial Developer of the Original Code is Charles W. Rapp.
-// Portions created by Charles W. Rapp are
-// Copyright (C) 2000 - 2007. Charles W. Rapp.
-// All Rights Reserved.
-//
-// Contributor(s):
-//
-// Name
-// TcpConnection.cpp
-//
-// Description
-// TCP connection class implementation.
-//
-// RCS ID
-// $Id: TcpConnection.cpp,v 1.9 2015/08/02 19:44:35 cwrapp Exp $
-//
-// CHANGE LOG
-// $Log: TcpConnection.cpp,v $
-// Revision 1.9 2015/08/02 19:44:35 cwrapp
-// Release 6.6.0 commit.
-//
-// Revision 1.8 2014/09/06 09:04:29 fperrad
-// pragma only for MS compiler
-//
-// Revision 1.7 2007/12/28 12:34:40 cwrapp
-// Version 5.0.1 check-in.
-//
-// Revision 1.6 2005/06/08 11:09:12 cwrapp
-// + Updated Python code generator to place "pass" in methods with empty
-// bodies.
-// + Corrected FSM errors in Python example 7.
-// + Removed unnecessary includes from C++ examples.
-// + Corrected errors in top-level makefile's distribution build.
-//
-// Revision 1.5 2005/05/28 13:31:18 cwrapp
-// Updated C++ examples.
-//
-// Revision 1.0 2003/12/14 19:40:23 charlesr
-// Initial revision
-//
-
-#ifdef _MSC_VER
-#pragma warning(disable: 4355)
-#endif
-
-#include "TcpConnection.h"
-#include "TcpSegment.h"
-#include "TcpClient.h"
-#include "TcpServer.h"
-#include "Eventloop.h"
-#include
-#include
-#include
-#include
-#if !defined(WIN32)
-#include
-#include
-# if defined(__sun)
-#include
-# endif
-#endif
-
-#ifdef _MSC_VER
-// Get rid of an annoying build warning.
-#pragma warning(disable: 4355)
-#endif
-
-using namespace std;
-
-#if defined(WIN32)
-typedef int socklen_t;
-#endif
-
-// External variable declarations.
-extern Eventloop *Gevent_loop;
-
-// Const member declarations.
-const unsigned long TcpConnection::ISN = 1415531521;
-const int TcpConnection::MIN_TIMEOUT = 1;
-const int TcpConnection::ACK_TIMEOUT = 2000;
-const int TcpConnection::CLOSE_TIMEOUT = 5000;
-const int TcpConnection::BUFFER_BLOCK_SIZE = 4096;
-
-// Const declarations.
-const static int MSG_READ = 0;
-const static int NO_SEND_FLAGS = 0;
-const static long MAX_HOSTNAME_LEN = 257;
-const static unsigned long LOCAL_HOST_ADDRESS = 0x7f000001;
-#if defined(WIN32)
-const static unsigned short MIN_PORT = 1024;
-const static unsigned short MAX_PORT = 5000;
-#endif
-
-// External routine declarations.
-char* winsock_strerror(int);
-
-//---------------------------------------------------------------
-// getFarAddress() const (Public)
-// Return the far-end's 4-byte IP address.
-//
-unsigned long TcpConnection::getFarAddress() const
-{
- return (_farAddress.sin_addr.s_addr);
-} // end of TcpConnection::getFarAddress() const
-
-//---------------------------------------------------------------
-// getFarPort() const (Public)
-// Return the far-end's TCP port.
-//
-unsigned short TcpConnection::getFarPort() const
-{
- return (_farAddress.sin_port);
-} // end of TcpConnection::getFarPort() const
-
-//---------------------------------------------------------------
-// getSequenceNumber() const (Public)
-// Return the current sequence number.
-//
-unsigned long TcpConnection::getSequenceNumber() const
-{
- return (_sequence_number);
-} // end of TcpConnection::getSequenceNumber() const
-
-//---------------------------------------------------------------
-// transmit(const unsigned char*, int, int) (Public)
-// Transmit data to the far side.
-//
-void TcpConnection::transmit(const char *data,
- int offset,
- int size)
-{
-#ifdef CRTP
- Transmit(data, offset, size);
-#else
- _fsm.Transmit(data, offset, size);
-#endif
- return;
-} // end of TcpConnection::transmit(const unsigned char*, int, int)
-
-//---------------------------------------------------------------
-// doClose() (Public)
-// Start closing this connection.
-//
-void TcpConnection::doClose()
-{
-#ifdef CRTP
- Close();
-#else
- _fsm.Close();
-#endif
- return;
-} // end of TcpConnection::doClose()
-
-//---------------------------------------------------------------
-// setListener(TcpConnectionListener&) (Public)
-// Set the connection's listener to a new object.
-//
-void TcpConnection::setListener(TcpConnectionListener& listener)
-{
- _listener = &listener;
- return;
-} // end of TcpConnection::setListener(TcpConnectionListener&)
-
-//---------------------------------------------------------------
-// handleReceive(int) (Public)
-// Process incoming data.
-//
-void TcpConnection::handleReceive(int)
-{
- sockaddr sourceAddress;
- TcpSegment *segment;
- socklen_t addressSize;
- int flags,
- done,
- errorFlag,
- bytesRead,
- totalBytesRead;
-
- // Read in the segment. Since the data may exceed the buffer
- // size, keep expanding the buffer until all the data is
- // read.
- for (done = 0, bytesRead = 0, totalBytesRead = 0, errorFlag = 0;
- done == 0;
- totalBytesRead += bytesRead)
- {
- // Be certain to offset properly into the input buffer.
- addressSize = sizeof(sourceAddress);
- bytesRead = recvfrom(_udp_socket,
- (_buffer + totalBytesRead),
- _bufferSize,
- MSG_READ,
- &sourceAddress,
- &addressSize);
-
-#if defined(WIN32)
- if (bytesRead == SOCKET_ERROR)
-#else
- if (bytesRead < 0)
-#endif
- {
- done = 1;
-
- if (errno != EAGAIN)
- {
- cerr << "Receive failure - "
- << strerror(errno)
- << "."
- << endl;
-
- errorFlag = 1;
- }
- else
- {
- bytesRead = 0;
- }
- }
- else if (bytesRead >= 0 && bytesRead < _bufferSize)
- {
- done = 1;
- }
- else
- {
- // The entire buffer was filled with the data.
- // Expand the buffer and read some more.
- expandBuffer();
- }
- }
-
- if (errorFlag == 0 && bytesRead > 0)
- {
- segment = new TcpSegment(reinterpret_cast(sourceAddress),
- _nearAddress,
- _buffer,
- totalBytesRead);
-
-#if defined(FSM_DEBUG)
- cout << "**** Received segment:"
- << endl
- << *segment
- << endl;
-#endif
-
- // Generate the appropriate transition based on the header
- // flags.
- flags = segment->getFlags();
- switch(flags)
- {
- case TcpSegment::FIN:
-#ifdef CRTP
- FIN(*segment);
-#else
- _fsm.FIN(*segment);
-#endif
- break;
-
- case TcpSegment::SYN:
-#ifdef CRTP
- SYN(*segment);
-#else
- _fsm.SYN(*segment);
-#endif
- break;
-
- case TcpSegment::RST:
-#ifdef CRTP
- RST(*segment);
-#else
- _fsm.RST(*segment);
-#endif
- break;
-
- case TcpSegment::PSH:
-#ifdef CRTP
- PSH(*segment);
-#else
- _fsm.PSH(*segment);
-#endif
- break;
-
- case TcpSegment::ACK:
-#ifdef CRTP
- ACK(*segment);
-#else
- _fsm.ACK(*segment);
-#endif
- break;
-
- case TcpSegment::URG:
-#ifdef CRTP
- URG(*segment);
-#else
- _fsm.URG(*segment);
-#endif
- break;
-
- case TcpSegment::FIN_ACK:
-#ifdef CRTP
- FIN_ACK(*segment);
-#else
- _fsm.FIN_ACK(*segment);
-#endif
- break;
-
- case TcpSegment::SYN_ACK:
-#ifdef CRTP
- SYN_ACK(*segment);
-#else
- _fsm.SYN_ACK(*segment);
-#endif
- break;
-
- case TcpSegment::RST_ACK:
-#ifdef CRTP
- RST_ACK(*segment);
-#else
- _fsm.RST_ACK(*segment);
-#endif
- break;
-
- case TcpSegment::PSH_ACK:
-#ifdef CRTP
- PSH_ACK(*segment);
-#else
- _fsm.PSH_ACK(*segment);
-#endif
- break;
-
- default:
-#ifdef CRTP
- UNDEF(*segment);
-#else
- _fsm.UNDEF(*segment);
-#endif
- break;
- }
- }
-
- return;
-} // end of TcpConnection::handleReceive(int)
-
-//---------------------------------------------------------------
-// handleTimeout(const char*) (Public)
-// Generate the appropriate transition based on the timer's name.
-//
-void TcpConnection::handleTimeout(const char *name)
-{
-#if defined(FSM_DEBUG)
- cout << "**** Timer " << name << " has expired." << endl;
-#endif
-
- if (strcmp(name, "ACK_TIMER") == 0)
- {
-#ifdef CRTP
- AckTimeout();
-#else
- _fsm.AckTimeout();
-#endif
- }
- else if (strcmp(name, "CONN_ACK_TIMER") == 0)
- {
-#ifdef CRTP
- ConnAckTimeout();
-#else
- _fsm.ConnAckTimeout();
-#endif
- }
- else if (strcmp(name, "TRANS_ACK_TIMER") == 0)
- {
-#ifdef CRTP
- TransAckTimeout();
-#else
- _fsm.TransAckTimeout();
-#endif
- }
- else if (strcmp(name, "CLOSE_ACK_TIMER") == 0)
- {
-#ifdef CRTP
- CloseAckTimeout();
-#else
- _fsm.CloseAckTimeout();
-#endif
- }
- else if (strcmp(name, "CLOSE_TIMER") == 0)
- {
-#ifdef CRTP
- CloseTimeout();
-#else
- _fsm.CloseTimeout();
-#endif
- }
- else if (strcmp(name, "SERVER_OPENED") == 0)
- {
-#ifdef CRTP
- ServerOpened();
-#else
- _fsm.ServerOpened();
-#endif
- }
- else if (strcmp(name, "CLIENT_OPENED") == 0)
- {
-#ifdef CRTP
- ClientOpened(&_farAddress);
-#else
- _fsm.ClientOpened(&_farAddress);
-#endif
- }
- else if (strcmp(name, "OPEN_FAILED") == 0)
- {
-#ifdef CRTP
- OpenFailed(_errorMessage);
-#else
- _fsm.OpenFailed(_errorMessage);
-#endif
- if (_errorMessage != NULL)
- {
- delete[] _errorMessage;
- _errorMessage = NULL;
- }
- }
-
- return;
-} // end of TcpConnection::handleTimeout(const char*)
-
-//---------------------------------------------------------------
-// openServerSocket(unsigned short) (Public)
-// Open a server socket on the specified port.
-//
-void TcpConnection::openServerSocket(unsigned short port)
-{
-#if defined(WIN32)
- unsigned long blockingFlag = 1;
- HANDLE newHandle;
-#endif
-
- // Set up this server's address.
- (void) memset(&_nearAddress, 0, sizeof(_nearAddress));
- _nearAddress.sin_family = AF_INET;
- _nearAddress.sin_port = port;
- _nearAddress.sin_addr.s_addr = INADDR_ANY;
-
- // Tell the UDP socket to route data bound for port to this
- // object.
-#if defined(WIN32)
- if ((_udp_win_socket = socket(AF_INET, SOCK_DGRAM, 0))
- == INVALID_SOCKET ||
- DuplicateHandle(GetCurrentProcess(),
- (HANDLE) _udp_win_socket,
- GetCurrentProcess(),
- &newHandle,
- 0,
- FALSE,
- DUPLICATE_SAME_ACCESS) == FALSE ||
- bind((unsigned int) newHandle,
- reinterpret_cast(&_nearAddress),
- sizeof(_nearAddress))
- == SOCKET_ERROR)
-#else
- if ((_udp_socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0 ||
- bind(_udp_socket,
- reinterpret_cast(&_nearAddress),
- sizeof(_nearAddress))
- < 0)
-#endif
- {
- char *error;
-
- // Use timer to report this event asynchronously.
- // Store away error message.
- if (_errorMessage != NULL)
- {
- delete[] _errorMessage;
- _errorMessage = NULL;
- }
-#if defined(WIN32)
- error = winsock_strerror(WSAGetLastError());
-#else
- error = strerror(errno);
-#endif
- _errorMessage = new char[strlen(error) + 1];
- (void) strcpy(_errorMessage, error);
- Gevent_loop->startTimer("OPEN_FAILED",
- MIN_TIMEOUT,
- *this);
- }
- else
- {
- // Get the UDP socket's address.
- _nearAddress.sin_family = AF_INET;
- _nearAddress.sin_addr.s_addr = getLocalAddress();
-
- // Set the socket to non-blocking and register it with
- // the event loop.
-#if defined(WIN32)
- _udp_socket = (unsigned int) newHandle;
- (void) ioctlsocket(_udp_socket, FIONBIO, &blockingFlag);
-#else
- (void) fcntl(_udp_socket, F_SETFL, O_NDELAY);
-#endif
- Gevent_loop->addFD(_udp_socket, *this);
-
- Gevent_loop->startTimer("SERVER_OPENED",
- MIN_TIMEOUT,
- *this);
- }
-
- return;
-} // end of TcpConnection::openServerSocket(int)
-
-//---------------------------------------------------------------
-// openClientSocket(const sockaddr_in*) (Public)
-// Connect to the specified address.
-//
-void TcpConnection::openClientSocket(const sockaddr_in *address)
-{
-#if defined(WIN32)
- unsigned long blockingFlag = 1;
- HANDLE newHandle;
- int new_port;
-#endif
-
- // Set up this client's address.
- (void) memset(&_nearAddress, 0, sizeof(_nearAddress));
- _nearAddress.sin_family = AF_INET;
- _nearAddress.sin_port = 0;
- _nearAddress.sin_addr.s_addr = INADDR_ANY;
-
-#if defined(WIN32)
- if ((_udp_win_socket = socket(AF_INET, SOCK_DGRAM, 0))
- == INVALID_SOCKET ||
- DuplicateHandle(GetCurrentProcess(),
- (HANDLE) _udp_win_socket,
- GetCurrentProcess(),
- &newHandle,
- 0,
- FALSE,
- DUPLICATE_SAME_ACCESS) == FALSE ||
- (new_port = doBind((int) newHandle)) < 0)
-#else
- if ((_udp_socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0 ||
- bind(_udp_socket,
- reinterpret_cast(&_nearAddress),
- sizeof(_nearAddress))
- < 0)
-#endif
- {
- char *error;
-
- // Use timer to report this event asynchronously.
- // Store away error message.
- if (_errorMessage != NULL)
- {
- delete[] _errorMessage;
- _errorMessage = NULL;
- }
-#if defined(WIN32)
- error = winsock_strerror(WSAGetLastError());
-#else
- error = strerror(errno);
-#endif
- _errorMessage = new char[strlen(error) + 1];
- (void) strcpy(_errorMessage, error);
- Gevent_loop->startTimer("OPEN_FAILED",
- MIN_TIMEOUT,
- *this);
- }
- else
- {
- // Get the UDP socket's address.
- _nearAddress.sin_family = AF_INET;
-#if defined(WIN32)
- _nearAddress.sin_port = (unsigned short) new_port;
-#else
- _nearAddress.sin_port = getLocalPort(_udp_socket);
-#endif
- _nearAddress.sin_addr.s_addr = getLocalAddress();
-
- // Set the socket to non-blocking and register it with
- // the event loop.
-#if defined(WIN32)
- _udp_socket = (unsigned int) newHandle;
- (void) ioctlsocket(_udp_socket, FIONBIO, &blockingFlag);
-#else
- (void) fcntl(_udp_socket, F_SETFL, O_NDELAY);
-#endif
- Gevent_loop->addFD(_udp_socket, *this);
-
- // Save the far-end address for later use.
- (void) memcpy(&_farAddress, address, sizeof(_farAddress));
-
- _sequence_number = ISN;
-
- Gevent_loop->startTimer("CLIENT_OPENED",
- MIN_TIMEOUT,
- *this);
- }
-
- return;
-} // end of TcpConnection::openClientSocket(const sockaddr_in*)
-
-//---------------------------------------------------------------
-// openSuccess() (Public)
-// The socket has been successfully opened.
-//
-void TcpConnection::openSuccess()
-{
- _listener->opened(*this);
- return;
-} // end of TcpConnection::openSuccess()
-
-//---------------------------------------------------------------
-// openFailed(const char*) (Public)
-// The socket could not be opened.
-//
-void TcpConnection::openFailed(const char *reason)
-{
- _listener->openFailed(reason, *this);
- return;
-} // end of TcpConnection::openFailed(const char*)
-
-//---------------------------------------------------------------
-// closeSocket() (Public)
-// Finish closing the socket.
-//
-void TcpConnection::closeSocket()
-{
- if (_udp_socket >= 0)
- {
- // Remove this UDP socket from the event loop.
- Gevent_loop->removeFD(_udp_socket);
-
- // Now close the UDP socket.
-#if defined(WIN32)
- CloseHandle((HANDLE) _udp_socket);
- closesocket(_udp_win_socket);
- _udp_win_socket = NULL;
-#else
- close(_udp_socket);
-#endif
- _udp_socket = -1;
- }
-
- return;
-} // end of TcpConnection::closeSocket()
-
-//---------------------------------------------------------------
-// halfClosed() (Public)
-// The far end client socket has closed its half of the
-// connection.
-//
-void TcpConnection::halfClosed()
-{
- _listener->halfClosed(*this);
- return;
-} // end of TcpConnection::halfClosed()
-
-//---------------------------------------------------------------
-// closed(const char*) (Public)
-// The connection is completely closed.
-//
-void TcpConnection::closed(const char *reason)
-{
- TcpConnectionListener *listener;
-
- if (_listener != NULL)
- {
- listener = _listener;
- _listener = NULL;
- listener->closed(reason, *this);
- }
-
- return;
-} // end of TcpConnection::closed(const char*)
-
-//---------------------------------------------------------------
-// clearListener() (Public)
-// Clear this connection's current listener.
-//
-void TcpConnection::clearListener()
-{
- _listener = NULL;
- return;
-} // end of TcpConnection::clearListener()
-
-//---------------------------------------------------------------
-// transmitted() (Public)
-// Data transmission successfully completed.
-//
-void TcpConnection::transmitted()
-{
- _listener->transmitted(*this);
- return;
-} // end of TcpConnection::transmitted()
-
-//---------------------------------------------------------------
-// transmitFailed(const char*) (Public)
-// Data transmission failed.
-//
-void TcpConnection::transmitFailed(const char *reason)
-{
- _listener->transmitFailed(reason, *this);
- return;
-} // end of TcpConnection::transmitFailed(const char*)
-
-//---------------------------------------------------------------
-// receive(const TcpSegment&) (Public)
-// Send received data to the listener.
-//
-void TcpConnection::receive(const TcpSegment& segment)
-{
- if (_listener != NULL)
- {
- _listener->receive(segment.getData(),
- segment.getDataSize(),
- *this);
- }
-
- return;
-} // end of TcpConnection::receive(const TcpSegment&)
-
-//---------------------------------------------------------------
-// sendOpenSyn(const sockaddr_in*) (Public)
-// Send the opening SYN message which requests connection to a
-// service.
-//
-void TcpConnection::sendOpenSyn(const sockaddr_in *address)
-{
- TcpSegment segment(*address,
- _nearAddress,
- 0,
- 0,
- TcpSegment::SYN,
- NULL,
- 0,
- 0);
-
- doSend(TcpSegment::SYN, NULL, 0, 0, &segment);
- return;
-} // end of TcpConnection::sendOpenSyn(const sockaddr_in*)
-
-//---------------------------------------------------------------
-// accept(const TcpSegment&) (Public)
-// Create a client socket to handle the new connection.
-//
-void TcpConnection::accept(const TcpSegment& segment)
-{
- TcpClient *accept_client;
- int new_socket;
-#if defined(WIN32)
- unsigned long blockingFlag = 1;
- HANDLE newHandle;
- int new_port;
-#else
- sockaddr_in clientAddress;
-#endif
-
- // Create a new UDP socket to handle this connection.
- // Let it be assigned a random UDP port.
-#if defined(WIN32)
- newHandle = NULL;
- if ((new_socket = socket(AF_INET, SOCK_DGRAM, 0))
- == INVALID_SOCKET ||
- DuplicateHandle(GetCurrentProcess(),
- (HANDLE) new_socket,
- GetCurrentProcess(),
- &newHandle,
- 0,
- FALSE,
- DUPLICATE_SAME_ACCESS) == FALSE ||
- (new_port = doBind((int) newHandle)) < 0)
- {
- // If an error occurs now, ignore it.
- if (new_socket != INVALID_SOCKET)
- {
- closesocket(new_socket);
- }
- if (newHandle != NULL)
- {
- CloseHandle((HANDLE) newHandle);
- }
- }
- else
- {
- // Set the socket to non-blocking.
- (void) ioctlsocket(
- (unsigned int) newHandle, FIONBIO, &blockingFlag);
-
- // Have the new client socket use this server
- // socket's near address for now.
- accept_client = new TcpClient(segment.getSource(),
- _nearAddress,
- (unsigned short) new_port,
- new_socket,
- newHandle,
- _sequence_number,
- (TcpServer&) *this,
- *_listener);
-#else
- // Set up this client's address.
- (void) memset(&clientAddress, 0, sizeof(clientAddress));
- clientAddress.sin_family = AF_INET;
- clientAddress.sin_port = 0;
- clientAddress.sin_addr.s_addr = INADDR_ANY;
-
- if ((new_socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0 ||
- bind(new_socket,
- reinterpret_cast(&clientAddress),
- sizeof(clientAddress))
- < 0)
- {
- // If an error occurs now, ignore it.
- if (new_socket >= 0)
- {
- close(new_socket);
- }
- }
- else
- {
- // Set the socket to non-blocking.
- (void) fcntl(new_socket, F_SETFL, O_NDELAY);
-
- // Have the new client socket use this server
- // socket's near address for now.
- accept_client = new TcpClient(segment.getSource(),
- _nearAddress,
- new_socket,
- _sequence_number,
- (TcpServer&) *this,
- *_listener);
-
-#endif
-
- accept_client->acceptOpen(segment);
- }
-
- return;
-} // end of TcpConnection::accept(const TcpSegment&)
-
-//---------------------------------------------------------------
-// accepted() (Public)
-// Connection completely accepted.
-//
-void TcpConnection::accepted()
-{
- TcpServer *server = _server;
- TcpConnectionListener *listener = _listener;
-
- // Tell the server listener that a new connection has
- // been accepted. Then clear the server listener because
- // this socket is now truly a client socket. Clear the
- // listener member data now because the callback method
- // will be resetting it and the reset will fail if we
- // don't do it.
- _server = NULL;
- _listener = NULL;
- listener->accepted((TcpClient&) *this, *server);
-
- return;
-} // end of TcpConnection::accepted()
-
-//---------------------------------------------------------------
-// sendSynAck(const TcpSegment&) (Public)
-// Acknowledge a SYN message.
-//
-void TcpConnection::sendSynAck(const TcpSegment& segment)
-{
- unsigned short port;
- char port_bytes[2];
-
- // Tell the far end client socket with what port it should
- // now communicate.
-#if defined(WIN32)
- port = _actualPort;
-#else
- port = getLocalPort(_udp_socket);
-#endif
-
- port_bytes[0] = (char) (port & 0x00ff);
- port_bytes[1] = (char) ((port & 0xff00) >> 8);
-
- doSend(TcpSegment::SYN_ACK, port_bytes, 0, 2, &segment);
-
- return;
-} // end of TcpConnection::sendSynAck(const TcpSegment&)
-
-//---------------------------------------------------------------
-// sendSynAckAck(const TcpSegment&) (Public)
-// Acknowledge the service's acknowledge. Need to do this so
-// doSend() will use the correct address.
-//
-void TcpConnection::sendSynAckAck(const TcpSegment& segment)
-{
- TcpSegment faux_segment(_farAddress,
- _nearAddress,
- segment.getSequenceNumber(),
- segment.getAcknowledgeNumber(),
- segment.getFlags(),
- NULL,
- 0,
- 0);
-
- doSend(TcpSegment::ACK, NULL, 0, 0, &faux_segment);
- return;
-} // end of TcpConnection::sendSynAckAck(const TcpSegment&)
-
-//---------------------------------------------------------------
-// doSend(...) (Public)
-// Send data to the specified address.
-//
-void TcpConnection::doSend(unsigned short flags,
- const char *data,
- int offset,
- int size,
- const TcpSegment *recv_segment)
-{
- sockaddr_in to_address;
- unsigned long ack_number;
- TcpSegment *send_segment;
- char *packet;
- int packet_size;
-
- (void) memset(&to_address, 0, sizeof(to_address));
-
- // First, use the received segment.
- // Else, use the connection's far end.
- if (recv_segment != NULL)
- {
- (void) memcpy(&to_address,
- &(recv_segment->getSource()),
- sizeof(to_address));
- }
- // If the address was not specified, then send this segment
- // to whatever client socket we are currently speaking.
- else
- {
- (void) memcpy(&to_address, &_farAddress, sizeof(to_address));
- }
-
- // Send the ack number only if the ack flag is set.
- if ((flags & TcpSegment::ACK) == 0 || recv_segment == NULL)
- {
- ack_number = 0;
- }
- else
- {
- // Figure out the ack number based on the received
- // segment's sequence number and data size.
- ack_number = getAck(*recv_segment);
- }
-
- send_segment =
- new TcpSegment(_nearAddress,
- to_address,
- _sequence_number,
- ack_number,
- flags,
- data,
- offset,
- size);
-
- // Advance the sequence number depending on the message sent.
- // Don't do this if the message came from an interloper.
- if (recv_segment == NULL ||
- ((recv_segment->getSource()).sin_port == _farAddress.sin_port &&
- (recv_segment->getSource()).sin_addr.s_addr == _farAddress.sin_addr.s_addr))
- {
- _sequence_number = getAck(*send_segment);
- }
-
- // Now send the data. First convert the TCP segment into a
- // sequence of raw bytes.
- send_segment->packetize(packet, packet_size);
-
- if (packet != NULL && packet_size > 0)
- {
-#if defined(FSM_DEBUG)
- cout << "**** Transmit segment:\n" << *send_segment << endl;
-#endif
-
-#if defined(WIN32)
- if (sendto(_udp_socket,
- packet,
- packet_size,
- NO_SEND_FLAGS,
- reinterpret_cast(&to_address),
- sizeof(to_address)) == SOCKET_ERROR)
-#else
- if (sendto(_udp_socket,
- packet,
- packet_size,
- NO_SEND_FLAGS,
- reinterpret_cast(&to_address),
- sizeof(to_address)) < 0)
-#endif
- {
- cerr << "Transmit failed - "
- << strerror(errno)
- << "."
- << endl;
- }
-
- // Free up the allocated packet.
- delete[] packet;
- }
-
- delete send_segment;
-
- return;
-} // end of TcpConnection::doSend(...)
-
-//---------------------------------------------------------------
-// startTimer(const char*, long) (Public)
-// Start the named timer running.
-//
-void TcpConnection::startTimer(const char *name, long duration)
-{
-#if defined(FSM_DEBUG)
- cout << "**** Starting timer "
- << name
- << ", duration: "
- << duration
- << " milliseconds."
- << endl;
-#endif
-
- Gevent_loop->startTimer(name, duration, *this);
- return;
-} // end of TcpConnection::startTimer(const char*, long)
-
-//---------------------------------------------------------------
-// stopTimer(const char*) (Public)
-// Stop the named timer.
-//
-void TcpConnection::stopTimer(const char* name)
-{
-#if defined(FSM_DEBUG)
- cout << "**** Stopping timer " << name << "." << endl;
-#endif
-
- Gevent_loop->stopTimer(name, *this);
- return;
-} // end of TcpConnection::stopTimer(const char*)
-
-//---------------------------------------------------------------
-// setNearAddress() (Public)
-// Figure out this socket's port and address based on the socket.
-//
-void TcpConnection::setNearAddress()
-{
- // Get the UDP socket's address.
- _nearAddress.sin_port = AF_INET;
-#if defined(WIN32)
- _nearAddress.sin_port = _actualPort;
-#else
- _nearAddress.sin_port = getLocalPort(_udp_socket);
-#endif
- _nearAddress.sin_addr.s_addr = getLocalAddress();
-
- return;
-} // end of TcpConnection::setNearAddress()
-
-//---------------------------------------------------------------
-// setFarAddress(const TcpSegment&) (Public)
-// Send data to a new client port instead of the server port.
-//
-void TcpConnection::setFarAddress(const TcpSegment& segment)
-{
- const char *data = segment.getData();
- unsigned short port;
-
- _farAddress.sin_family = AF_INET;
- port = ((((unsigned short) data[0]) & 0x00ff) |
- ((((unsigned short) data[1]) & 0x00ff) << 8));
- _farAddress.sin_port = port;
- _farAddress.sin_addr.s_addr =
- segment.getSource().sin_addr.s_addr;
-
- return;
-} // end of TcpConnection::setFarAddress(const TcpSegment&)
-
-//---------------------------------------------------------------
-// deleteSegment(const TcpSegment&) (Public)
-// Delete a segment object.
-//
-void TcpConnection::deleteSegment(const TcpSegment& segment)
-{
- delete const_cast(&segment);
- return;
-} // end of TcpConnection::deleteSegment(const TcpSegment&)
-
-//---------------------------------------------------------------
-// TcpConnection(TcpConnectionListener&) (Protected)
-// Create a server socket.
-//
-TcpConnection::TcpConnection(TcpConnectionListener& listener)
-: _listener(&listener),
-#if defined(WIN32)
- _actualPort(0),
- _udp_win_socket(NULL),
-#endif
- _udp_socket(-1),
- _sequence_number(ISN),
- _buffer(NULL),
- _bufferSize(0),
- _server(NULL),
- _errorMessage(NULL)
-#ifdef CRTP
-#else
- , _fsm(*this)
-#endif
-{
- (void) memset(&_nearAddress, 0, sizeof(_nearAddress));
- (void) memset(&_farAddress, 0, sizeof(_farAddress));
- expandBuffer();
-
-#if defined(FSM_DEBUG)
- // Turn on state map debug printout.
-#ifdef CRTP
- setDebugFlag(true);
-#else
- _fsm.setDebugFlag(true);
-#endif
-#endif
-
- return;
-} // end of TcpConnection::TcpConnection(TcpConnectionListener&)
-
-//---------------------------------------------------------------
-// TcpConnection(const sockaddr_in&, ...) (Protected)
-// "Accepted" client connection.
-//
-TcpConnection::TcpConnection(const sockaddr_in& far_address,
- const sockaddr_in& near_address,
-#if defined(WIN32)
- unsigned short actual_port,
- SOCKET udp_socket,
- HANDLE udp_handle,
-#else
- int udp_socket,
-#endif
- int sequence_number,
- TcpServer& server,
- TcpConnectionListener& listener)
-: _listener(&listener),
-#if defined(WIN32)
- _actualPort(actual_port),
- _udp_win_socket(udp_socket),
- _udp_socket((unsigned int) udp_handle),
-#else
- _udp_socket(udp_socket),
-#endif
- _sequence_number(sequence_number),
- _buffer(NULL),
- _bufferSize(0),
- _server(&server),
- _errorMessage(NULL)
-#ifdef CRTP
-#else
- , _fsm(*this)
-#endif
-{
- // Register the UDP socket with the event loop.
- Gevent_loop->addFD(_udp_socket, *this);
-
- (void) memcpy(&_nearAddress, &near_address, sizeof(_nearAddress));
- (void) memcpy(&_farAddress, &far_address, sizeof(_farAddress));
-
- // Set up the input buffer.
- expandBuffer();
-
-#if defined(FSM_DEBUG)
- // Turn on state map debug printout.
-#ifdef CRTP
- setDebugFlag(true);
-#else
- _fsm.setDebugFlag(true);
-#endif
-#endif
-
- return;
-} // end of TcpConnection::TcpConnection(...)
-
-//---------------------------------------------------------------
-// ~TcpConnection() (Protected)
-// Destructor.
-//
-TcpConnection::~TcpConnection()
-{
- if (_buffer != NULL)
- {
- delete[] _buffer;
- _buffer = NULL;
- _bufferSize = 0;
- }
-
- if (_errorMessage != NULL)
- {
- delete[] _errorMessage;
- _errorMessage = NULL;
- }
-
- // Just in case ...
- closeSocket();
-
- return;
-} // end of TcpConnection::~TcpConnection()
-
-//---------------------------------------------------------------
-// passiveOpen(unsigned short) (Protected)
-// Open a server socket.
-//
-void TcpConnection::passiveOpen(unsigned short port)
-{
-#ifdef CRTP
- PassiveOpen(port);
-#else
- _fsm.PassiveOpen(port);
-#endif
- return;
-} // end of TcpConnection::passiveOpen(unsigned short)
-
-//---------------------------------------------------------------
-// activeOpen(const sockaddr_in&) (Protected)
-// Open a client socket.
-//
-void TcpConnection::activeOpen(const sockaddr_in& address)
-{
-#ifdef CRTP
- ActiveOpen(&address);
-#else
- _fsm.ActiveOpen(&address);
-#endif
- return;
-} // end of TcpConnection::activeOpen(const sockaddr_in&)
-
-//---------------------------------------------------------------
-// acceptOpen(const TcpSegment&) (Protected)
-// "Open" an accepted client connection.
-//
-void TcpConnection::acceptOpen(const TcpSegment& segment)
-{
-#ifdef CRTP
- AcceptOpen(segment);
-#else
- _fsm.AcceptOpen(segment);
-#endif
- return;
-} // end of TcpConnection::acceptOpen(const TcpSegment&)
-
-//---------------------------------------------------------------
-// expandBuffer() (Private)
-// Expand the buffer's current size by one block.
-//
-void TcpConnection::expandBuffer()
-{
- char *newBuffer;
- int newSize,
- currBlocks;
-
- currBlocks = _bufferSize / BUFFER_BLOCK_SIZE;
- newSize = (currBlocks + 1) * BUFFER_BLOCK_SIZE;
- newBuffer = new char[newSize];
-
- // If the current buffer has data in it, copy it over to the
- // new buffer before deleting the current buffer.
- if (_buffer != NULL)
- {
- (void) memcpy(newBuffer, _buffer, _bufferSize);
- delete[] _buffer;
- }
-
- _buffer = newBuffer;
- _bufferSize = newSize;
-
- return;
-} // end of TcpConnection::expandBuffer()
-
-#if defined(WIN32)
-//---------------------------------------------------------------
-// doBind(int) const (Private)
-// Bind this UDP socket to a random, available port number.
-//
-int TcpConnection::doBind(int handle) const
-{
- sockaddr_in address;
- unsigned short portIt;
- int socket_error,
- retval;
-
- // Set up this client's address.
- (void) memset(&address, 0, sizeof(address));
- address.sin_family = AF_INET;
- address.sin_port = 0;
- address.sin_addr.s_addr = INADDR_ANY;
-
- // Start at the largest number and work down.
- for (portIt = MIN_PORT; portIt <= MAX_PORT; ++portIt)
- {
- address.sin_port = htons(portIt);
- if (bind(handle, (sockaddr *) &address, sizeof(sockaddr_in))
- == SOCKET_ERROR)
- {
- socket_error = WSAGetLastError();
- if (socket_error != WSAEADDRINUSE &&
- socket_error != WSAEADDRNOTAVAIL)
- {
- retval = -1;
- break;
- }
- }
- else
- {
- // The bind worked. Return the port number.
- retval = address.sin_port;
- break;
- }
- }
-
- return(retval);
-} // end of TcpConnection::doBind(int) const
-#else
-//---------------------------------------------------------------
-// getLocalPort(int) const (Private)
-// Figure out the UDP socket's port number.
-//
-unsigned short TcpConnection::getLocalPort(int fd) const
-{
- socklen_t size;
- sockaddr_in address;
- unsigned short retval;
-
- size = sizeof(address);
- if (getsockname(fd,
- reinterpret_cast(&address),
- &size) < 0)
- {
- retval = 0xffff;
- }
- else
- {
- retval = address.sin_port;
- }
-
- return(retval);
-} // end of TcpConnection::getLocalPort(int) const
-#endif
-
-//---------------------------------------------------------------
-// getLocalAddress() const (Private)
-// Return this machine's local internet address. Do this by
-// first retrieving the hostname and then doing gethostbyname()
-// on itself.
-//
-unsigned long TcpConnection::getLocalAddress() const
-{
- char hostname[MAX_HOSTNAME_LEN];
- hostent *hostEntry;
- unsigned long retval;
-
- // 1. Get this machine's network host name.
-#if defined(__sun)
- (void) sysinfo(SI_HOSTNAME, hostname, MAX_HOSTNAME_LEN);
-#else
- (void) gethostname(hostname, MAX_HOSTNAME_LEN);
-#endif
-
- // 2. Get this host name's address.
- if ((hostEntry = gethostbyname(hostname)) != NULL)
- {
- (void) memcpy(&retval,
- hostEntry->h_addr,
- hostEntry->h_length);
- }
- else
- {
- // If there is no known address for this host name,
- // default to 127.0.0.1.
- retval = LOCAL_HOST_ADDRESS;
- }
-
- return(retval);
-} // end of TcpConnection::getLocalAddress() const
-
-//---------------------------------------------------------------
-// getAck(const TcpSegment&) (Private)
-// Figure out what the acknowledgement number should be based on
-// the TCP segment's type and size.
-//
-int TcpConnection::getAck(const TcpSegment& segment)
-{
- int retval;
-
- // The ack # depends on the segment's flags.
- switch (segment.getFlags())
- {
- case TcpSegment::FIN:
- case TcpSegment::SYN:
- case TcpSegment::FIN_ACK:
- case TcpSegment::SYN_ACK:
- retval = segment.getSequenceNumber() + 1;
- break;
-
- case TcpSegment::PSH:
- case TcpSegment::PSH_ACK:
- retval = segment.getSequenceNumber() +
- segment.getDataSize();
- break;
-
- case TcpSegment::ACK:
- default:
- retval = segment.getSequenceNumber();
- break;
- }
-
- return(retval);
-} // end of TcpConnection::getAck(const TcpSegment&)
diff --git a/FSM/samples/TCP/TcpConnection.h b/FSM/samples/TCP/TcpConnection.h
deleted file mode 100644
index a375c127c..000000000
--- a/FSM/samples/TCP/TcpConnection.h
+++ /dev/null
@@ -1,237 +0,0 @@
-#ifndef _H_TCPCONNECTION
-#define _H_TCPCONNECTION
-
-//
-// The contents of this file are subject to the Mozilla Public
-// License Version 1.1 (the "License"); you may not use this file
-// except in compliance with the License. You may obtain a copy
-// of the License at http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an
-// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-// implied. See the License for the specific language governing
-// rights and limitations under the License.
-//
-// The Original Code is State Machine Compiler (SMC).
-//
-// The Initial Developer of the Original Code is Charles W. Rapp.
-// Portions created by Charles W. Rapp are
-// Copyright (C) 2000 - 2007. Charles W. Rapp.
-// All Rights Reserved.
-//
-// Contributor(s):
-//
-// Name
-// TcpConnection.h
-//
-// Description
-// TCP connection class header.
-//
-// RCS ID
-// $Id: TcpConnection.h,v 1.6 2015/08/02 19:44:35 cwrapp Exp $
-//
-// CHANGE LOG
-// $Log: TcpConnection.h,v $
-// Revision 1.6 2015/08/02 19:44:35 cwrapp
-// Release 6.6.0 commit.
-//
-// Revision 1.5 2007/12/28 12:34:40 cwrapp
-// Version 5.0.1 check-in.
-//
-// Revision 1.4 2005/05/28 13:31:18 cwrapp
-// Updated C++ examples.
-//
-// Revision 1.0 2003/12/14 19:40:45 charlesr
-// Initial revision
-//
-
-#include
-#if defined(WIN32)
-#include
-#else
-#include
-#endif
-#include "TcpSegment.h"
-#include "TcpConnection_sm.h"
-#include "TcpConnectionListener.h"
-#include "InputListener.h"
-#include "TimerListener.h"
-
-class TcpConnection :
- /* implements */ public InputListener,
- /* implements */ public TimerListener
-#ifdef CRTP
- /* extends */ , public TcpConnectionContext
-#endif
-{
-// Member functions.
- public:
-
- virtual ~TcpConnection();
-
- // Return the far-end's 4-byte IP address.
- unsigned long getFarAddress() const;
-
- // Return the far-end's TCP port.
- unsigned short getFarPort() const;
-
- // Return the current sequence number.
- unsigned long getSequenceNumber() const;
-
- // Send the raw bytes to the far end client socket.
- void transmit(const char *data,
- int offset,
- int size);
-
- // Start closing this connection.
- void doClose();
-
- // Set an accepted client socket's listener.
- void setListener(TcpConnectionListener& listener);
-
- // Socket event handling methods.
- void handleReceive(int fd);
- void handleTimeout(const char *name);
-
- //-----------------------------------------------------------
- // State Machine Actions
- //
- void openServerSocket(unsigned short port);
- void openClientSocket(const sockaddr_in *address);
- void openSuccess();
- void openFailed(const char *reason);
- void closeSocket();
- void halfClosed();
- void closed(const char *reason);
- void clearListener();
- void transmitted();
- void transmitFailed(const char *reason);
- void receive(const TcpSegment& segment);
- void sendOpenSyn(const sockaddr_in *address);
- void accept(const TcpSegment& segment);
- void accepted();
- void sendSynAck(const TcpSegment& segment);
- void sendSynAckAck(const TcpSegment& segment);
- void doSend(unsigned short flags,
- const char *data,
- int offset,
- int size,
- const TcpSegment *recv_segment);
- void startTimer(const char *name, time_t time);
- void stopTimer(const char *name);
- void setNearAddress();
- void setFarAddress(const TcpSegment& segment);
- void deleteSegment(const TcpSegment& segment);
-
- protected:
-
- // Server and active client socket constructor.
- TcpConnection(TcpConnectionListener& listener);
-
- // "Accepted" socket constructor.
- TcpConnection(const sockaddr_in& near_address,
- const sockaddr_in& far_address,
-#if defined(WIN32)
- unsigned short actual_port,
- SOCKET udp_socket,
- HANDLE udp_handle,
-#else
- int udp_socket,
-#endif
- int sequence_number,
- TcpServer& server,
- TcpConnectionListener& listener);
-
- // Open a server socket.
- void passiveOpen(unsigned short port);
-
- // Open a client socket.
- void activeOpen(const sockaddr_in& address);
-
- // An accepted client socket.
- void acceptOpen(const TcpSegment& segment);
-
- private:
-
- // Copy construction and assignment not allowed.
- TcpConnection(const TcpConnection&);
- const TcpConnection& operator=(const TcpConnection&);
-
- // Increase the buffer's size.
- void expandBuffer();
-
-#if defined(WIN32)
- // Windows doesn't bind UDP sockets to random ports
- // correctly. So this app has to do it itself.
- int doBind(int handle) const;
-#else
- // Return the UDP socket's port.
- unsigned short getLocalPort(int fd) const;
-#endif
-
- // Return this machine's address.
- unsigned long getLocalAddress() const;
-
- // Return the expected ack number for the given segment.
- int getAck(const TcpSegment& segment);
-
-// Member data.
- public:
-
- // Constants.
- // Initial Sequence Number.
- const static unsigned long ISN;
-
- // Minimum timeout is 1 millisecond.
- const static int MIN_TIMEOUT;
-
- // Wait only so long for an ACK (in milliseconds).
- const static int ACK_TIMEOUT;
-
- // Wait a while before reusing this port (in milliseconds).
- const static int CLOSE_TIMEOUT;
-
- // Allocate the input buffer using this block size.
- const static int BUFFER_BLOCK_SIZE;
-
- protected:
-
- // Send TCP events to this listener.
- TcpConnectionListener *_listener;
-
- // Connected to this address.
- sockaddr_in _farAddress;
-
- // This socket's address.
- sockaddr_in _nearAddress;
-
-#if defined(WIN32)
- // This socket's actual port number.
- unsigned short _actualPort;
-#endif
-
- private:
-
-#if defined(WIN32)
- SOCKET _udp_win_socket;
-#endif
- int _udp_socket;
- unsigned long _sequence_number;
-
- // Read data into the following buffer.
- char *_buffer;
- int _bufferSize;
-
- // The server which accepted this connection. Will only be
- // set if this is an "accepted" client connection.
- TcpServer *_server;
-
- // Store failure messages here.
- char *_errorMessage;
-
-#ifndef CRTP
- TcpConnectionContext _fsm;
-#endif
-};
-
-#endif
diff --git a/FSM/samples/TCP/TcpConnectionListener.h b/FSM/samples/TCP/TcpConnectionListener.h
deleted file mode 100644
index e77f0a39b..000000000
--- a/FSM/samples/TCP/TcpConnectionListener.h
+++ /dev/null
@@ -1,81 +0,0 @@
-#ifndef _H_TCPCONNECTIONLISTENER
-#define _H_TCPCONNECTIONLISTENER
-
-//
-// The contents of this file are subject to the Mozilla Public
-// License Version 1.1 (the "License"); you may not use this file
-// except in compliance with the License. You may obtain a copy
-// of the License at http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an
-// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-// implied. See the License for the specific language governing
-// rights and limitations under the License.
-//
-// The Original Code is State Machine Compiler (SMC).
-//
-// The Initial Developer of the Original Code is Charles W. Rapp.
-// Portions created by Charles W. Rapp are
-// Copyright (C) 2000 - 2007. Charles W. Rapp.
-// All Rights Reserved.
-//
-// Contributor(s):
-//
-// Name
-// TcpConnectionListener.h
-//
-// Description
-// TCP connection connection callback handler.
-//
-// RCS ID
-// $Id: TcpConnectionListener.h,v 1.5 2007/12/28 12:34:40 cwrapp Exp $
-//
-// CHANGE LOG
-// $Log: TcpConnectionListener.h,v $
-// Revision 1.5 2007/12/28 12:34:40 cwrapp
-// Version 5.0.1 check-in.
-//
-// Revision 1.4 2005/05/28 13:31:18 cwrapp
-// Updated C++ examples.
-//
-// Revision 1.0 2003/12/14 19:41:24 charlesr
-// Initial revision
-//
-
-// Forward declarations.
-class TcpConnection;
-class TcpClient;
-class TcpServer;
-
-class TcpConnectionListener
-{
-// Member functions.
-public:
-
- virtual ~TcpConnectionListener()
- {};
-
- virtual void opened(TcpConnection& connection)=0;
- virtual void openFailed(const char *reason,
- TcpConnection& connection)=0;
- virtual void halfClosed(TcpConnection& connection)=0;
- virtual void closed(const char *reason,
- TcpConnection& connection)=0;
- virtual void transmitted(TcpConnection& connection)=0;
- virtual void transmitFailed(const char *reason,
- TcpConnection& connection)=0;
- virtual void receive(const char *data,
- int size,
- TcpConnection& connection)=0;
- virtual void accepted(TcpClient& client, TcpServer& server)=0;
-
-protected:
-private:
-
-// Member data.
-public:
-protected:
-private:
-};
-
-#endif
diff --git a/FSM/samples/TCP/TcpSegment.cpp b/FSM/samples/TCP/TcpSegment.cpp
deleted file mode 100644
index 50d194006..000000000
--- a/FSM/samples/TCP/TcpSegment.cpp
+++ /dev/null
@@ -1,471 +0,0 @@
-//
-// The contents of this file are subject to the Mozilla Public
-// License Version 1.1 (the "License"); you may not use this file
-// except in compliance with the License. You may obtain a copy
-// of the License at http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an
-// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-// implied. See the License for the specific language governing
-// rights and limitations under the License.
-//
-// The Original Code is State Machine Compiler (SMC).
-//
-// The Initial Developer of the Original Code is Charles W. Rapp.
-// Portions created by Charles W. Rapp are
-// Copyright (C) 2000 - 2007. Charles W. Rapp.
-// All Rights Reserved.
-//
-// Contributor(s):
-//
-// Name
-// TcpSegment.cpp
-//
-// Description
-// Converts between raw bytes and segment objects.
-//
-// RCS ID
-// $Id: TcpSegment.cpp,v 1.5 2007/12/28 12:34:40 cwrapp Exp $
-//
-// CHANGE LOG
-// $Log: TcpSegment.cpp,v $
-// Revision 1.5 2007/12/28 12:34:40 cwrapp
-// Version 5.0.1 check-in.
-//
-// Revision 1.4 2005/05/28 13:31:18 cwrapp
-// Updated C++ examples.
-//
-// Revision 1.0 2003/12/14 19:41:38 charlesr
-// Initial revision
-//
-
-#include "TcpSegment.h"
-#include
-#include
-#include
-#if !defined(WIN32)
-#include
-#include
-#endif
-
-using namespace std;
-
-// Static member data declarations.
-const int TcpSegment::TCP_HEADER_SIZE = 16;
-
-//---------------------------------------------------------------
-// TcpSegment(const sockaddr_in&, ...) (Public)
-// Create an outbound segment.
-//
-TcpSegment::TcpSegment(const sockaddr_in& source_address,
- const sockaddr_in& destination_address,
- unsigned long sequence_number,
- unsigned long ack_number,
- unsigned short flags,
- const char *data,
- int offset,
- int size)
-{
- (void) memcpy(&_src_address,
- &source_address,
- sizeof(source_address));
- (void) memcpy(&_dest_address,
- &destination_address,
- sizeof(destination_address));
- _sequence_number = sequence_number;
- _ack_number = ack_number;
- _flags = flags;
-
- // Copy the data.
- _data = new char[size];
- _data_size = size;
- (void) memcpy(_data, (data + offset), size);
-
- return;
-} // end of TcpSegment::TcpSegment(const sockaddr_in&, ...)
-
-//---------------------------------------------------------------
-// TcpSegment(const sockaddr_in&, ...) (Public)
-// Create an inbound segment.
-//
-TcpSegment::TcpSegment(const sockaddr_in& source_address,
- const sockaddr_in& dest_address,
- const char *data,
- int)
-{
- unsigned short srcPort;
- unsigned short destPort;
- unsigned long sequence;
- unsigned long ack;
- unsigned short flags;
- unsigned short data_size;
-
- srcPort = ((((unsigned short) data[ 0]) & 0x00ff) << 8) |
- (((unsigned short) data[ 1]) & 0x00ff);
- destPort = ((((unsigned short) data[ 2]) & 0x00ff) << 8) |
- (((unsigned short) data[ 3]) & 0x00ff);
- sequence = ((((unsigned long) data[ 4]) & 0x000000ff) << 24) |
- ((((unsigned long) data[ 5]) & 0x000000ff) << 16) |
- ((((unsigned long) data[ 6]) & 0x000000ff) << 8) |
- (((unsigned long) data[ 7]) & 0x000000ff);
- ack = ((((unsigned long) data[ 8]) & 0x000000ff) << 24) |
- ((((unsigned long) data[ 9]) & 0x000000ff) << 16) |
- ((((unsigned long) data[10]) & 0x000000ff) << 8) |
- (((unsigned long) data[11]) & 0x000000ff);
- flags = ((((unsigned short) data[12]) & 0x00ff) << 8) |
- (((unsigned short) data[13]) & 0x00ff);
- data_size = ((((unsigned short) data[14]) & 0x00ff) << 8) |
- (((unsigned short) data[15]) & 0x00ff);
-
- // Set the source address.
- _src_address.sin_family = AF_INET;
- _src_address.sin_port = ntohs(srcPort);
- _src_address.sin_addr.s_addr = source_address.sin_addr.s_addr;
-
- // Set the destination address.
- _dest_address.sin_family = AF_INET;
- _dest_address.sin_port = ntohs(destPort);
- _dest_address.sin_addr.s_addr = dest_address.sin_addr.s_addr;
-
- _sequence_number = sequence;
- _ack_number = ack;
- _flags = flags;
- _data_size = data_size;
-
-
- if (_data_size == 0)
- {
- _data = NULL;
- }
- else
- {
- _data = new char[_data_size];
- (void) memcpy(_data,
- &(data[TCP_HEADER_SIZE]),
- _data_size);
- }
-
- return;
-} // end of TcpSegment::TcpSegment(const char*, int)
-
-//---------------------------------------------------------------
-// ~TcpSegment() (Public)
-// Destructor.
-//
-TcpSegment::~TcpSegment()
-{
- if (_data != NULL)
- {
- delete[] _data;
- _data = NULL;
- _data_size = 0;
- }
-} // end of TcpSegment::~TcpSegment()
-
-//---------------------------------------------------------------
-// getSource() const (Public)
-// Return segment's source address.
-//
-const sockaddr_in& TcpSegment::getSource() const
-{
- return(_src_address);
-} // end of TcpSegment::getSource() const
-
-//---------------------------------------------------------------
-// getDestination() const (Public)
-// Return segment's destination address.
-//
-const sockaddr_in& TcpSegment::getDestination() const
-{
- return(_dest_address);
-} // end of TcpSegment::getDestination() const
-
-//---------------------------------------------------------------
-// getSrcAddress() const (Public)
-// Return the segment's source address.
-//
-unsigned long TcpSegment::getSrcAddress() const
-{
- return (_src_address.sin_addr.s_addr);
-} // end of TcpSegment::getSrcAddress() const
-
-//---------------------------------------------------------------
-// getSrcPort() const (Public)
-// Return the segment's source port.
-//
-unsigned short TcpSegment::getSrcPort() const
-{
- return (_src_address.sin_port);
-} // end of TcpSegment::getSrcPort() const
-
-//---------------------------------------------------------------
-// getDestAddress() const (Public)
-// Return the segment's destination address.
-//
-unsigned long TcpSegment::getDestAddress() const
-{
- return (_dest_address.sin_addr.s_addr);
-} // end of TcpSegment::getDestAddress() const
-
-//---------------------------------------------------------------
-// getDestPort() const (Public)
-// Return the segment's destination port.
-//
-unsigned short TcpSegment::getDestPort() const
-{
- return (_dest_address.sin_port);
-} // end of TcpSegment::getDestPort() const
-
-//---------------------------------------------------------------
-// getSequenceNumber() const (Public)
-// Return segment's sequence number.
-//
-unsigned long TcpSegment::getSequenceNumber() const
-{
- return(_sequence_number);
-} // end of TcpSegment::getSequenceNumber() const
-
-//---------------------------------------------------------------
-// getAcknowledgeNumber() const (Public)
-// Return segment's acknowledge number.
-//
-unsigned long TcpSegment::getAcknowledgeNumber() const
-{
- return(_ack_number);
-} // end of TcpSegment::getAcknowledgeNumber() const
-
-//---------------------------------------------------------------
-// getFlags() const (Public)
-// Return segment's flags.
-//
-unsigned short TcpSegment::getFlags() const
-{
- return(_flags);
-} // end of TcpSegment::getFlags() const
-
-//---------------------------------------------------------------
-// getDataSize() const (Public)
-// Return segment's data size.
-//
-int TcpSegment::getDataSize() const
-{
- return(_data_size);
-} // end of TcpSegment::getDataSize() const
-
-//---------------------------------------------------------------
-// getData() const (Public)
-// Return segment's data.
-//
-const char* TcpSegment::getData() const
-{
- return(_data);
-} // end of TcpSegment::getData() const
-
-//---------------------------------------------------------------
-// packetize(char*&, int&) (Public)
-// Convert this TCP segment into raw bytes.
-//
-void TcpSegment::packetize(char*& data, int& size)
-{
- unsigned short srcPort;
- unsigned short destPort;
- unsigned long sequence;
- unsigned long ack;
- unsigned short flags;
- unsigned short data_size;
-
- // The segment's size is the TCP header size + data size.
- // (TCP options are *not* supported).
- size = TCP_HEADER_SIZE + _data_size;
-
- data = new char[size];
-
- // Get data in network byte order.
- srcPort = htons(_src_address.sin_port);
- destPort = htons(_dest_address.sin_port);
- sequence = _sequence_number;
- ack = _ack_number;
- flags = _flags;
- data_size = _data_size;
-
- // Fill in the TCP header.
- data[ 0] = (char) (( srcPort & 0xff00) >> 8);
- data[ 1] = (char) ( srcPort & 0x00ff);
- data[ 2] = (char) (( destPort & 0xff00) >> 8);
- data[ 3] = (char) ( destPort & 0x00ff);
- data[ 4] = (char) (( sequence & 0xff000000) >> 24);
- data[ 5] = (char) (( sequence & 0x00ff0000) >> 16);
- data[ 6] = (char) (( sequence & 0x0000ff00) >> 8);
- data[ 7] = (char) ( sequence & 0x000000ff);
- data[ 8] = (char) (( ack & 0xff000000) >> 24);
- data[ 9] = (char) (( ack & 0x00ff0000) >> 16);
- data[10] = (char) (( ack & 0x0000ff00) >> 8);
- data[11] = (char) ( ack & 0x000000ff);
- data[12] = (char) (( flags & 0xff00) >> 8);
- data[13] = (char) ( flags & 0x00ff);
- data[14] = (char) ((data_size & 0xff00) >> 8);
- data[15] = (char) (data_size & 0x00ff);
-
- // Copy in the data.
- if (_data_size > 0)
- {
- (void) memcpy((data + TCP_HEADER_SIZE),
- _data,
- _data_size);
- }
-
- return;
-} // end of TcpSegment::packetize(char&*, int&)
-
-//---------------------------------------------------------------
-// flagsToString(unsigned short) (Static Private)
-// Make a string representation of the TCP header flags.
-//
-char* TcpSegment::flagsToString(unsigned short flags)
-{
- char separator[3] = "{";
- char *retval;
- char *cptr;
-
- (void) strcpy(separator, "{");
- retval = new char[31];
- (void) memset(retval, 0, 31);
- cptr = retval;
- if ((flags & FIN) == FIN)
- {
- (void) strcpy(cptr, separator);
- cptr += strlen(separator);
- (void) strcpy(cptr, "FIN");
- cptr += 3;
- (void) strcpy(separator, ", ");
- }
-
- if ((flags & SYN) == SYN)
- {
- (void) strcpy(cptr, separator);
- cptr += strlen(separator);
- (void) strcpy(cptr, "SYN");
- cptr += 3;
- (void) strcpy(separator, ", ");
- }
-
- if ((flags & RST) == RST)
- {
- (void) strcpy(cptr, separator);
- cptr += strlen(separator);
- (void) strcpy(cptr, "RST");
- cptr += 3;
- (void) strcpy(separator, ", ");
- }
-
- if ((flags & PSH) == PSH)
- {
- (void) strcpy(cptr, separator);
- cptr += strlen(separator);
- (void) strcpy(cptr, "PSH");
- cptr += 3;
- (void) strcpy(separator, ", ");
- }
-
- if ((flags & ACK) == ACK)
- {
- (void) strcpy(cptr, separator);
- cptr += strlen(separator);
- (void) strcpy(cptr, "ACK");
- cptr += 3;
- (void) strcpy(separator, ", ");
- }
-
- if ((flags & URG) == URG)
- {
- (void) strcpy(cptr, separator);
- cptr += strlen(separator);
- (void) strcpy(cptr, "URG");
- cptr += 3;
- }
-
- if ((flags & FLAG_MASK) == 0)
- {
- (void) strcpy(cptr, separator);
- cptr += strlen(separator);
- (void) strcpy(cptr, "UNK");
- cptr += 3;
- }
-
- *cptr = '}';
-
- return(retval);
-} // end of TcpSegment::flagsToString(unsigned short)
-
-//---------------------------------------------------------------
-// addressToString(const sockaddr_in&) (Static Private)
-// Generate a string representation of an IP address.
-//
-char* TcpSegment::addressToString(const sockaddr_in& address)
-{
- struct hostent *hostEntry;
- char *dotted_addr;
- char port[6];
- char *retval;
- char *cptr;
- unsigned short udp_port;
-
- retval = new char[512];
- (void) memset(retval, 0, 512);
- cptr = retval;
- hostEntry = gethostbyaddr((char *) &(address.sin_addr),
- sizeof(address.sin_addr),
- AF_INET);
- (void) strcpy(cptr,
- (hostEntry == NULL ?
- "" :
- hostEntry->h_name));
- cptr += strlen(cptr);
- *cptr++ = '(';
- dotted_addr = inet_ntoa(address.sin_addr);
- (void) strcpy(cptr, dotted_addr);
- cptr += strlen(dotted_addr);
- (void) strcpy(cptr, "):");
- cptr += 2;
- udp_port = ntohs(address.sin_port);
- sprintf(port, "%d", udp_port);
- (void) strcpy(cptr, port);
-
- return(retval);
-} // end of TcpSegment::addressToString(const sockaddr_in&)
-
-//---------------------------------------------------------------
-// operator<<(ostream&, const TcpSegment&) (Routine)
-// Print this segment out to the stream.
-//
-ostream& operator<<(ostream& stream, const TcpSegment& segment)
-{
- char *srcAddrStr,
- *destAddrStr,
- *flagStr;
-
- srcAddrStr = TcpSegment::addressToString(segment._src_address);
- destAddrStr = TcpSegment::addressToString(segment._dest_address);
- flagStr = TcpSegment::flagsToString(segment._flags);
-
- stream << "\t Source: "
- << srcAddrStr
- << "\n\t Destination: "
- << destAddrStr
- << "\n\t Sequence #: "
- << segment._sequence_number
- << "\n\tAcknowledge #: "
- << segment._ack_number
- << "\n\t Flags: "
- << flagStr
- << " (0x"
- << ios::hex << segment._flags << ios::dec << ")"
- << "\n\t Data size: "
- << segment._data_size;
-
- delete[] srcAddrStr;
- delete[] destAddrStr;
- delete[] flagStr;
-
- return(stream);
-} // end of operator<<(ostream&, const TcpSegment&)
diff --git a/FSM/samples/TCP/TcpSegment.h b/FSM/samples/TCP/TcpSegment.h
deleted file mode 100644
index d7a4829d8..000000000
--- a/FSM/samples/TCP/TcpSegment.h
+++ /dev/null
@@ -1,145 +0,0 @@
-#ifndef _H_TCPSEGMENT
-#define _H_TCPSEGMENT
-
-//
-// The contents of this file are subject to the Mozilla Public
-// License Version 1.1 (the "License"); you may not use this file
-// except in compliance with the License. You may obtain a copy
-// of the License at http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an
-// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-// implied. See the License for the specific language governing
-// rights and limitations under the License.
-//
-// The Original Code is State Machine Compiler (SMC).
-//
-// The Initial Developer of the Original Code is Charles W. Rapp.
-// Portions created by Charles W. Rapp are
-// Copyright (C) 2000 - 2007. Charles W. Rapp.
-// All Rights Reserved.
-//
-// Contributor(s):
-//
-// Name
-// TcpSegment.h
-//
-// Description
-// All TCP transmissions are put into a segment.
-//
-// RCS ID
-// $Id: TcpSegment.h,v 1.6 2007/12/28 12:34:40 cwrapp Exp $
-//
-// CHANGE LOG
-// $Log: TcpSegment.h,v $
-// Revision 1.6 2007/12/28 12:34:40 cwrapp
-// Version 5.0.1 check-in.
-//
-// Revision 1.5 2005/06/08 11:09:12 cwrapp
-// + Updated Python code generator to place "pass" in methods with empty
-// bodies.
-// + Corrected FSM errors in Python example 7.
-// + Removed unnecessary includes from C++ examples.
-// + Corrected errors in top-level makefile's distribution build.
-//
-// Revision 1.4 2005/05/28 13:31:18 cwrapp
-// Updated C++ examples.
-//
-// Revision 1.0 2003/12/14 19:41:54 charlesr
-// Initial revision
-//
-
-#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
-#include
-#include
-#include
-#elif defined(WIN32)
-#include
-#include
-#else
-#include
-#include
-#include
-#endif
-
-class TcpSegment
-{
-// Member functions.
-public:
-
- TcpSegment(const sockaddr_in& source_address,
- const sockaddr_in& destination_address,
- unsigned long sequence_number,
- unsigned long ack_number,
- unsigned short flags,
- const char *data,
- int offset,
- int size);
-
- // Convert the raw bytes into a segment.
- TcpSegment(const sockaddr_in& source_address,
- const sockaddr_in& dest_address,
- const char *data,
- int size);
-
- // Destructor.
- ~TcpSegment();
-
- const sockaddr_in& getSource() const;
- const sockaddr_in& getDestination() const;
- unsigned long getSrcAddress() const;
- unsigned short getSrcPort() const;
- unsigned long getDestAddress() const;
- unsigned short getDestPort() const;
- unsigned long getSequenceNumber() const;
- unsigned long getAcknowledgeNumber() const;
- unsigned short getFlags() const;
- int getDataSize() const;
- const char* getData() const;
-
- // Convert this segment into raw bytes.
- void packetize(char*& data, int& size);
-
- friend std::ostream& operator<<(std::ostream& stream,
- const TcpSegment& segment);
-
- protected:
- private:
-
- static char* flagsToString(unsigned short flags);
- static char* addressToString(const sockaddr_in& address);
-
-// Member data.
- public:
-
- enum TcpHeaderFlags
- {
- NONE= 0x00,
- FIN = 0x01,
- SYN = 0x02,
- RST = 0x04,
- PSH = 0x08,
- ACK = 0x10,
- URG = 0x20,
- FIN_ACK = 0x11,
- SYN_ACK = 0x12,
- RST_ACK = 0x14,
- PSH_ACK = 0x18,
- FLAG_MASK = 0x3f
- };
-
- static const int TCP_HEADER_SIZE;
-
- protected:
- private:
-
- sockaddr_in _src_address;
- sockaddr_in _dest_address;
- unsigned long _sequence_number;
- unsigned long _ack_number;
- unsigned short _flags;
- char *_data;
- int _data_size;
-};
-
-#endif
diff --git a/FSM/samples/TCP/TcpServer.cpp b/FSM/samples/TCP/TcpServer.cpp
deleted file mode 100644
index 61f3384ac..000000000
--- a/FSM/samples/TCP/TcpServer.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-//
-// The contents of this file are subject to the Mozilla Public
-// License Version 1.1 (the "License"); you may not use this file
-// except in compliance with the License. You may obtain a copy
-// of the License at http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an
-// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-// implied. See the License for the specific language governing
-// rights and limitations under the License.
-//
-// The Original Code is State Machine Compiler (SMC).
-//
-// The Initial Developer of the Original Code is Charles W. Rapp.
-// Portions created by Charles W. Rapp are
-// Copyright (C) 2000 - 2007. Charles W. Rapp.
-// All Rights Reserved.
-//
-// Contributor(s):
-//
-// Name
-// TcpServer.cpp
-//
-// Description
-// TCP server connection class implementation.
-//
-// RCS ID
-// $Id: TcpServer.cpp,v 1.5 2007/12/28 12:34:40 cwrapp Exp $
-//
-// CHANGE LOG
-// $Log: TcpServer.cpp,v $
-// Revision 1.5 2007/12/28 12:34:40 cwrapp
-// Version 5.0.1 check-in.
-//
-// Revision 1.4 2005/05/28 13:31:18 cwrapp
-// Updated C++ examples.
-//
-// Revision 1.0 2003/12/14 19:43:00 charlesr
-// Initial revision
-//
-
-#include "TcpServer.h"
-
-//---------------------------------------------------------------
-// TcpServer(TcpConnectionListener&) (Public)
-// Create a TCP service object.
-//
-TcpServer::TcpServer(TcpConnectionListener& listener)
-: TcpConnection(listener)
-{}
-
-//---------------------------------------------------------------
-// ~TcpServer() (Public)
-// Destructor.
-//
-TcpServer::~TcpServer()
-{}
-
-//---------------------------------------------------------------
-// getPort() const (Public)
-// Return this service's TCP port.
-//
-unsigned short TcpServer::getPort() const
-{
- return(_nearAddress.sin_port);
-} // end of TcpServer::getPort() const
-
-//---------------------------------------------------------------
-// getAddress() const (Public)
-// Return this service's IP address.
-//
-unsigned long TcpServer::getAddress() const
-{
- return(_nearAddress.sin_addr.s_addr);
-} // end of TcpServer::getAddress() const
-
-//---------------------------------------------------------------
-// open(unsigned short) (Public)
-// Open this TCP service.
-//
-void TcpServer::open(unsigned short port)
-{
- passiveOpen(port);
- return;
-} // end of TcpServer::open(unsigned short)
diff --git a/FSM/samples/TCP/TcpServer.h b/FSM/samples/TCP/TcpServer.h
deleted file mode 100644
index 878d20f05..000000000
--- a/FSM/samples/TCP/TcpServer.h
+++ /dev/null
@@ -1,77 +0,0 @@
-#ifndef _H_TCPSERVER
-#define _H_TCPSERVER
-
-//
-// The contents of this file are subject to the Mozilla Public
-// License Version 1.1 (the "License"); you may not use this file
-// except in compliance with the License. You may obtain a copy
-// of the License at http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an
-// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-// implied. See the License for the specific language governing
-// rights and limitations under the License.
-//
-// The Original Code is State Machine Compiler (SMC).
-//
-// The Initial Developer of the Original Code is Charles W. Rapp.
-// Portions created by Charles W. Rapp are
-// Copyright (C) 2000 - 2007. Charles W. Rapp.
-// All Rights Reserved.
-//
-// Contributor(s):
-//
-// Name
-// TcpServer.h
-//
-// Description
-// TCP server connection class header.
-//
-// RCS ID
-// $Id: TcpServer.h,v 1.5 2007/12/28 12:34:40 cwrapp Exp $
-//
-// CHANGE LOG
-// $Log: TcpServer.h,v $
-// Revision 1.5 2007/12/28 12:34:40 cwrapp
-// Version 5.0.1 check-in.
-//
-// Revision 1.4 2005/05/28 13:31:18 cwrapp
-// Updated C++ examples.
-//
-// Revision 1.0 2003/12/14 19:43:20 charlesr
-// Initial revision
-//
-
-#include "TcpConnection.h"
-
-class TcpServer: public TcpConnection
-{
-// Member functions.
-public:
-
- // Create a TCP service.
- TcpServer(TcpConnectionListener& listener);
-
- // Destructor.
- ~TcpServer();
-
- // Return the TCP service's port.
- unsigned short getPort() const;
-
- // Return the TCP service's address.
- unsigned long getAddress() const;
-
- // Open the TCP service.
- void open(unsigned short port);
-
-protected:
-private:
-
-// Member data.
-public:
-protected:
-private:
-
-};
-
-#endif
diff --git a/FSM/samples/TCP/TimerListener.h b/FSM/samples/TCP/TimerListener.h
deleted file mode 100644
index 19d4922dd..000000000
--- a/FSM/samples/TCP/TimerListener.h
+++ /dev/null
@@ -1,68 +0,0 @@
-#ifndef _H_TIMERLISTENER
-#define _H_TIMERLISTENER
-
-//
-// The contents of this file are subject to the Mozilla Public
-// License Version 1.1 (the "License"); you may not use this file
-// except in compliance with the License. You may obtain a copy
-// of the License at http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an
-// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-// implied. See the License for the specific language governing
-// rights and limitations under the License.
-//
-// The Original Code is State Machine Compiler (SMC).
-//
-// The Initial Developer of the Original Code is Charles W. Rapp.
-// Portions created by Charles W. Rapp are
-// Copyright (C) 2000 - 2007. Charles W. Rapp.
-// All Rights Reserved.
-//
-// Contributor(s):
-//
-// Name
-// TimerListener.h
-//
-// Description
-// Timer event handler.
-//
-// RCS ID
-// $Id: TimerListener.h,v 1.5 2007/12/28 12:34:40 cwrapp Exp $
-//
-// CHANGE LOG
-// $Log: TimerListener.h,v $
-// Revision 1.5 2007/12/28 12:34:40 cwrapp
-// Version 5.0.1 check-in.
-//
-// Revision 1.4 2005/05/28 13:31:18 cwrapp
-// Updated C++ examples.
-//
-// Revision 1.0 2003/12/14 19:43:36 charlesr
-// Initial revision
-//
-
-class TimerListener
-{
-// Member functions.
-public:
-
- // Default constructor.
- TimerListener() {};
-
- // Destructor.
- virtual ~TimerListener() {};
-
- // Input callback method.
- virtual void handleTimeout(const char *name)=0;
-
-protected:
-private:
-
-// Member data.
-public:
-protected:
-private:
-};
-
-#endif
diff --git a/FSM/samples/TCP/client.cpp b/FSM/samples/TCP/client.cpp
deleted file mode 100644
index 7a33db575..000000000
--- a/FSM/samples/TCP/client.cpp
+++ /dev/null
@@ -1,277 +0,0 @@
-//
-// The contents of this file are subject to the Mozilla Public
-// License Version 1.1 (the "License"); you may not use this file
-// except in compliance with the License. You may obtain a copy
-// of the License at http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an
-// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-// implied. See the License for the specific language governing
-// rights and limitations under the License.
-//
-// The Original Code is State Machine Compiler (SMC).
-//
-// The Initial Developer of the Original Code is Charles W. Rapp.
-// Portions created by Charles W. Rapp are
-// Copyright (C) 2000 - 2007. Charles W. Rapp.
-// All Rights Reserved.
-//
-// Contributor(s):
-//
-// File
-// client.cpp
-//
-// Description
-// Encapsulates "TCP" client connection.
-//
-// RCS ID
-// $Id: client.cpp,v 1.6 2007/12/28 12:34:40 cwrapp Exp $
-//
-// CHANGE LOG
-// $Log: client.cpp,v $
-// Revision 1.6 2007/12/28 12:34:40 cwrapp
-// Version 5.0.1 check-in.
-//
-// Revision 1.5 2005/06/08 11:09:12 cwrapp
-// + Updated Python code generator to place "pass" in methods with empty
-// bodies.
-// + Corrected FSM errors in Python example 7.
-// + Removed unnecessary includes from C++ examples.
-// + Corrected errors in top-level makefile's distribution build.
-//
-// Revision 1.4 2005/05/28 13:31:18 cwrapp
-// Updated C++ examples.
-//
-// Revision 1.0 2003/12/14 19:43:52 charlesr
-// Initial revision
-//
-
-#include "Eventloop.h"
-#include "AppClient.h"
-#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
-#include
-#include
-#include
-#elif defined(WIN32)
-#include
-#else
-#include
-#include
-#include
-#endif
-#include
-#include
-
-using namespace std;
-
-#ifndef WIN32
-#ifndef SA_NOMASK
-#define SA_NOMASK 0
-#endif
-#endif
-
-// Global variable declarations.
-Eventloop *Gevent_loop;
-
-// Static variable declarations.
-static AppClient *Sclient_socket;
-
-// Constant declarations.
-const static int STDIN_FD = 0;
-#ifndef INADDR_NONE
-const static unsigned long INADDR_NONE = 0xffffffff;
-#endif
-
-#if defined(WIN32)
-char* winsock_strerror(int);
-#endif
-
-//---------------------------------------------------------------
-// main(int, char**) (Routine)
-// Process the command line arguments, open the TCP service and
-// then sit in the event loop. Stop running when the Enter key
-// is hit.
-//
-int main(int argc, char *argv[])
-{
- int longPort;
- unsigned long ip_address = INADDR_ANY;
- sockaddr_in address;
- int retcode;
-#if defined(WIN32)
- WORD winsockVersion;
- WSADATA winsockData;
- int errorCode;
-#else
- struct sigaction signalAction;
-#endif
-
- // External routine declarations.
- unsigned long getIPAddress(const char*);
- void sigintHandler(int);
-#if defined(WIN32)
- char* winsock_strerror(int);
-#endif
-
-#ifdef WIN32
- // Windows kinda supports signals.
- (void) signal(SIGINT, sigintHandler);
-#else
- // Set up the SIGINT handler.
- signalAction.sa_handler = sigintHandler;
-#if defined(__hpux) || defined (__linux__)
- sigemptyset(&signalAction.sa_mask);
-#if defined(__linux__)
- signalAction.sa_restorer = NULL;
-#endif
-#endif
- signalAction.sa_flags = SA_NOMASK;
- if (sigaction(SIGINT,
- &signalAction,
- (struct sigaction *) NULL) != 0)
- {
- cerr << "Unable to set SIGINT handling function." << endl;
- exit(1);
- }
-#endif
-
-#if defined(WIN32)
- // Initialize winsock.
- winsockVersion = MAKEWORD(2, 0);
- if ((errorCode = WSAStartup(winsockVersion, &winsockData)) != 0)
- {
- cout << "Unable to initialize Win32 sockets - "
- << winsock_strerror(errorCode)
- << "."
- << endl;
- exit(2);
- }
-#endif
-
- if (argc != 3)
- {
- cerr << argv[0]
- << ": Wrong number of arguments."
- << endl;
- cerr << "usage: client {hostname | IP address} port" << endl;
- retcode = 1;
- }
- // Check the port's validity.
- else if (sscanf(argv[2], "%d", &longPort) != 1 ||
- longPort < 0 ||
- longPort > 65535)
- {
- cerr << "Invalid port number - \""
- << argv[2]
- << "\"."
- << endl;
- retcode = 2;
- }
- // Check the address' validity.
- else if ((ip_address = getIPAddress(argv[1])) == INADDR_NONE)
- {
- cerr << "Invalid host - \""
- << argv[1]
- << "\"."
- << endl;
- retcode = 3;
- }
- else
- {
- string host(argv[1]);
- unsigned short port;
-
- // Set up the service address.
- (void) memset(&address, 0, sizeof(address));
- address.sin_family = AF_INET;
- port = static_cast(longPort);
- address.sin_port = htons(port);
- address.sin_addr.s_addr = ip_address;
-
- cout << "(Starting execution. Hit \"Cntl-c\" to stop.)" << endl;
-
- // 1. Create the event loop object.
- Gevent_loop = new Eventloop();
-
- // 2. Open server port.
- Sclient_socket = new AppClient();
- Sclient_socket->open(host, address);
-
- // 3. Start connection process.
- Gevent_loop->start();
-
- cout << "(Stopping execution.)" << endl;
-
- // 4. Close connection.
- delete Sclient_socket;
- Sclient_socket = NULL;
-
- // Delete the event loop.
- delete Gevent_loop;
- Gevent_loop = NULL;
-
-#if defined(WIN32)
- WSACleanup();
-#endif
-
- retcode = 0;
- }
-
- return(retcode);
-} // end of main(int, char**)
-
-//---------------------------------------------------------------
-// socketClosed() (Routine)
-// The server socket is closed. Stop the application.
-//
-void socketClosed()
-{
- Gevent_loop->stop();
- return;
-} // end of socketClosed()
-
-//---------------------------------------------------------------
-// getIPAddress(const char*) (Routine)
-// Convert a host name or dotted-decimal notation address into
-// an IP address.
-//
-unsigned long getIPAddress(const char *host)
-{
- hostent *host_entry = NULL;
- unsigned long retcode;
-
- // First try to convert host name as a dotted-decimal
- // notation. If that fails, try gethostbyname().
- if ((retcode = inet_addr(host)) == INADDR_NONE &&
- (host_entry = gethostbyname(host)) == NULL)
- {
- // Failed to convert host name into IP address.
- retcode = INADDR_NONE;
- }
- else if (host_entry != NULL)
- {
- (void) memcpy(&retcode,
- host_entry->h_addr,
- host_entry->h_length);
- }
-
- return(retcode);
-} // end of getIPAddress(const char*)
-
-//---------------------------------------------------------------
-// sigintHandler(int) (Routine)
-// When an interrupt is detected, start shutting down the
-// connection.
-//
-void sigintHandler(int)
-{
- Sclient_socket->close();
-
-#ifdef WIN32
- // Windows removes the SIGINT callback. So put
- // the callback back in place.
- (void) signal(SIGINT, sigintHandler);
-#endif
-
- return;
-} // end of sigintHandler(int)
diff --git a/FSM/samples/TCP/server.cpp b/FSM/samples/TCP/server.cpp
deleted file mode 100644
index 5bfb375f5..000000000
--- a/FSM/samples/TCP/server.cpp
+++ /dev/null
@@ -1,209 +0,0 @@
-//
-// The contents of this file are subject to the Mozilla Public
-// License Version 1.1 (the "License"); you may not use this file
-// except in compliance with the License. You may obtain a copy
-// of the License at http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an
-// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-// implied. See the License for the specific language governing
-// rights and limitations under the License.
-//
-// The Original Code is State Machine Compiler (SMC).
-//
-// The Initial Developer of the Original Code is Charles W. Rapp.
-// Portions created by Charles W. Rapp are
-// Copyright (C) 2000 - 2007. Charles W. Rapp.
-// All Rights Reserved.
-//
-// Contributor(s):
-//
-// Function
-// Main
-//
-// Description
-// Encapsulates "TCP" server connection, accepting new client connections.
-//
-// RCS ID
-// $Id: server.cpp,v 1.6 2007/12/28 12:34:40 cwrapp Exp $
-//
-// CHANGE LOG
-// $Log: server.cpp,v $
-// Revision 1.6 2007/12/28 12:34:40 cwrapp
-// Version 5.0.1 check-in.
-//
-// Revision 1.5 2005/06/08 11:09:12 cwrapp
-// + Updated Python code generator to place "pass" in methods with empty
-// bodies.
-// + Corrected FSM errors in Python example 7.
-// + Removed unnecessary includes from C++ examples.
-// + Corrected errors in top-level makefile's distribution build.
-//
-// Revision 1.4 2005/05/28 13:31:18 cwrapp
-// Updated C++ examples.
-//
-// Revision 1.0 2003/12/14 19:44:25 charlesr
-// Initial revision
-//
-
-#include "Eventloop.h"
-#include "AppServer.h"
-#include
-
-using namespace std;
-
-#ifndef WIN32
-#if !defined(SA_NOMASK)
-#define SA_NOMASK 0
-#endif
-#endif
-
-// Global variable declarations.
-Eventloop *Gevent_loop;
-
-// Static variable declarations.
-static AppServer *Sserver_socket;
-
-// Constant declarations.
-const static int STDIN_FD = 0;
-
-//---------------------------------------------------------------
-// main(int, char**) (Routine)
-// Process the command line arguments, open the TCP service and
-// then sit in the event loop. Stop running when the Enter key
-// is hit.
-//
-int main(int argc, char *argv[])
-{
- int longPort;
- int retcode;
-#if defined(WIN32)
- WORD winsockVersion;
- WSADATA winsockData;
- int errorCode;
-#else
- struct sigaction signalAction;
-#endif
-
- // External routine declarations.
- void sigintHandler(int);
-#if defined(WIN32)
- char* winsock_strerror(int);
-#endif
-
-#ifdef WIN32
- // Windows kinda supports signals.
- (void) signal(SIGINT, sigintHandler);
-#else
- // Set up the SIGINT handler.
- signalAction.sa_handler = sigintHandler;
-#if defined(__hpux) || defined (__linux__)
- sigemptyset(&signalAction.sa_mask);
-#if defined(__linux__)
- signalAction.sa_restorer = NULL;
-#endif
-#endif
- signalAction.sa_flags = SA_NOMASK;
- if (sigaction(SIGINT,
- &signalAction,
- (struct sigaction *) NULL) != 0)
- {
- cerr << "Unable to set SIGINT handling function." << endl;
- exit(1);
- }
-#endif
-
-#if defined(WIN32)
- // Initialize winsock.
- winsockVersion = MAKEWORD(2, 0);
- if ((errorCode = WSAStartup(winsockVersion, &winsockData)) != 0)
- {
- cout << "Unable to initialize Win32 sockets - "
- << winsock_strerror(errorCode)
- << "."
- << endl;
- exit(2);
- }
-#endif
-
- if (argc != 2)
- {
- cerr << argv[0]
- << ": Wrong number of arguments."
- << endl;
- cerr << "usage: server port" << endl;
- retcode = 1;
- }
- else if (sscanf(argv[1], "%d", &longPort) != 1 ||
- longPort < 0 ||
- longPort > 65535)
- {
- cerr << "Invalid port number - \""
- << argv[1]
- << "\"."
- << endl;
- retcode = 2;
- }
- else
- {
- unsigned short port;
-
- cout << "(Starting execution. Hit \"Cntl-c\" to stop.)" << endl;
-
- // 1. Create the event loop object.
- Gevent_loop = new Eventloop();
-
- // 2. Open server port.
- Sserver_socket = new AppServer();
- port = static_cast(longPort);
- Sserver_socket->open(htons(port));
-
- // 3. Wait for accept messages.
- Gevent_loop->start();
-
- cout << "(Stopping execution.)" << endl;
-
- // 4. Delete the TCP service.
- delete Sserver_socket;
- Sserver_socket = NULL;
-
- // 5. Delete the event loop.
- delete Gevent_loop;
- Gevent_loop = NULL;
-
-#if defined(WIN32)
- WSACleanup();
-#endif
-
- retcode = 0;
- }
-
- return(retcode);
-} // end of main(int, char**)
-
-//---------------------------------------------------------------
-// socketClosed() (Routine)
-// The server socket is closed. Stop the application.
-//
-void socketClosed()
-{
- Gevent_loop->stop();
- return;
-} // end of socketClosed()
-
-//---------------------------------------------------------------
-// sigintHandler(int) (Routine)
-// When an interrupt is detected, stop execution.
-//
-void sigintHandler(int)
-{
- Sserver_socket->close();
-
-#ifdef WIN32
- // Windows removes the SIGINT callback. So put
- // the callback back in place.
- (void) signal(SIGINT, sigintHandler);
-#endif
-
- return;
-} // end of sigintHandler(int)
diff --git a/FSM/samples/TCP/stdafx.cpp b/FSM/samples/TCP/stdafx.cpp
deleted file mode 100644
index cc787bcba..000000000
--- a/FSM/samples/TCP/stdafx.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-// stdafx.cpp : fichier source incluant simplement les fichiers Include standard
-// TCP.pch représente l'en-tête précompilé
-// stdafx.obj contient les informations de type précompilées
-
-#include "stdafx.h"
-
-// TODO: faites référence aux en-têtes supplémentaires nécessaires dans STDAFX.H
-// absents de ce fichier
diff --git a/FSM/samples/TCP/stdafx.h b/FSM/samples/TCP/stdafx.h
deleted file mode 100644
index 16ac0befb..000000000
--- a/FSM/samples/TCP/stdafx.h
+++ /dev/null
@@ -1,15 +0,0 @@
-// stdafx.h : fichier Include pour les fichiers Include système standard,
-// ou les fichiers Include spécifiques aux projets qui sont utilisés fréquemment,
-// et sont rarement modifiés
-//
-
-#pragma once
-
-#include "targetver.h"
-
-#include
-#include
-
-
-
-// TODO: faites référence ici aux en-têtes supplémentaires nécessaires au programme
diff --git a/FSM/samples/TCP/targetver.h b/FSM/samples/TCP/targetver.h
deleted file mode 100644
index c8351ffde..000000000
--- a/FSM/samples/TCP/targetver.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#pragma once
-
-// Si vous incluez SDKDDKVer.h, cela définit la dernière plateforme Windows disponible.
-
-// Si vous souhaitez générer votre application pour une plateforme Windows précédente, incluez WinSDKVer.h et
-// définissez la macro _WIN32_WINNT à la plateforme que vous souhaitez prendre en charge avant d'inclure SDKDDKVer.h.
-
-#include
diff --git a/FSM/samples/TCP/winsock_strerror.cpp b/FSM/samples/TCP/winsock_strerror.cpp
deleted file mode 100644
index ef5102860..000000000
--- a/FSM/samples/TCP/winsock_strerror.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-//
-// The contents of this file are subject to the Mozilla Public
-// License Version 1.1 (the "License"); you may not use this file
-// except in compliance with the License. You may obtain a copy
-// of the License at http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an
-// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-// implied. See the License for the specific language governing
-// rights and limitations under the License.
-//
-// The Original Code is State Machine Compiler (SMC).
-//
-// The Initial Developer of the Original Code is Charles W. Rapp.
-// Portions created by Charles W. Rapp are
-// Copyright (C) 2000 - 2003 Charles W. Rapp.
-// All Rights Reserved.
-//
-// Contributor(s):
-//
-// Function
-// Main
-//
-// Description
-// Encapsulates "TCP" server connection, accepting new client connections.
-//
-// RCS ID
-// $Id: winsock_strerror.cpp,v 1.5 2009/03/01 18:20:38 cwrapp Exp $
-//
-// CHANGE LOG
-// $Log: winsock_strerror.cpp,v $
-// Revision 1.5 2009/03/01 18:20:38 cwrapp
-// Preliminary v. 6.0.0 commit.
-//
-// Revision 1.4 2005/05/28 13:31:18 cwrapp
-// Updated C++ examples.
-//
-// Revision 1.0 2003/12/14 19:44:45 charlesr
-// Initial revision
-//
-
-#if defined(WIN32)
-#include
-
-//---------------------------------------------------------------
-// winsock_strerror(int) (Routine)
-// Return a string equivalent for a winsock error.
-//
-char* winsock_strerror(int error)
-{
- char *retval;
-
- switch (error)
- {
- case WSANOTINITIALISED:
- retval = "winsock library not initialized";
- break;
-
- case WSAENETDOWN:
- retval = "network down";
- break;
-
- case WSAEAFNOSUPPORT:
- retval = "address family not supported";
- break;
-
- case WSAEINPROGRESS:
- retval = "blocking call in progress";
- break;
-
- case WSAEMFILE:
- retval = "no more socket descriptors available";
- break;
-
- case WSAENOBUFS:
- retval = "buffer space exhausted";
- break;
-
- case WSAEPROTONOSUPPORT:
- retval = "specified protocol not supported";
- break;
-
- case WSAEPROTOTYPE:
- retval = "specified protocol incorrect type for socket";
- break;
-
- case WSAESOCKTNOSUPPORT:
- retval = "socket family and type combination not supported";
- break;
-
- case WSAEADDRINUSE:
- retval = "address in use";
- break;
-
- case WSAEADDRNOTAVAIL:
- retval = "address not available";
- break;
-
- case WSAEFAULT:
- retval = "invalid address";
- break;
-
- case WSAEINVAL:
- retval = "invalid request";
- break;
-
- case WSAENOTSOCK:
- retval = "invalid socket specified";
- break;
-
- case WSAEISCONN:
- retval = "socket is connected";
- break;
-
- case WSAENETRESET:
- retval = "network reset";
- break;
-
- case WSAEOPNOTSUPP:
- retval = "operation not supported";
- break;
-
- case WSAESHUTDOWN:
- retval = "socket was shutdown";
- break;
-
- case WSAEWOULDBLOCK:
- retval = "socket would block";
- break;
-
- case WSAEMSGSIZE:
- retval = "message too large";
- break;
-
- case WSAETIMEDOUT:
- retval = "timed out";
- break;
-
- case WSAECONNRESET:
- retval = "connection reset";
- break;
-
- case WSAEINTR:
- retval = "call interrupted";
- break;
-
- case WSAEHOSTUNREACH:
- retval = "host unreachable";
- break;
-
- case WSAECONNABORTED:
- retval = "connection aborted";
- break;
-
- case WSAEDESTADDRREQ:
- retval = "destination address required";
- break;
-
- case WSAENETUNREACH:
- retval = "network unreachable";
- break;
-
- case WSASYSNOTREADY:
- retval = "network subsystem not ready";
- break;
-
- case WSAVERNOTSUPPORTED:
- retval = "version not supported";
- break;
-
- case WSAEPROCLIM:
- retval = "process limit reached";
- break;
-
- case WSAHOST_NOT_FOUND:
- retval = "host not found";
- break;
-
- case WSATRY_AGAIN:
- retval = "try again";
- break;
-
- case WSANO_RECOVERY:
- retval = "no recovery";
- break;
-
- case WSANO_DATA:
- retval = "no data";
- break;
-
- default:
- retval = "unknown error code";
- break;
- }
-
- return(retval);
-} // end of TcpConnection::winsock_strerror(int)
-
-#endif
diff --git a/FSM/samples/TrafficLight/Makefile b/FSM/samples/TrafficLight/Makefile
deleted file mode 100644
index 98399affb..000000000
--- a/FSM/samples/TrafficLight/Makefile
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Makefile
-#
-# $Id: //poco/1.4/FSM/samples/TrafficLight/Makefile#1 $
-#
-# Makefile for Poco FSM TrafficLight
-#
-
-include $(POCO_BASE)/build/rules/global
-INCLUDE += -I$(POCO_BASE)/FSM/include
-CXXFLAGS += -std=c++11 -fno-operator-names
-
-# Cygwin Poco*.dll should be on PATH
-ifeq ($(OSNAME), Cygwin)
- PATH :=$(LIBPATH):$(PATH)
-endif
-
-# Where to find the Finite State Machine Compiler executable
-FSMc = $(POCO_BUILD)/FSM/bin/$(OSNAME)/$(OSARCH)/FSMc
-
-objects = stoplight Stoplight_sm TrafficLight
-
-target = TrafficLight
-target_version = 1
-target_libs = PocoUtil PocoJSON PocoNet PocoXML PocoFoundation
-
-include $(POCO_BASE)/build/rules/exec
-
-ifdef POCO_UNBUNDLED
- SYSLIBS += -lz -lpcre -lexpat
-endif
-
-# Rule for runnning Finite State Machine Compiler
-src/%.cpp: src/%.sm
- @echo "** Compiling FSM " $<
- $(SET_LD_LIBRARY_PATH) $(FSMc) $<
diff --git a/FSM/samples/TrafficLight/Stoplight_sm.cpp b/FSM/samples/TrafficLight/Stoplight_sm.cpp
deleted file mode 100644
index 2edfb2efb..000000000
--- a/FSM/samples/TrafficLight/Stoplight_sm.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-#include "stoplightdefs.h"
-#include "stoplight.h"
-#include "Stoplight_sm.h"
-using namespace statemap;
-namespace cpp_ex4 {
- // FSM Map constructor.
- StopMap::StopMap() :
- EastWestGreen("EastWestGreen", 0),
- EastWestYellow("EastWestYellow", 1),
- NorthSouthGreen("NorthSouthGreen", 2),
- NorthSouthYellow("NorthSouthYellow", 3)
- {}
-
- // Class state -----------------------------------
- void StoplightState::Timeout(StoplightContext& context) {
- Default(context);
- }
- void StoplightState::Default(StoplightContext& context) {
- throw TransitionUndefinedException(context.getState().getName(), context.getTransition());
- return;
- }
- void StopMap_EastWestGreen::Entry(StoplightContext& context) {
- Stoplight& ctxt = context.getOwner();
- ctxt.TurnLight(NSLIGHT, RED);
- ctxt.TurnLight(EWLIGHT, GREEN);
- }
-
- // ----------------------------------------------------
- void StopMap_EastWestGreen::Timeout(StoplightContext& context) {
- Stoplight& ctxt = context.getOwner();
-
- (context.getState()).Exit(context);
- context.setState(context.EastWestYellow);
- (context.getState()).Entry(context);
- ctxt.setTimer(Stoplight::YellowTimer);
- return;
- };
- void StopMap_EastWestYellow::Entry(StoplightContext& context) {
- Stoplight& ctxt = context.getOwner();
- ctxt.TurnLight(EWLIGHT, YELLOW);
- }
-
- // ----------------------------------------------------
- void StopMap_EastWestYellow::Timeout(StoplightContext& context) {
- Stoplight& ctxt = context.getOwner();
-
- (context.getState()).Exit(context);
- context.setState(context.NorthSouthGreen);
- (context.getState()).Entry(context);
- ctxt.setTimer(Stoplight::NSGreenTimer);
- return;
- };
- void StopMap_NorthSouthGreen::Entry(StoplightContext& context) {
- Stoplight& ctxt = context.getOwner();
- ctxt.TurnLight(EWLIGHT, RED);
- ctxt.TurnLight(NSLIGHT, GREEN);
- }
-
- // ----------------------------------------------------
- void StopMap_NorthSouthGreen::Timeout(StoplightContext& context) {
- Stoplight& ctxt = context.getOwner();
-
- (context.getState()).Exit(context);
- context.setState(context.NorthSouthYellow);
- (context.getState()).Entry(context);
- ctxt.setTimer(Stoplight::YellowTimer);
- return;
- };
- void StopMap_NorthSouthYellow::Entry(StoplightContext& context) {
- Stoplight& ctxt = context.getOwner();
- ctxt.TurnLight(NSLIGHT, YELLOW);
- }
-
- // ----------------------------------------------------
- void StopMap_NorthSouthYellow::Timeout(StoplightContext& context) {
- Stoplight& ctxt = context.getOwner();
-
- (context.getState()).Exit(context);
- context.setState(context.EastWestGreen);
- (context.getState()).Entry(context);
- ctxt.setTimer(Stoplight::EWGreenTimer);
- return;
- };
-}
diff --git a/FSM/samples/TrafficLight/Stoplight_sm.h b/FSM/samples/TrafficLight/Stoplight_sm.h
deleted file mode 100644
index 8a2d7fe96..000000000
--- a/FSM/samples/TrafficLight/Stoplight_sm.h
+++ /dev/null
@@ -1,126 +0,0 @@
-#ifndef cpp_ex4_Stoplight_sm_H
-#define cpp_ex4_Stoplight_sm_H
-#include "Poco/FSM/statemap.h"
-namespace cpp_ex4 {
- // Forward declarations.--------------------------
- class StopMap;
- class StopMap_EastWestGreen;
- class StopMap_EastWestYellow;
- class StopMap_NorthSouthGreen;
- class StopMap_NorthSouthYellow;
- class StopMap_Default;
- class StoplightState;
- template class StoplightContext;
- class Stoplight;
-
-
- // Class State.-----------------------------------
- class StoplightState : public statemap::State {
- public:
- StoplightState(const char *name, int no) : statemap::State(name, no) {};
-
- virtual void Entry(StoplightContext&) {};
- virtual void Exit(StoplightContext&) {};
-
- virtual void Timeout(StoplightContext& context);
- protected:
- virtual void Default(StoplightContext& context);
- };
-
- // FSM map default state class.-------------------
- class StopMap_Default : public StoplightState {
- public:
- StopMap_Default (const char *name, int stateId) : StoplightState(name, stateId) {}
- };
-
- // FSM map states class.--------------------------
- // --------------------------------------------------
- class StopMap_EastWestGreen: public StopMap_Default {
- public:
- StopMap_EastWestGreen(const char* name, int no) : StopMap_Default(name, no) {}
-
- void Entry(StoplightContext& context);
-
- void Timeout(StoplightContext& context);
- };
-
- // --------------------------------------------------
- class StopMap_EastWestYellow: public StopMap_Default {
- public:
- StopMap_EastWestYellow(const char* name, int no) : StopMap_Default(name, no) {}
-
- void Entry(StoplightContext& context);
-
- void Timeout(StoplightContext& context);
- };
-
- // --------------------------------------------------
- class StopMap_NorthSouthGreen: public StopMap_Default {
- public:
- StopMap_NorthSouthGreen(const char* name, int no) : StopMap_Default(name, no) {}
-
- void Entry(StoplightContext& context);
-
- void Timeout(StoplightContext& context);
- };
-
- // --------------------------------------------------
- class StopMap_NorthSouthYellow: public StopMap_Default {
- public:
- StopMap_NorthSouthYellow(const char* name, int no) : StopMap_Default(name, no) {}
-
- void Entry(StoplightContext& context);
-
- void Timeout(StoplightContext& context);
- };
-
- // FSM map class.---------------------------------
- class StopMap {
- public:
- StopMap();
- StopMap_EastWestGreen EastWestGreen;
- StopMap_EastWestYellow EastWestYellow;
- StopMap_NorthSouthGreen NorthSouthGreen;
- StopMap_NorthSouthYellow NorthSouthYellow;
- };
-
- // FSM context class -----------------------------
- template
- class StoplightContext : public statemap::FSMContext, public StopMap {
- public:
- explicit
- StoplightContext(statemap::Notifier& notifier) : FSMContext(notifier, StopMap::NorthSouthGreen) {};
- StoplightContext(statemap::Notifier& notifier, const statemap::State& state) : FSMContext(notifier, state) {};
-
- void setStartState(const statemap::State& state) {
- setState(state);
- }
-
- virtual void enterStartState() {
- getState().Entry(*this);
- return;
- }
-
- Derived& getOwner() {
- return (*static_cast(this));
- };
-
- const Derived& getOwner() const {
- return (*static_cast(this));
- };
-
- StoplightState& getState() const {
- if (_state == nullptr) {
- throw statemap::StateUndefinedException();
- }
- return (dynamic_cast(*_state));
- };
-
- void Timeout() {
- setTransition("Timeout");
- getState().Timeout(*this);
- setTransition(nullptr);
- };
- };
-}
-#endif
diff --git a/FSM/samples/TrafficLight/TrafficLight.sm b/FSM/samples/TrafficLight/TrafficLight.sm
deleted file mode 100644
index 7d5810662..000000000
--- a/FSM/samples/TrafficLight/TrafficLight.sm
+++ /dev/null
@@ -1,63 +0,0 @@
-// -*- tab-width: 4; -*-
-
-%{
-//
-// The contents of this file are subject to the Mozilla Public
-// License Version 1.1 (the "License"); you may not use this file
-// except in compliance with the License. You may obtain a copy of
-// the License at http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an "AS
-// IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-// implied. See the License for the specific language governing
-// rights and limitations under the License.
-//
-// The Original Code is State Machine Compiler (SMC).
-//
-// The Initial Developer of the Original Code is Charles W. Rapp.
-// Portions created by Charles W. Rapp are
-// Copyright (C) 2000 - 2003 Charles W. Rapp.
-// All Rights Reserved.
-//
-// Contributor(s):
-//
-// State Machine
-// Stoplight
-//
-// Description
-// This state machine implements a US traffic light.
-//
-%}
-%start StopMap::NorthSouthGreen
-%class Stoplight
-%fsmclass StoplightContext
-%include "stoplightdefs.h"
-%header stoplight.h
-%package cpp_ex4
-
-%map StopMap
-%%
-EastWestGreen
- Entry { TurnLight(NSLIGHT, RED); TurnLight(EWLIGHT, GREEN); }
-{
- Timeout EastWestYellow { setTimer(Stoplight::YellowTimer); }
-}
-
-EastWestYellow
- Entry { TurnLight(EWLIGHT, YELLOW); }
-{
- Timeout NorthSouthGreen { setTimer(Stoplight::NSGreenTimer); }
-}
-
-NorthSouthGreen
- Entry { TurnLight(EWLIGHT, RED); TurnLight(NSLIGHT, GREEN); }
-{
- Timeout NorthSouthYellow { setTimer(Stoplight::YellowTimer); }
-}
-
-NorthSouthYellow
- Entry { TurnLight(NSLIGHT, YELLOW); }
-{
- Timeout EastWestGreen { setTimer(Stoplight::EWGreenTimer); }
-}
-%%
diff --git a/FSM/samples/TrafficLight/TrafficLight_vs120.vcxproj b/FSM/samples/TrafficLight/TrafficLight_vs120.vcxproj
deleted file mode 100644
index ca523b230..000000000
--- a/FSM/samples/TrafficLight/TrafficLight_vs120.vcxproj
+++ /dev/null
@@ -1,114 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
-
- {E3EE4584-8403-494A-B982-EFC4E5B04690}
- Win32Proj
- TrafficLight
- TrafficLight
-
-
-
- Application
- true
- v120
- Unicode
-
-
- Application
- false
- v120
- true
- Unicode
-
-
-
-
-
-
-
-
-
-
-
-
- true
- ClCompile
-
-
- false
- $(IncludePath)
- ClCompile
-
-
-
-
-
- Level3
- Disabled
- WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
- ..\..\..\FSM\include;..\..\..\Util\include;..\..\..\Foundation\include
-
-
- Console
- true
- ..\..\..\lib
-
-
- set PATH=..\..\..\bin;%PATH% && ..\..\bin\fsmc TrafficLight.sm
- SpotLight_sm.h;SpotLight_sm.cpp
-
-
-
-
- Level3
-
-
- MaxSpeed
- true
- true
- WIN32;NDEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
- ..\..\..\FSM\include;..\..\..\Util\include;..\..\..\Foundation\include
-
-
- Console
- true
- true
- true
- ..\..\..\lib
-
-
- set PATH=..\..\..\bin;%PATH% && ..\..\bin\fsmc TrafficLight.sm
- SpotLight_sm.h;SpotLight_sm.cpp
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/FSM/samples/TrafficLight/TrafficLight_vs120.vcxproj.filters b/FSM/samples/TrafficLight/TrafficLight_vs120.vcxproj.filters
deleted file mode 100644
index bcd69e9c0..000000000
--- a/FSM/samples/TrafficLight/TrafficLight_vs120.vcxproj.filters
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hh;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
-
-
-
-
- Fichiers sources
-
-
- Fichiers sources
-
-
- Fichiers sources
-
-
- Fichiers sources
-
-
-
-
- Fichiers d%27en-tête
-
-
- Fichiers d%27en-tête
-
-
- Fichiers d%27en-tête
-
-
- Fichiers d%27en-tête
-
-
- Fichiers d%27en-tête
-
-
-
\ No newline at end of file
diff --git a/FSM/samples/TrafficLight/src/Stoplight_sm.cpp b/FSM/samples/TrafficLight/src/Stoplight_sm.cpp
deleted file mode 100644
index 2edfb2efb..000000000
--- a/FSM/samples/TrafficLight/src/Stoplight_sm.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-#include "stoplightdefs.h"
-#include "stoplight.h"
-#include "Stoplight_sm.h"
-using namespace statemap;
-namespace cpp_ex4 {
- // FSM Map constructor.
- StopMap::StopMap() :
- EastWestGreen("EastWestGreen", 0),
- EastWestYellow("EastWestYellow", 1),
- NorthSouthGreen("NorthSouthGreen", 2),
- NorthSouthYellow("NorthSouthYellow", 3)
- {}
-
- // Class state -----------------------------------
- void StoplightState::Timeout(StoplightContext& context) {
- Default(context);
- }
- void StoplightState::Default(StoplightContext& context) {
- throw TransitionUndefinedException(context.getState().getName(), context.getTransition());
- return;
- }
- void StopMap_EastWestGreen::Entry(StoplightContext& context) {
- Stoplight& ctxt = context.getOwner();
- ctxt.TurnLight(NSLIGHT, RED);
- ctxt.TurnLight(EWLIGHT, GREEN);
- }
-
- // ----------------------------------------------------
- void StopMap_EastWestGreen::Timeout(StoplightContext& context) {
- Stoplight& ctxt = context.getOwner();
-
- (context.getState()).Exit(context);
- context.setState(context.EastWestYellow);
- (context.getState()).Entry(context);
- ctxt.setTimer(Stoplight::YellowTimer);
- return;
- };
- void StopMap_EastWestYellow::Entry(StoplightContext& context) {
- Stoplight& ctxt = context.getOwner();
- ctxt.TurnLight(EWLIGHT, YELLOW);
- }
-
- // ----------------------------------------------------
- void StopMap_EastWestYellow::Timeout(StoplightContext& context) {
- Stoplight& ctxt = context.getOwner();
-
- (context.getState()).Exit(context);
- context.setState(context.NorthSouthGreen);
- (context.getState()).Entry(context);
- ctxt.setTimer(Stoplight::NSGreenTimer);
- return;
- };
- void StopMap_NorthSouthGreen::Entry(StoplightContext& context) {
- Stoplight& ctxt = context.getOwner();
- ctxt.TurnLight(EWLIGHT, RED);
- ctxt.TurnLight(NSLIGHT, GREEN);
- }
-
- // ----------------------------------------------------
- void StopMap_NorthSouthGreen::Timeout(StoplightContext& context) {
- Stoplight& ctxt = context.getOwner();
-
- (context.getState()).Exit(context);
- context.setState(context.NorthSouthYellow);
- (context.getState()).Entry(context);
- ctxt.setTimer(Stoplight::YellowTimer);
- return;
- };
- void StopMap_NorthSouthYellow::Entry(StoplightContext& context) {
- Stoplight& ctxt = context.getOwner();
- ctxt.TurnLight(NSLIGHT, YELLOW);
- }
-
- // ----------------------------------------------------
- void StopMap_NorthSouthYellow::Timeout(StoplightContext& context) {
- Stoplight& ctxt = context.getOwner();
-
- (context.getState()).Exit(context);
- context.setState(context.EastWestGreen);
- (context.getState()).Entry(context);
- ctxt.setTimer(Stoplight::EWGreenTimer);
- return;
- };
-}
diff --git a/FSM/samples/TrafficLight/src/TrafficLight.cpp b/FSM/samples/TrafficLight/src/TrafficLight.cpp
deleted file mode 100644
index d809f8252..000000000
--- a/FSM/samples/TrafficLight/src/TrafficLight.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-#include
-#include
-#include
-#include "Poco/DateTime.h"
-#include "Poco/DateTimeFormatter.h"
-#include "Poco/Util/LoggingConfigurator.h"
-#include "Poco/Util/PropertyFileConfiguration.h"
-#include "Poco/Exception.h"
-#include "Poco/Util/Option.h"
-#include "Poco/Util/OptionSet.h"
-#include "Poco/Util/HelpFormatter.h"
-#include "Poco/Util/Application.h"
-#include "Poco/Timer.h"
-#include "Poco/Thread.h"
-#include "Poco/Stopwatch.h"
-
-using Poco::Util::Application;
-using Poco::Util::Option;
-using Poco::Util::OptionSet;
-using Poco::Util::HelpFormatter;
-using Poco::Util::LoggingConfigurator;
-using Poco::Util::PropertyFileConfiguration;
-using Poco::AutoPtr;
-using Poco::TimerCallback;
-using Poco::Stopwatch;
-using Poco::Thread;
-
-using namespace std;
-
-#include "stoplight.h"
-using namespace cpp_ex4;
-
-
-class TrafficLight : public Application {
- /// The main application class.
- ///
- /// This class handles command-line arguments and configuration files.
- /// Start the TrafficLight executable with the help
- /// option (/help on Windows, --help on Unix) for
- /// the available command line options.
- ///
- protected:
- void initialize(Application& self) {
- loadConfiguration(); // load default configuration files, if present
- Application::initialize(self);
- }
-
- void uninitialize() {
- Application::uninitialize();
- }
-
- void defineOptions(OptionSet& options) {
- Application::defineOptions(options);
-
- options.addOption(
- Option("help", "h", "display help information on command line arguments")
- .required(false)
- .repeatable(false));
- }
-
- void handleOption(const std::string& name, const std::string& value) {
- Application::handleOption(name, value);
-
- if (name == "help")
- help = true;
- }
-
- void displayHelp() {
- HelpFormatter helpFormatter(options());
- helpFormatter.setCommand(commandName());
- helpFormatter.setUsage("OPTIONS");
- helpFormatter.setHeader("A US TrafficLight as a FSM.");
- helpFormatter.format(std::cout);
- }
-
- int main(const std::vector& args) {
- if (help) {
- displayHelp();
- } else {
- Stoplight stoplight(NORTH_SOUTH, NSGreenTimer, EWGreenTimer);
- stoplight.start(YellowTimer);
- }
- return Application::EXIT_OK;
- }
- private:
- int KeepGoing = 1;
-
- int YellowTimer = 2; // Yellow lights last 2 seconds.
- int NSGreenTimer = 8; // North-south green lasts 8 seconds.
- int EWGreenTimer = 5; // East-west green lasts 5 seconds.
- bool help = false;
-};
-
-POCO_APP_MAIN(TrafficLight)
diff --git a/FSM/samples/TrafficLight/src/stdafx.cpp b/FSM/samples/TrafficLight/src/stdafx.cpp
deleted file mode 100644
index c494ab227..000000000
--- a/FSM/samples/TrafficLight/src/stdafx.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-// stdafx.cpp : fichier source incluant simplement les fichiers Include standard
-// TrafficLight.pch représente l'en-tête précompilé
-// stdafx.obj contient les informations de type précompilées
-
-#include "stdafx.h"
-
-// TODO: faites référence aux en-têtes supplémentaires nécessaires dans STDAFX.H
-// absents de ce fichier
diff --git a/FSM/samples/TrafficLight/src/stdafx.h b/FSM/samples/TrafficLight/src/stdafx.h
deleted file mode 100644
index 16ac0befb..000000000
--- a/FSM/samples/TrafficLight/src/stdafx.h
+++ /dev/null
@@ -1,15 +0,0 @@
-// stdafx.h : fichier Include pour les fichiers Include système standard,
-// ou les fichiers Include spécifiques aux projets qui sont utilisés fréquemment,
-// et sont rarement modifiés
-//
-
-#pragma once
-
-#include "targetver.h"
-
-#include
-#include
-
-
-
-// TODO: faites référence ici aux en-têtes supplémentaires nécessaires au programme
diff --git a/FSM/samples/TrafficLight/src/stoplight.cpp b/FSM/samples/TrafficLight/src/stoplight.cpp
deleted file mode 100644
index 790c021a8..000000000
--- a/FSM/samples/TrafficLight/src/stoplight.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-//
-// The contents of this file are subject to the Mozilla Public
-// License Version 1.1 (the "License"); you may not use this file
-// except in compliance with the License. You may obtain a copy
-// of the License at http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an
-// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-// implied. See the License for the specific language governing
-// rights and limitations under the License.
-//
-// The Original Code is State Machine Compiler (SMC).
-//
-// The Initial Developer of the Original Code is Charles W. Rapp.
-// Portions created by Charles W. Rapp are
-// Copyright (C) 2000 - 2009. Charles W. Rapp.
-// All Rights Reserved.
-//
-// Contributor(s):
-//
-// Class
-// Stoplight
-//
-// Member Functions
-// Stoplight() - Default constructor.
-// Stoplight(Directions) - Set initial direction.
-// TurnLight(StopLights, LightColors) - Change directions.
-// SetTimer(int) - Start a timer.
-// Initialize(Directions) - Set start state and timer.
-//
-
-#include
-#include "Poco/Thread.h"
-#include "Poco/Stopwatch.h"
-#include "stoplight.h"
-
-static const char tab = '\t';
-
-using namespace std;
-using Poco::TimerCallback;
-using Poco::Stopwatch;
-using Poco::Thread;
-
-namespace cpp_ex4 {
-
-int Stoplight::YellowTimer;
-int Stoplight::NSGreenTimer;
-int Stoplight::EWGreenTimer;
-
-const char* literal(const statemap::Event & event) {
- switch (event) {
- case statemap::Event::Enter: return "Enter ";
- case statemap::Event::Leave: return "Leave ";
- case statemap::Event::Switch: return "Switch ";
- case statemap::Event::Transition: return "Transition";
- case statemap::Event::Push: return "Push ";
- case statemap::Event::Pop: return "Pop ";
- }
-}
-class Print : public statemap::Notifier {
-public:
- void operator ()(const statemap::Event & event, const char * message) {
- clog << tab << tab << literal(event) << ": " << message << endl;
- }
- void operator ()(const statemap::Event & event, const statemap::State * state) {
-// clog << tab << tab << literal(event) << ": " << state->getName() << endl;
- }
- void operator ()(const statemap::Event & event, const statemap::State * fromState, const statemap::State *toState) {
- clog << tab << tab << literal(event) << ": " << fromState->getName() << " => " << toState->getName() << endl << endl;
- }
-};
-static Print print;
-
- Stoplight::Stoplight(Directions direction, int NSGreenTimer, int EWGreenTimer) :
- StoplightContext(print),
- callback(*this, &Stoplight::onTimer) {
-
-#define FSM_DEBUG
-#ifdef FSM_DEBUG
- setDebugFlag(true);
-#endif
- switch(direction) {
- case NORTH_SOUTH:
- cout << "Turning the north-south lights green." << endl;
- setStartState(NorthSouthGreen);
- timer.setStartInterval(NSGreenTimer * 1000);
- break;
-
- case EAST_WEST:
- cout << "Turning the east-west lights green." << endl;
- setStartState(EastWestGreen);
- timer.setStartInterval(EWGreenTimer * 1000);
- break;
- }
- this->NSGreenTimer = NSGreenTimer;
- this->EWGreenTimer = EWGreenTimer;
-}
-
-void Stoplight::start(int YellowTimer) {
- this->YellowTimer = YellowTimer;
- enterStartState();
- timer.start(callback);
-
- Stopwatch sw;
- sw.start();
- _event.wait();
- sw.stop();
- return;
-}
-
-void Stoplight::TurnLight(StopLights light, LightColors color) {
- cout << "Turning the ";
-
- switch(light) {
- case EWLIGHT:
- cout << "east-west lights ";
- break;
-
- case NSLIGHT:
- cout << "north-south lights ";
- break;
- }
-
- switch(color) {
- case GREEN:
- cout << "green." << endl;
- break;
-
- case YELLOW:
- cout << "yellow." << endl;
- break;
-
- case RED:
- cout << "red." << endl;
- break;
- }
-
- return;
-}
-
-void Stoplight::onTimer(Timer& t) {
-// clog << ">>> onTimer: " << endl;
- Timeout();
-// clog << "<<< onTimer: " << endl;
-}
-
-void Stoplight::setTimer(int seconds) {
-// clog << ">>> setTimer: " << seconds << endl;
- timer.setPeriodicInterval(seconds * 1000);
- timer.restart();
-// clog << "<<< setTimer: " << seconds << endl;
-}
-
-}
diff --git a/FSM/samples/TrafficLight/src/stoplight.h b/FSM/samples/TrafficLight/src/stoplight.h
deleted file mode 100644
index fa84cbdfd..000000000
--- a/FSM/samples/TrafficLight/src/stoplight.h
+++ /dev/null
@@ -1,80 +0,0 @@
-#ifndef _H_STOPLIGHT
-#define _H_STOPLIGHT
-
-//
-// The contents of this file are subject to the Mozilla Public
-// License Version 1.1 (the "License"); you may not use this file
-// except in compliance with the License. You may obtain a copy
-// of the License at http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an
-// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-// implied. See the License for the specific language governing
-// rights and limitations under the License.
-//
-// The Original Code is State Machine Compiler (SMC).
-//
-// The Initial Developer of the Original Code is Charles W. Rapp.
-// Portions created by Charles W. Rapp are
-// Copyright (C) 2000 - 2009. Charles W. Rapp.
-// All Rights Reserved.
-//
-// Contributor(s):
-//
-// Name
-// TheContext
-//
-// Description
-// When a state map executes an action, it is really calling a
-// member function in the context class.
-//
-
-#include "Poco/Timer.h"
-#include "Poco/Event.h"
-using Poco::Timer;
-using Poco::Event;
-using Poco::TimerCallback;
-
-#include "stoplightdefs.h"
-#include "stoplight_sm.h"
-
-namespace cpp_ex4 {
- class Stoplight : protected StoplightContext {
- // Member data.
- public:
- static int YellowTimer;
- static int NSGreenTimer;
- static int EWGreenTimer;
-
-protected:
- void onTimer(Timer& t);
-
-private:
- Event _event;
- Timer timer;
- TimerCallback callback;
-
- // Member functions.
-public:
- // Specify the initial direction with the green light.
- Stoplight(Directions direction, int NSGreenTimer, int EWGreenTimer);
-
- // Destructor.
- virtual ~Stoplight() {};
-
- void start(int YellowTimer);
-
- // Change a stoplight's color.
- void TurnLight(StopLights light, LightColors color);
-
- // Set a timer for the specified number of seconds.
- void setTimer(int time);
-
-
- // Sets the initial state of the state map and the initial timer.
- //static Stoplight* Initialize(Directions direction);
-
-
- };
-}
-#endif
diff --git a/FSM/samples/TrafficLight/src/stoplight_sm.h b/FSM/samples/TrafficLight/src/stoplight_sm.h
deleted file mode 100644
index 8a2d7fe96..000000000
--- a/FSM/samples/TrafficLight/src/stoplight_sm.h
+++ /dev/null
@@ -1,126 +0,0 @@
-#ifndef cpp_ex4_Stoplight_sm_H
-#define cpp_ex4_Stoplight_sm_H
-#include "Poco/FSM/statemap.h"
-namespace cpp_ex4 {
- // Forward declarations.--------------------------
- class StopMap;
- class StopMap_EastWestGreen;
- class StopMap_EastWestYellow;
- class StopMap_NorthSouthGreen;
- class StopMap_NorthSouthYellow;
- class StopMap_Default;
- class StoplightState;
- template class StoplightContext;
- class Stoplight;
-
-
- // Class State.-----------------------------------
- class StoplightState : public statemap::State {
- public:
- StoplightState(const char *name, int no) : statemap::State(name, no) {};
-
- virtual void Entry(StoplightContext&) {};
- virtual void Exit(StoplightContext&) {};
-
- virtual void Timeout(StoplightContext& context);
- protected:
- virtual void Default(StoplightContext& context);
- };
-
- // FSM map default state class.-------------------
- class StopMap_Default : public StoplightState {
- public:
- StopMap_Default (const char *name, int stateId) : StoplightState(name, stateId) {}
- };
-
- // FSM map states class.--------------------------
- // --------------------------------------------------
- class StopMap_EastWestGreen: public StopMap_Default {
- public:
- StopMap_EastWestGreen(const char* name, int no) : StopMap_Default(name, no) {}
-
- void Entry(StoplightContext& context);
-
- void Timeout(StoplightContext& context);
- };
-
- // --------------------------------------------------
- class StopMap_EastWestYellow: public StopMap_Default {
- public:
- StopMap_EastWestYellow(const char* name, int no) : StopMap_Default(name, no) {}
-
- void Entry(StoplightContext& context);
-
- void Timeout(StoplightContext& context);
- };
-
- // --------------------------------------------------
- class StopMap_NorthSouthGreen: public StopMap_Default {
- public:
- StopMap_NorthSouthGreen(const char* name, int no) : StopMap_Default(name, no) {}
-
- void Entry(StoplightContext& context);
-
- void Timeout(StoplightContext& context);
- };
-
- // --------------------------------------------------
- class StopMap_NorthSouthYellow: public StopMap_Default {
- public:
- StopMap_NorthSouthYellow(const char* name, int no) : StopMap_Default(name, no) {}
-
- void Entry(StoplightContext& context);
-
- void Timeout(StoplightContext& context);
- };
-
- // FSM map class.---------------------------------
- class StopMap {
- public:
- StopMap();
- StopMap_EastWestGreen EastWestGreen;
- StopMap_EastWestYellow EastWestYellow;
- StopMap_NorthSouthGreen NorthSouthGreen;
- StopMap_NorthSouthYellow NorthSouthYellow;
- };
-
- // FSM context class -----------------------------
- template
- class StoplightContext : public statemap::FSMContext, public StopMap {
- public:
- explicit
- StoplightContext(statemap::Notifier& notifier) : FSMContext(notifier, StopMap::NorthSouthGreen) {};
- StoplightContext(statemap::Notifier& notifier, const statemap::State& state) : FSMContext(notifier, state) {};
-
- void setStartState(const statemap::State& state) {
- setState(state);
- }
-
- virtual void enterStartState() {
- getState().Entry(*this);
- return;
- }
-
- Derived& getOwner() {
- return (*static_cast(this));
- };
-
- const Derived& getOwner() const {
- return (*static_cast(this));
- };
-
- StoplightState& getState() const {
- if (_state == nullptr) {
- throw statemap::StateUndefinedException();
- }
- return (dynamic_cast(*_state));
- };
-
- void Timeout() {
- setTransition("Timeout");
- getState().Timeout(*this);
- setTransition(nullptr);
- };
- };
-}
-#endif
diff --git a/FSM/samples/TrafficLight/src/stoplightdefs.h b/FSM/samples/TrafficLight/src/stoplightdefs.h
deleted file mode 100644
index fa8f3a9ea..000000000
--- a/FSM/samples/TrafficLight/src/stoplightdefs.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef _H_STOPLIGHTDEFS
-#define _H_STOPLIGHTDEFS
-
-//
-// The contents of this file are subject to the Mozilla Public
-// License Version 1.1 (the "License"); you may not use this file
-// except in compliance with the License. You may obtain a copy of
-// the License at http://www.mozilla.org/MPL/
-//
-// Software distributed under the License is distributed on an "AS
-// IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-// implied. See the License for the specific language governing
-// rights and limitations under the License.
-//
-// The Original Code is State Machine Compiler (SMC).
-//
-// The Initial Developer of the Original Code is Charles W. Rapp.
-// Portions created by Charles W. Rapp are
-// Copyright (C) 2000 - 2003 Charles W. Rapp.
-// All Rights Reserved.
-//
-// Contributor(s):
-//
-// Name
-// TheContext
-//
-// Description
-// When a state machine executes an action, it is really calling a
-// member function in the context class.
-//
-
-#ifdef WIN32
-// Use this value when setting the stoplight timer.
-#define STOPLIGHT_TIMER 1
-#endif
-
-namespace cpp_ex4 {
-enum LightColors {
- GREEN = 0,
- YELLOW,
- RED
-};
-
-enum StopLights {
- EWLIGHT = 1,
- NSLIGHT
-};
-
-enum Directions {
- NORTH_SOUTH,
- EAST_WEST
-};
-}
-
-#endif
diff --git a/FSM/samples/TrafficLight/src/targetver.h b/FSM/samples/TrafficLight/src/targetver.h
deleted file mode 100644
index c8351ffde..000000000
--- a/FSM/samples/TrafficLight/src/targetver.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#pragma once
-
-// Si vous incluez SDKDDKVer.h, cela définit la dernière plateforme Windows disponible.
-
-// Si vous souhaitez générer votre application pour une plateforme Windows précédente, incluez WinSDKVer.h et
-// définissez la macro _WIN32_WINNT à la plateforme que vous souhaitez prendre en charge avant d'inclure SDKDDKVer.h.
-
-#include
diff --git a/FSM/samples/samples_vs120.sln b/FSM/samples/samples_vs120.sln
deleted file mode 100644
index 771f00ea2..000000000
--- a/FSM/samples/samples_vs120.sln
+++ /dev/null
@@ -1,28 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Express 2013 for Windows Desktop
-VisualStudioVersion = 12.0.40629.0
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TrafficLight", "TrafficLight\TrafficLight_vs120.vcxproj", "{E3EE4584-8403-494A-B982-EFC4E5B04690}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TCP", "TCP\TCP_vs120.vcxproj", "{11E01C5F-683C-4290-B520-D3D248327DE1}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {E3EE4584-8403-494A-B982-EFC4E5B04690}.Debug|Win32.ActiveCfg = Debug|Win32
- {E3EE4584-8403-494A-B982-EFC4E5B04690}.Debug|Win32.Build.0 = Debug|Win32
- {E3EE4584-8403-494A-B982-EFC4E5B04690}.Release|Win32.ActiveCfg = Release|Win32
- {E3EE4584-8403-494A-B982-EFC4E5B04690}.Release|Win32.Build.0 = Release|Win32
- {11E01C5F-683C-4290-B520-D3D248327DE1}.Debug|Win32.ActiveCfg = Debug|Win32
- {11E01C5F-683C-4290-B520-D3D248327DE1}.Debug|Win32.Build.0 = Debug|Win32
- {11E01C5F-683C-4290-B520-D3D248327DE1}.Release|Win32.ActiveCfg = Release|Win32
- {11E01C5F-683C-4290-B520-D3D248327DE1}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/FSM/src/Action.cpp b/FSM/src/Action.cpp
deleted file mode 100644
index 4e647cbb6..000000000
--- a/FSM/src/Action.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Action.cpp
- *
- * Created on: 16 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "model/Action.h"
-#include "model/Argument.h"
-#include "model/Print.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace MODEL
-{
-const string Action::display() const
-{
- if (oneline.empty())
- {
- oneline += name();
- oneline += '(';
- string arguments;
-
- for (int no = 0; no < _arguments.size(); ++no)
- {
- arguments += _arguments[no]->name();
- if (no + 1 < _arguments.size())
- arguments += ", ";
- }
- oneline += arguments;
- oneline += ')';
- oneline += ';';
- }
- return oneline;
-}
-void Action::print(Print& print) const
-{
- print(display());
-}
-}
-}
-}
diff --git a/FSM/src/ActionForCpp.cpp b/FSM/src/ActionForCpp.cpp
deleted file mode 100644
index 9925b4a2b..000000000
--- a/FSM/src/ActionForCpp.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * ActionForCpp.cpp
- *
- * Created on: 19 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include
-using std::replace;
-
-#include "cpp/ActionForCpp.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-namespace CPP
-{
-const string ActionForCpp::name() const
-{
- string cppname = Element::name();
- replace(cppname.begin(), cppname.end(), '-', '_');
- return cppname;
-}
-void ActionForCpp::generateInclude(ostream& inc, bool debug) const
-{
-}
-void ActionForCpp::generateCode(ostream& cpp, bool debug) const
-{
-}
-}
-}
-}
-}
diff --git a/FSM/src/Actions.cpp b/FSM/src/Actions.cpp
deleted file mode 100644
index d47348be2..000000000
--- a/FSM/src/Actions.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Actions.cpp
- *
- * Created on: 26 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "model/Actions.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace MODEL
-{
-
-}
-}
-}
diff --git a/FSM/src/Argument.cpp b/FSM/src/Argument.cpp
deleted file mode 100644
index 70aea07f2..000000000
--- a/FSM/src/Argument.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Argument.cpp
- *
- * Created on: 21 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "model/Argument.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace MODEL
-{
-const string Argument::display() const
-{
- if (oneline.empty())
- {
- oneline += name();
- }
- return oneline;
-}
-
-}
-}
-}
diff --git a/FSM/src/ArgumentForCpp.cpp b/FSM/src/ArgumentForCpp.cpp
deleted file mode 100644
index 00afc51b3..000000000
--- a/FSM/src/ArgumentForCpp.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * ArgumentForCpp.cpp
- *
- * Created on: 21 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "cpp/ArgumentForCpp.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-namespace CPP
-{
-void ArgumentForCpp::generateInclude(ostream& inc, bool debug) const
-{
-}
-void ArgumentForCpp::generateCode(ostream& cpp, bool debug) const
-{
-}
-
-}
-}
-}
-}
diff --git a/FSM/src/BinaryOperation.cpp b/FSM/src/BinaryOperation.cpp
deleted file mode 100644
index 597073e2a..000000000
--- a/FSM/src/BinaryOperation.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * BinaryOperation.cpp
- *
- * Created on: 20 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "model/BinaryOperation.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace MODEL
-{
-const string BinaryOperation::display() const
-{
- if (_asstring.empty())
- {
- _asstring += _left->display();
- switch (_operator)
- {
- case Operator::equal:
- _asstring += "==";
- break;
- case Operator::notequal:
- _asstring += "!=";
- break;
- case Operator::and:
- _asstring += "&&";
- break;
- case Operator::or:
- _asstring += "||";
- break;
- case Operator::xor:
- _asstring += '^';
- break;
- default:
- _asstring += "???";
- break;
- }
- _asstring += _right->display();
- }
- return _asstring;
-}
-}
-}
-}
\ No newline at end of file
diff --git a/FSM/src/BinaryOperationForCpp.cpp b/FSM/src/BinaryOperationForCpp.cpp
deleted file mode 100644
index e90f6a864..000000000
--- a/FSM/src/BinaryOperationForCpp.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * BinaryOperationForCpp.cpp
- *
- * Created on: 24 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "cpp/BinaryOperationForCpp.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-namespace CPP
-{
-const string BinaryOperationForCpp::display(const string& prefix) const
-{
- string value;
- value += dynamic_cast(left())->display(prefix);
- switch (_operator)
- {
- case Poco::FSM::MODEL::Operator::equal:
- value += "==";
- break;
- case Poco::FSM::MODEL::Operator::notequal:
- value += "!=";
- break;
- case Poco::FSM::MODEL::Operator::and:
- value += "&&";
- break;
- case Poco::FSM::MODEL::Operator::or:
- value += "||";
- break;
- case Poco::FSM::MODEL::Operator::xor:
- value += '^';
- break;
- default:
- value += "???";
- break;
- }
- value += dynamic_cast(right())->display(prefix);
- return value;
-}
-
-}
-}
-}
-}
diff --git a/FSM/src/Character.cpp b/FSM/src/Character.cpp
deleted file mode 100644
index 6e5e4ab0d..000000000
--- a/FSM/src/Character.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Character.cpp
- *
- * Created on: 3 août 2014
- * Author: FrancisANDRE
- */
-
-#include "Poco/StreamTokenizer.h"
-#include "Poco/Exception.h"
-#include "Poco/Ascii.h"
-#include "parser/Character.h"
-
-using Poco::StreamTokenizer;
-using Poco::SyntaxException;
-using Poco::Token;
-using Poco::InvalidToken;
-using Poco::EOFToken;
-using Poco::WhitespaceToken;
-using Poco::Ascii;
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-
-Character::Character()
-{
-}
-
-
-Character::~Character()
-{
-}
-
-
-Token::Class Character::tokenClass() const
-{
- return Token::CHAR_LITERAL_TOKEN;
-}
-
-
-bool Character::start(char c, std::istream& istr)
-{
- _value = c;
- return c == '\'';
-}
-
-
-void Character::finish(std::istream& istr)
-{
- int next = istr.peek();
- while (next != -1 && next != '\'' && next != '\n' && next != '\r')
- {
- if (next == '\\') _value += (char) istr.get();
- _value += (char) istr.get();
- next = istr.peek();
- }
- if (next == '\'')
- {
- next = istr.get();
- _value += (char) next;
- }
- else throw SyntaxException("Unterminated character literal");
-}
-
-
-char Character::asChar() const
-{
- char result('\0');
- std::string::const_iterator it = _value.begin();
- std::string::const_iterator end = _value.end();
- if (it != end)
- {
- if (*it == '\'') ++it;
- while (it != end && *it != '\'')
- {
- if (*it == '\\') ++it;
- if (it != end) result = *it++;
- }
- }
- return result;
-}
-
-
-}
-}
-}
diff --git a/FSM/src/Comment.cpp b/FSM/src/Comment.cpp
deleted file mode 100644
index ec03ec5ee..000000000
--- a/FSM/src/Comment.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Comment.cpp
- *
- * Created on: 3 août 2014
- * Author: FrancisANDRE
- */
-
-#include "Poco/Ascii.h"
-#include "Poco/StreamTokenizer.h"
-using Poco::StreamTokenizer;
-using Poco::Token;
-using Poco::InvalidToken;
-using Poco::EOFToken;
-using Poco::WhitespaceToken;
-using Poco::Ascii;
-#include "parser/Comment.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-
-Comment::Comment()
-{
-}
-
-
-Comment::~Comment()
-{
-}
-
-
-Token::Class Comment::tokenClass() const
-{
- return (_value.length() > 2 && _value[2] == '/') ? Token::SPECIAL_COMMENT_TOKEN : Token::COMMENT_TOKEN;
-}
-
-
-bool Comment::start(char c, std::istream& istr)
-{
- _value = c;
- int next = istr.peek();
- return c == '/' && (next == '*' || next == '/');
-}
-
-
-void Comment::finish(std::istream& istr)
-{
- int next = istr.peek();
- if (next == '/')
- {
- while (next != -1 && next != '\r' && next != '\n')
- {
- _value += (char) istr.get();
- next = istr.peek();
- }
- }
- else
- {
- _value += (char) istr.get(); // *
- next = istr.peek();
- while (next != -1)
- {
- next = istr.get();
- _value += (char) next;
- if (next == '*' && istr.peek() == '/')
- {
- _value += (char) istr.get();
- break;
- }
- }
- }
-}
-
-
-std::string Comment::asString() const
-{
- if (_value.length() > 2 && _value[2] == '/')
- return _value.substr(3);
- else
- return _value.substr(2);
-}
-
-
-}
-}
-}
diff --git a/FSM/src/CompilableForCpp.cpp b/FSM/src/CompilableForCpp.cpp
deleted file mode 100644
index 9bd9ebc99..000000000
--- a/FSM/src/CompilableForCpp.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * CompilableForCpp.cpp
- *
- * Created on: 24 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "cpp/CompilableForCpp.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-namespace CPP
-{
-
-}
-}
-}
-}
diff --git a/FSM/src/Dumper.cpp b/FSM/src/Dumper.cpp
deleted file mode 100644
index 0ab483eb4..000000000
--- a/FSM/src/Dumper.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Dumper.cpp
- *
- * Created on: 8 févr. 2016
- * Author: FrancisANDRE
- */
-
-#include "model/Dumper.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace MODEL
-{
-
-}
-}
-}
diff --git a/FSM/src/Element.cpp b/FSM/src/Element.cpp
deleted file mode 100644
index d81a0203d..000000000
--- a/FSM/src/Element.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Element.cpp
- *
- * Created on: 16 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "model/Element.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace MODEL
-{
-
-}
-}
-}
\ No newline at end of file
diff --git a/FSM/src/ElementForCpp.cpp b/FSM/src/ElementForCpp.cpp
deleted file mode 100644
index 1996cd284..000000000
--- a/FSM/src/ElementForCpp.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * ElementForCpp.cpp
- *
- * Created on: 2 févr. 2016
- * Author: FrancisANDRE
- */
-
-#include "cpp/ElementForCpp.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-namespace CPP
-{
-
-}
-}
-}
-}
diff --git a/FSM/src/Entry.cpp b/FSM/src/Entry.cpp
deleted file mode 100644
index a3c31f082..000000000
--- a/FSM/src/Entry.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Entry.cpp
- *
- * Created on: 26 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "model/Print.h"
-#include "model/Entry.h"
-#include "model/Action.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace MODEL
-{
-const string Entry::display() const
-{
- if (oneline.empty())
- {
- oneline += Element::name();
- }
- return oneline;
-}
-void Entry::print(Print& print) const
-{
- string line;
- line += "Entry\t{";
-
- for (const auto& action : actions())
- line += action->display();
-
- line += '}';
- print(line);
-}
-}
-}
-}
diff --git a/FSM/src/EntryForCpp.cpp b/FSM/src/EntryForCpp.cpp
deleted file mode 100644
index 2c2b175a7..000000000
--- a/FSM/src/EntryForCpp.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * EntryForCpp.cpp
- *
- * Created on: 26 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "cpp/EntryForCpp.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-namespace CPP
-{
-void EntryForCpp::generateInclude(ostream& inc, bool debug) const
-{
-}
-void EntryForCpp::generateCode(ostream& cpp, bool debug) const
-{
-}
-}
-}
-}
-}
diff --git a/FSM/src/Exit.cpp b/FSM/src/Exit.cpp
deleted file mode 100644
index 7b82f4bf8..000000000
--- a/FSM/src/Exit.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Exit.cpp
- *
- * Created on: 26 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "model/Exit.h"
-#include "model/Action.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace MODEL
-{
-const string Exit::display() const
-{
- if (oneline.empty())
- {
- oneline += name();
- }
- return oneline;
-}
-void Exit::print(Print& print) const
-{
- string line;
- line += "Exit\t{";
-
- for (const auto& action : actions())
- line += action->display();
-
- line += '}';
- print(line);
-}
-}
-}
-}
diff --git a/FSM/src/ExitForCpp.cpp b/FSM/src/ExitForCpp.cpp
deleted file mode 100644
index 3425e41ee..000000000
--- a/FSM/src/ExitForCpp.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * ExitForCpp.cpp
- *
- * Created on: 26 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "cpp/ExitForCpp.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-namespace CPP
-{
-void ExitForCpp::generateInclude(ostream& inc, bool debug) const
-{
-}
-void ExitForCpp::generateCode(ostream& cpp, bool debug) const
-{
-}
-}
-}
-}
-}
diff --git a/FSM/src/Expression.cpp b/FSM/src/Expression.cpp
deleted file mode 100644
index 46aa0755a..000000000
--- a/FSM/src/Expression.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Expression.cpp
- *
- * Created on: 21 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "model/Expression.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace MODEL
-{
-
-}
-}
-}
\ No newline at end of file
diff --git a/FSM/src/ExpressionForCpp.cpp b/FSM/src/ExpressionForCpp.cpp
deleted file mode 100644
index 8cd05594b..000000000
--- a/FSM/src/ExpressionForCpp.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * ExpressionForCpp.cpp
- *
- * Created on: 24 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "cpp/ExpressionForCpp.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-namespace CPP
-{
-
-}
-}
-}
-}
diff --git a/FSM/src/FSM.cpp b/FSM/src/FSM.cpp
deleted file mode 100644
index edcd3fff1..000000000
--- a/FSM/src/FSM.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * FSM.cpp
- *
- * Created on: 16 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "Poco/Format.h"
-using Poco::format;
-
-#include "parser/Keyword.h"
-#include "model/FSM.h"
-#include "model/Map.h"
-using Poco::FSM::PARSER::Keyword;
-
-namespace Poco
-{
-namespace FSM
-{
-namespace MODEL
-{
-void FSM::add(MapPtr map)
-{
- _maps.push_back(map);
- map->fsm() = this;
-}
-void FSM::addPackage(const string& package)
-{
- _packages.push_back(package);
-}
-void FSM::addImport(const string& import)
-{
- _imports.push_back(import);
-}
-void FSM::addInclude(const string& inc)
-{
- _includes.push_back(inc);
-}
-void FSM::addDeclare(const string& declare)
-{
- _declares.push_back(declare);
-}
-void FSM::print(Print& print) const
-{
- print(format("%s\t%s", string(Keyword::asString(Keyword::START)), startState()));
- print(format("%s\t%s", string(Keyword::asString(Keyword::FSMFILE)), fsmfile()));
- print(format("%s\t%s", string(Keyword::asString(Keyword::FFSMLASS)), fsmclass()));
- print(format("%s\t%s", string(Keyword::asString(Keyword::CLASS)), klass()));
-// print(format("%s\t%s", string(Keyword::asString(Keyword::DECLARE)), declare()));
-// print(format("%s\t%s", string(Keyword::asString(Keyword::ACCESS)), access()));
- print(format("%s\t%s", string(Keyword::asString(Keyword::HEADER)), header()));
- print(format("%s\t%s", string(Keyword::asString(Keyword::PACKAGE)), packages()[0]));
-
- for (const auto& map : maps())
- {
- print(format("%s\t%s", string(Keyword::asString(Keyword::MAP)), map->Element::name()));
- map->print(print);
- }
-}
-}
-}
-}
diff --git a/FSM/src/FSMForCpp.cpp b/FSM/src/FSMForCpp.cpp
deleted file mode 100644
index e97ea58b5..000000000
--- a/FSM/src/FSMForCpp.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * FSMForCpp.cpp
- *
- * Created on: 19 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include
-#include "Poco/Timestamp.h"
-#include "Poco/File.h"
-#include "Poco/FileStream.h"
-using Poco::FileInputStream;
-using Poco::FileOutputStream;
-using Poco::File;
-using Poco::Timestamp;
-
-#include "cpp/FSMForCpp.h"
-#include "cpp/MapForCpp.h"
-#include "parser/Parser.h"
-
-using namespace std;
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-namespace CPP
-{
-void FSMForCpp::openNamespaces(IndentStream& os) const
-{
- for (const auto& package : packages())
- if (!package.empty())
- os << "namespace " << package << " {" << endl << tab;
-}
-void FSMForCpp::closeNamespaces(IndentStream& os) const
-{
- for (const auto& package : packages())
- if (!package.empty())
- os << back << '}' << endl;
-}
-void FSMForCpp::generate(const Path& out, bool debug) const
-{
- {
- Path incPath(out, fsmfile() + ".h");
- FileOutputStream incfos(incPath.toString());
- IndentStream inc(incfos);
- string define;
- for (const auto& ns : packages())
- {
- define += ns;
- define += "_";
- }
- define += fsmfile();
- inc << "#ifndef " << define << "_H" << endl;
- inc << "#define " << define << "_H" << endl;
-
- inc << "#include \"Poco/FSM/statemap.h\"" << endl;
-
- openNamespaces(inc);
-
- for (auto map : _maps)
- {
- dynamic_cast(map)->generateInclude(inc, debug);
- }
- closeNamespaces(inc);
- inc << "#endif" << endl;
- }
- {
- Path cppPath(out, fsmfile() + ".cpp");
- FileOutputStream cppfos(cppPath.toString());
- IndentStream cpp(cppfos);
-
- for (const auto& include : includes())
- if (!include.empty())
- cpp << "#include \"" << include << "\"" << endl;
-
- if (!header().empty())
- cpp << "#include \"" << header() << "\"" << endl;
-
- cpp << "#include \"" << fsmfile() << ".h\"" << endl;
-
- cpp << "using namespace statemap;" << endl;
-
- openNamespaces(cpp);
- for (const auto& map : _maps)
- {
- dynamic_cast(map)->generateCode(cpp, debug);
- }
- closeNamespaces(cpp);
- }
-}
-bool FSMForCpp::updated(const Path& out)
-{
- Path incPath(out, fsmfile() + ".h");
- File incFile(incPath);
- if (incFile.exists())
- {
- Timestamp incFilets = incFile.getLastModified();
- Timestamp fsmfilets = parser()->file().getLastModified();
- if (incFilets > fsmfilets)
- return true;
- }
-
- return false;
-}
-
-}
-}
-}
-}
diff --git a/FSM/src/FactoryForCpp.cpp b/FSM/src/FactoryForCpp.cpp
deleted file mode 100644
index 46d9fb9ac..000000000
--- a/FSM/src/FactoryForCpp.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * FactoryForCpp.cpp
- *
- * Created on: 20 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "cpp/FactoryForCpp.h"
-#include "cpp/ActionForCpp.h"
-#include "cpp/FSMForCpp.h"
-#include "cpp/GuardForCpp.h"
-#include "cpp/MapForCpp.h"
-#include "cpp/ParameterForCpp.h"
-#include "cpp/StateForCpp.h"
-#include "cpp/EntryForCpp.h"
-#include "cpp/ExitForCpp.h"
-#include "cpp/TransitionForCpp.h"
-#include "cpp/ReferenceForCpp.h"
-#include "cpp/VariableForCpp.h"
-#include "cpp/FunctionForCpp.h"
-#include "cpp/LiteralForCpp.h"
-#include "cpp/ArgumentForCpp.h"
-#include "cpp/UnaryOperationForCpp.h"
-#include "cpp/BinaryOperationForCpp.h"
-
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-namespace CPP
-{
-ActionPtr FactoryForCpp::newAction(const string& name, int lineno) const
-{
- return new ActionForCpp(name, lineno);
-}
-FSMPtr FactoryForCpp::newFSM(Parser* parser) const
-{
- return new FSMForCpp(parser);
-}
-GuardPtr FactoryForCpp::newGuard(const string& name, int lineno) const
-{
- return new GuardForCpp(name, lineno);
-}
-MapPtr FactoryForCpp::newMap(const string& name, int lineno) const
-{
- return new MapForCpp(name, lineno);
-}
-ParameterPtr FactoryForCpp::newParameter(const string& name, int lineno) const
-{
- return new ParameterForCpp(name, lineno);
-}
-StatePtr FactoryForCpp::newState(const string& name, int lineno) const
-{
- return new StateForCpp(name, lineno);
-}
-EntryPtr FactoryForCpp::newEntry(const string& name, int lineno) const
-{
- return new EntryForCpp(name, lineno);
-}
-ExitPtr FactoryForCpp::newExit(const string& name, int lineno) const
-{
- return new ExitForCpp(name, lineno);
-}
-TransitionPtr FactoryForCpp::newTransition(const string& name, int lineno) const
-{
- return new TransitionForCpp(name, lineno);
-}
-ReferencePtr FactoryForCpp::newReference(const VariablePtr variable, int lineno) const
-{
- return new ReferenceForCpp(variable, lineno);
-}
-ReferencePtr FactoryForCpp::newReference(const FunctionPtr function, int lineno) const
-{
- return new ReferenceForCpp(function, lineno);
-}
-ReferencePtr FactoryForCpp::newReference(const LiteralPtr literal, int lineno) const
-{
- return new ReferenceForCpp(literal, lineno);
-}
-VariablePtr FactoryForCpp::newVariable(const string& name, int lineno) const
-{
- return new VariableForCpp(name, lineno);
-}
-FunctionPtr FactoryForCpp::newFunction(const string& name, int lineno) const
-{
- return new FunctionForCpp(name, lineno);
-}
-LiteralPtr FactoryForCpp::newLiteral(const string& name, int lineno) const
-{
- return new LiteralForCpp(name, lineno);
-}
-ArgumentPtr FactoryForCpp::newArgument(const string& name, int lineno) const
-{
- return new ArgumentForCpp(name, lineno);
-}
-UnaryOperationPtr FactoryForCpp::newUnaryOperation(Poco::FSM::MODEL::Operator op) const
-{
- return new UnaryOperationForCpp(op);
-}
-BinaryOperationPtr FactoryForCpp::newBinaryOperation(Poco::FSM::MODEL::Operator op) const
-{
- return new BinaryOperationForCpp(op);
-}
-
-}
-}
-}
-}
\ No newline at end of file
diff --git a/FSM/src/Function.cpp b/FSM/src/Function.cpp
deleted file mode 100644
index 62d35ca4f..000000000
--- a/FSM/src/Function.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Function.cpp
- *
- * Created on: 21 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "model/Function.h"
-#include "model/Argument.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace MODEL
-{
-const string Function::display() const
-{
- if (oneline.empty())
- {
- oneline += name();
- oneline += '(';
- string arguments;
-
- for (int no = 0; no < _arguments.size(); ++no)
- {
- arguments += _arguments[no]->name();
- if (no + 1 < _arguments.size())
- arguments += ", ";
- }
- oneline += arguments;
- oneline += ')';
- }
- return oneline;
-}
-
-}
-}
-}
\ No newline at end of file
diff --git a/FSM/src/FunctionForCpp.cpp b/FSM/src/FunctionForCpp.cpp
deleted file mode 100644
index aeaf79003..000000000
--- a/FSM/src/FunctionForCpp.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * FunctionForCpp.cpp
- *
- * Created on: 21 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "cpp/FunctionForCpp.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-namespace CPP
-{
-const string FunctionForCpp::display(const string& prefix) const
-{
- return prefix + Function::display();
-}
-}
-}
-}
-}
diff --git a/FSM/src/Guard.cpp b/FSM/src/Guard.cpp
deleted file mode 100644
index 41360e7ec..000000000
--- a/FSM/src/Guard.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Guard.cpp
- *
- * Created on: 16 janv. 2016
- * Author: FrancisANDRE
- */
-#include
-using std::max;
-
-
-#include "model/Guard.h"
-#include "model/Action.h"
-#include "model/State.h"
-#include "model/Expression.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace MODEL
-{
-const string Guard::display() const
-{
- if (oneline.empty())
- {
- string guards;
- if (_condition != nullptr)
- {
- guards += '[';
- guards += _condition->display();
- guards += ']';
- }
- guards.resize(max(guards.size(), (size_t)40), ' ');
- oneline += guards;
-
- string end = "nil";
- if (endstate())
- end = endstate()->name();
- end.resize(max(end.size(), (size_t)10), ' ');
-
- oneline += end;
-
- string actions;
- actions += '{';
- for (auto action : _actions)
- {
- actions += action->display();
- }
- actions += '}';
-
- oneline += actions;
- }
- return oneline;
-}
-}
-}
-}
\ No newline at end of file
diff --git a/FSM/src/GuardForCpp.cpp b/FSM/src/GuardForCpp.cpp
deleted file mode 100644
index 26bd758dc..000000000
--- a/FSM/src/GuardForCpp.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * GuardForCpp.cpp
- *
- * Created on: 19 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "cpp/GuardForCpp.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-namespace CPP
-{
-void GuardForCpp::generateInclude(ostream& inc, bool debug) const
-{
-}
-void GuardForCpp::generateCode(ostream& cpp, bool debug) const
-{
-}
-}
-}
-}
-}
\ No newline at end of file
diff --git a/FSM/src/Identifier.cpp b/FSM/src/Identifier.cpp
deleted file mode 100644
index 8377aac85..000000000
--- a/FSM/src/Identifier.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Identifier.cpp
- *
- * Created on: 3 août 2014
- * Author: FrancisANDRE
- */
-
-#include "Poco/Ascii.h"
-#include "Poco/StreamTokenizer.h"
-using Poco::StreamTokenizer;
-using Poco::Token;
-using Poco::InvalidToken;
-using Poco::EOFToken;
-using Poco::WhitespaceToken;
-using Poco::Ascii;
-#include "parser/Identifier.h"
-
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-Token::Class
-Identifier::tokenClass() const
-{
- return Token::IDENTIFIER_TOKEN;
-}
-bool
-Identifier::start(char c, std::istream& istr)
-{
- if (c != -1 && Ascii::isAlpha(c))
- {
- _value = c;
- return true;
- }
- else
- return false;
-}
-void
-Identifier::finish(std::istream& istr)
-{
- int c = istr.peek();
- while (c != -1 && (Ascii::isAlphaNumeric(c) || Ascii::isDigit(c) || c == '_') || c == '-')
- {
- istr.get();
- _value += c;
- c = istr.peek();
- }
-}
-
-}
-}
-}
diff --git a/FSM/src/IndentStream.cpp b/FSM/src/IndentStream.cpp
deleted file mode 100644
index 5cfc2ad09..000000000
--- a/FSM/src/IndentStream.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-#include "parser/IndentStream.h"
-
-std::ostream& tab(std::ostream& stream)
-{
- IndentStream* pIndentStream = dynamic_cast(&stream);
- if (pIndentStream != nullptr)
- {
- pIndentStream->ib.tab();
- }
- return stream;
-}
-
-std::ostream& back(std::ostream& stream)
-{
- IndentStream* pIndentStream = dynamic_cast(&stream);
- if (pIndentStream != nullptr)
- {
- pIndentStream->ib.back();
- }
- return stream;
-}
-
diff --git a/FSM/src/Keyword.cpp b/FSM/src/Keyword.cpp
deleted file mode 100644
index 7988459c0..000000000
--- a/FSM/src/Keyword.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Keyword.cpp
- *
- * Created on: 3 août 2014
- * Author: FrancisANDRE
- */
-
-#include "Poco/Token.h"
-#include "Poco/Ascii.h"
-using Poco::InvalidToken;
-using Poco::EOFToken;
-using Poco::WhitespaceToken;
-using Poco::Ascii;
-
-#include "parser/Keyword.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-Keyword::Keyword()
-{
- _opMap["%start"] = START; // %start
- _opMap["%class"] = CLASS; // %class
- _opMap["%fsmclass"] = FFSMLASS, // %fsmclass
- _opMap["%fsmfile"] = FSMFILE, // %fsmfile
- _opMap["%header"] = HEADER; // %header
- _opMap["%include"] = INCLUDE; // %include
- _opMap["%package"] = PACKAGE; // %package
- _opMap["%import"] = IMPORT; // %import
- _opMap["%declare"] = DECLARE; // %declare
- _opMap["%access"] = ACCESS; // %access
- _opMap["%map"] = MAP; // %map
- _opMap["%return"] = RETURN; // %return
-}
-Keyword::~Keyword()
-{
-
-}
-
-Token::Class Keyword::tokenClass() const
-{
- return Token::KEYWORD_TOKEN;
-}
-bool Keyword::start(char c, std::istream& istr)
-{
- if (c != -1 && c == '%')
- {
- char next = istr.peek();
- if (islower(next))
- {
- _value = c;
- return true;
- }
- }
- return false;
-}
-void Keyword::finish(std::istream& istr)
-{
- int c = istr.peek();
- while (c != -1 && (Ascii::isLower(c)))
- {
- istr.get();
- _value += c;
- c = istr.peek();
- }
-}
-int Keyword::asInteger() const
-{
- OpMap::const_iterator it = _opMap.find(_value);
- if (it != _opMap.end())
- return it->second;
- else
- return 0;
-}
-const char* Keyword::asString(int kwno)
-{
- switch (kwno)
- {
- case START:
- return "%start";
- case CLASS:
- return "%class";
- case FSMFILE:
- return "%fsmfile";
- case FFSMLASS:
- return "%fsmclass";
- case HEADER:
- return "%header";
- case INCLUDE:
- return "%include";
- case PACKAGE:
- return "%package";
- case IMPORT:
- return "%import";
- case DECLARE:
- return "%declare";
- case ACCESS:
- return "%access";
- case MAP:
- return "%map";
- default:
- return "???";
- }
-}
-
-}
-}
-}
diff --git a/FSM/src/Literal.cpp b/FSM/src/Literal.cpp
deleted file mode 100644
index 1bc22ec77..000000000
--- a/FSM/src/Literal.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Literal.cpp
- *
- * Created on: 21 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "model/Literal.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace MODEL
-{
-const string Literal::display() const
-{
- return name();
-}
-const string Literal::display(const string& prefix) const
-{
- return display();
-}
-}
-}
-}
diff --git a/FSM/src/LiteralForCpp.cpp b/FSM/src/LiteralForCpp.cpp
deleted file mode 100644
index b8288502c..000000000
--- a/FSM/src/LiteralForCpp.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * LiteralForCpp.cpp
- *
- * Created on: 21 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "cpp/LiteralForCpp.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-namespace CPP
-{
-}
-}
-}
-}
diff --git a/FSM/src/Map.cpp b/FSM/src/Map.cpp
deleted file mode 100644
index e1e53f225..000000000
--- a/FSM/src/Map.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Map.cpp
- *
- * Created on: 16 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "model/Map.h"
-#include "model/Transition.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace MODEL
-{
-void Map::add(TransitionPtr transition)
-{
- if (transition->name() != "Default")
- _transitions[transition->signature()] = transition;
-}
-
-void Map::add(StatePtr state)
-{
- _states[state->name()] = state;
- state->map() = this;
-}
-
-StatePtr Map::lookfor(const string& state) const
-{
- StatePtr result = nullptr;
- try
- {
- result = _states.at(state);
- }
- catch (const std::out_of_range&)
- {
- }
- return result;
-}
-void Map::print(Print& print) const
-{
- for (const auto& state : states())
- {
- state.second->print(print);
- }
-}
-const string Map::display() const
-{
- if (oneline.empty())
- {
-
- }
- return oneline;
-}
-}
-}
-}
\ No newline at end of file
diff --git a/FSM/src/MapForCpp.cpp b/FSM/src/MapForCpp.cpp
deleted file mode 100644
index fb43f6018..000000000
--- a/FSM/src/MapForCpp.cpp
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * MapForCpp.cpp
- *
- * Created on: 19 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include
-#include "parser/IndentStream.h"
-#include "model/Parameter.h"
-#include "cpp/MapForCpp.h"
-#include "cpp/StateForCpp.h"
-#include "cpp/FSMForCpp.h"
-#include "cpp/TransitionForCpp.h"
-
-using Poco::FSM::MODEL::Parameter;
-using Poco::FSM::MODEL::StatePtr;
-
-using namespace std;
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-namespace CPP
-{
-
-string MapForCpp::defaultStateName() const
-{
- return name() + '_' + defaultState()->name();
-}
-
-string MapForCpp::startStateName() const
-{
- return fsm()->startState();
-}
-
-static const int LL = 50;
-
-void MapForCpp::generateInclude(ostream& inc, bool debug) const
-{
- string comment;
- {
- comment = "// Forward declarations.";
- comment.resize(LL, '-');
- inc << comment << endl;
- inc << "class " << name() << ";" << endl;
-
- for (const auto& state : states())
- {
- dynamic_cast(state.second)->generateForwarDeclaration(inc, debug);
- }
-
- inc << "class " << defaultStateName() << ";" << endl;
- inc << "class " << fsm()->klass() << "State;" << endl;
- inc << "template class " << fsm()->fsmclass() << ";" << endl;
- inc << "class " << fsm()->klass() << ";" << endl;
- inc << endl;
- inc << endl;
- }
-
- {
- comment = "// Class State.";
- comment.resize(LL, '-');
- inc << comment << endl;
- inc << "class " << fsm()->klass() << "State : public statemap::State {" << endl;
- inc << "public:" << endl << tab;
-
- inc << fsm()->klass() << "State(const char *name, int no) : statemap::State(name, no) {};" << endl;
- inc << endl;
- inc << "virtual void Entry(" << fsm()->context() << "&) {};" << endl;
- inc << "virtual void Exit(" << fsm()->context() << "&) {};" << endl;
- inc << endl;
-
-#if 0
- for (const auto& state : states())
- {
- StateForCpp* sfc = dynamic_cast(state.second);
- sfc->generateVirtualTransitions(inc);
- }
-#else
- for (const auto& transition : transitions())
- if (transition.second)
- {
- Parameter context("context");
- context.type() = fsm()->context() + '&';
- TransitionForCpp* tfc = static_cast(transition.second);
- inc << "virtual void " << tfc->declaration(&context) << ";" << endl;
- }
-
-#endif
- inc << back << "protected:" << endl << tab;
- inc << "virtual void Default(" << fsm()->context() << "& context);" << endl << back;
- inc << "};" << endl;
- inc << endl;
- }
-
- {
- comment = "// FSM map default state class.";
- comment.resize(LL, '-');
- inc << comment << endl;
- inc << "class " << defaultStateName() << " : public " << fsm()->klass() << "State {" << endl;
- inc << "public:" << endl << tab;
- inc << defaultStateName() << " (const char *name, int stateId) : " << fsm()->klass() << "State(name, stateId) {}" << endl;
- inc << back << "};";
- inc << endl;
- inc << endl;
-
- comment = "// FSM map states class.";
- comment.resize(LL, '-');
- inc << comment << endl;
- for (const auto& state : states())
- {
- StateForCpp* sfc = dynamic_cast(state.second);
- sfc->generateDefinition(inc, debug);
- }
- }
-
-
- {
- comment = "// FSM map class.";
- comment.resize(LL, '-');
- inc << comment << endl;
- inc << "class " << name() << " {" << endl;
- inc << "public:" << endl << tab;
- inc << name() << "();" << endl;
- for (const auto& state : states())
- {
- const StatePtr sp = state.second;
- inc << name() + '_' + sp->name() << ' ' << sp->name() << ";" << endl;
- }
- inc << back << "};" << endl;
- inc << endl;
- }
-
- {
- comment = "// FSM context class ";
- comment.resize(LL, '-');
- inc << comment << endl;
-
- inc << "template" << endl;
- inc << "class " << fsm()->fsmclass() << " : public statemap::FSMContext, public " << name() << " {" << endl;
- inc << "public:" << endl << tab;
-
- inc << "explicit " << endl;
- inc << fsm()->fsmclass() << "(statemap::Notifier& notifier) : FSMContext(notifier, " << startStateName() << ") {};" << endl;
- inc << fsm()->fsmclass() << "(statemap::Notifier& notifier, const statemap::State& state) : FSMContext(notifier, state) {};" << endl;
- inc << endl;
-
- inc << "void setStartState(const statemap::State& state) {" << endl;
- inc << " setState(state);" << endl;
- inc << "}" << endl;
- inc << endl;
-
- inc << "virtual void enterStartState() {" << endl;
- inc << " getState().Entry(*this);" << endl;
- inc << " return;" << endl;
- inc << "}" << endl;
- inc << endl;
-
- inc << "Derived& getOwner() {" << endl;
- inc << " return (*static_cast(this));" << endl;
- inc << "};" << endl;
- inc << endl;
-
- inc << "const Derived& getOwner() const {" << endl;
- inc << " return (*static_cast(this));" << endl;
- inc << "};" << endl;
- inc << endl;
-
- inc << fsm()->klass() << "State& getState() const {" << endl;
- inc << " if (_state == nullptr) {" << endl;
- inc << " throw statemap::StateUndefinedException();" << endl;
- inc << " }" << endl;
- inc << " return (dynamic_cast<" << fsm()->klass() << "State&>(*_state));" << endl;
- inc << "};" << endl;
- inc << endl;
-
- for (const auto& transition : transitions())
- if (transition.second)
- {
- TransitionForCpp* tfc = static_cast(transition.second);
- if (fsm()->returnt().empty())
- inc << "void ";
- else
- inc << fsm()->returnt() + " ";
-
- inc << tfc->declaration() << " {" << endl;
- inc << " setTransition(\"" << tfc->Transition::name() << "\");" << endl;
- inc << " getState()." << tfc->call("*this") << ";" << endl;
- inc << " setTransition(nullptr);" << endl;
- inc << "};" << endl;
- }
- inc << back;
- inc << "};" << endl;
-
- }
-}
-void MapForCpp::generateCode(ostream& cpp, bool debug) const
-{
- string comment;
- cpp << "// FSM Map constructor." << endl;
- cpp << name() << "::" << name() << "() :" << endl << tab;
- int no = 0;
- for (const auto& state : states())
- {
- StateForCpp* sfc = dynamic_cast(state.second);
- sfc->generateDeclaration(cpp, no++);
- if (no < states().size())
- cpp << ",";
- cpp << endl;
- }
- cpp << back << "{}" << endl;
-
- cpp << endl;
- comment = "// Class state ";
- comment.resize(LL, '-');
- cpp << comment << endl;
- for (const auto& transition : transitions())
- if (transition.second)
- {
- Parameter context("context");
- context.type() = fsm()->context() + '&';
- TransitionForCpp* tfc = static_cast(transition.second);
- if (fsm()->returnt().empty())
- cpp << "void ";
- else
- cpp << fsm()->returnt() + " ";
-
- cpp << fsm()->klass() << "State::" << tfc->declaration(&context) << " {" << endl;
- cpp << " Default(context);" << endl;
- cpp << "}" << endl;
- }
-
- cpp << "void " << fsm()->klass() << "State::Default(" << fsm()->context() << "& context) {" << endl;
- cpp << " throw TransitionUndefinedException(context.getState().getName(), context.getTransition());" << endl;
- cpp << " return;" << endl;
- cpp << "}" << endl;
-
-
- for (const auto& state : states())
- {
- StateForCpp* sfc = dynamic_cast(state.second);
- sfc->generateCode(cpp, debug);
- }
-}
-}
-}
-}
-}
\ No newline at end of file
diff --git a/FSM/src/Number.cpp b/FSM/src/Number.cpp
deleted file mode 100644
index 532b211e6..000000000
--- a/FSM/src/Number.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Number.cpp
- *
- * Created on: 3 août 2014
- * Author: FrancisANDRE
- */
-
-#include "Poco/Token.h"
-#include "Poco/Ascii.h"
-using Poco::InvalidToken;
-using Poco::EOFToken;
-using Poco::WhitespaceToken;
-using Poco::Ascii;
-#include "parser/Number.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-Token::Class Number::tokenClass() const
-{
- return Token::INTEGER_LITERAL_TOKEN;
-}
-bool Number::start(char c, std::istream& istr)
-{
- if (c != -1 && Ascii::isDigit(c))
- {
- _value = c;
- return true;
- }
- else
- return false;
-}
-void Number::finish(std::istream& istr)
-{
- int c = istr.peek();
- while (c != -1 && Ascii::isDigit(c))
- {
- istr.get();
- _value += c;
- c = istr.peek();
- }
-}
-
-}
-}
-}
diff --git a/FSM/src/Operation.cpp b/FSM/src/Operation.cpp
deleted file mode 100644
index dfdfee883..000000000
--- a/FSM/src/Operation.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Operation.cpp
- *
- * Created on: 20 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "model/Operation.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace MODEL
-{
-
-Operation::Operation(Operator op) :_operator(op)
-{
-}
-Operation:: ~Operation()
-{
-}
-void Operation::setNoContextuel()
-{
- if (_operator == Operator::equal || _operator == Operator::notequal)
- {
- _contextuel = false;
- }
-}
-}
-}
-}
\ No newline at end of file
diff --git a/FSM/src/Operator.cpp b/FSM/src/Operator.cpp
deleted file mode 100644
index ea2e7e8be..000000000
--- a/FSM/src/Operator.cpp
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * Operator.cpp
- *
- * Created on: 3 août 2014
- * Author: FrancisANDRE
- */
-
-#include "Poco/Ascii.h"
-
-#include "Poco/StreamTokenizer.h"
-using Poco::StreamTokenizer;
-using Poco::Token;
-using Poco::InvalidToken;
-using Poco::EOFToken;
-using Poco::WhitespaceToken;
-using Poco::Ascii;
-
-#include "parser/Operator.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-Operator::Operator()
-{
- _opMap["["] = OP::OPENBRACKET;
- _opMap["]"] = OP::CLOSBRACKET;
- _opMap["("] = OP::OPENPARENT;
- _opMap[")"] = OP::CLOSPARENT;
- _opMap["{"] = OP::OPENBRACE;
- _opMap["}"] = OP::CLOSBRACE;
- _opMap["<"] = OP::LT;
- _opMap["<="] = OP::LE;
- _opMap["<<"] = OP::SHL;
- _opMap["<<="] = OP::SHL_ASSIGN;
- _opMap[">"] = OP::GT;
- _opMap[">="] = OP::GE;
- _opMap[">>"] = OP::SHR;
- _opMap[">>="] = OP::SHR_ASSIGN;
- _opMap["="] = OP::ASSIGN;
- _opMap["=="] = OP::EQ;
- _opMap["!"] = OP::NOT;
- _opMap["!="] = OP::NE;
- _opMap["&"] = OP::BITAND;
- _opMap["&="] = OP::BITAND_ASSIGN;
- _opMap["&&"] = OP::AND;
- _opMap["|"] = OP::BITOR;
- _opMap["|="] = OP::BITOR_ASSIGN;
- _opMap["||"] = OP::OR;
- _opMap["^"] = OP::XOR;
- _opMap["^="] = OP::XOR_ASSIGN;
- _opMap["~"] = OP::COMPL;
- _opMap["*"] = OP::STAR;
- _opMap["*="] = OP::STAR_ASSIGN;
- _opMap["/"] = OP::SLASH;
- _opMap["/="] = OP::SLASH_ASSIGN;
- _opMap["+"] = OP::PLUS;
- _opMap["+="] = OP::PLUS_ASSIGN;
- _opMap["++"] = OP::INCR;
- _opMap["-"] = OP::MINUS;
- _opMap["-="] = OP::MINUS_ASSIGN;
- _opMap["--"] = OP::DECR;
- _opMap["->"] = OP::ARROW;
- _opMap["%"] = OP::MOD;
- _opMap["%="] = OP::MOD_ASSIGN;
- _opMap[","] = OP::COMMA;
- _opMap["."] = OP::PERIOD;
- _opMap["..."] = OP::ELLIPSIS;
- _opMap[":"] = OP::COLON;
- _opMap["::"] = OP::DBL_COLON;
- _opMap[";"] = OP::SEMICOLON;
- _opMap["?"] = OP::QUESTION;
- _opMap["%{"] = OP::OPENCODE;
- _opMap["%}"] = OP::CLOSCODE;
- _opMap["%%"] = OP::FSM;
-}
-
-
-Operator::~Operator()
-{
-}
-
-
-Token::Class Operator::tokenClass() const
-{
- return Token::OPERATOR_TOKEN;
-}
-
-
-bool Operator::start(char c, std::istream& istr)
-{
- _value = c;
- char next = (char) istr.peek();
- switch (_value[0])
- {
- case '[':
- case ']':
- case '(':
- case ')':
- case '{':
- case '}':
- case '<':
- case '>':
- case '=':
- case '!':
- case '&':
- case '|':
- case '*':
- case '+':
- case '-':
- case '^':
- case '~':
- case ',':
- case ':':
- case ';':
- case '%':
- case '?':
- return true;
- case '.':
- return !(next >= '0' && next <= '9');
- case '/':
- return !(next == '/' || next == '*');
- default:
- return false;
- }
-}
-
-
-void Operator::finish(std::istream& istr)
-{
- int next = (char) istr.peek();
- switch (_value[0])
- {
- case '(':
- case ')':
- case '{':
- case '}':
- case '[':
- case ']':
- case ';':
- case '?':
- case '~':
- case ',':
- break;
- case '.':
- if (next == '.')
- {
- _value += (char) istr.get();
- if (istr.peek() != '.') syntaxError(".", std::string(1, (char)istr.peek()));
- _value += (char) istr.get();
- }
- break;
- case ':':
- if (next == ':') _value += (char) istr.get();
- break;
- case '<':
- if (next == '<')
- {
- _value += (char) istr.get();
- next = (char) istr.peek();
- }
- if (next == '=') _value += (char) istr.get();
- break;
- case '>':
- if (next == '>')
- {
- _value += (char) istr.get();
- next = (char) istr.peek();
- }
- if (next == '=') _value += (char) istr.get();
- break;
- case '&':
- if (next == '&' || next == '=') _value += (char) istr.get();
- break;
- case '|':
- if (next == '|' || next == '=') _value += (char) istr.get();
- break;
- case '+':
- if (next == '+' || next == '=') _value += (char) istr.get();
- break;
- case '-':
- if (next == '-' || next == '=' || next == '>') _value += (char) istr.get();
- break;
- case '=':
- case '!':
- case '*':
- case '/':
- case '^':
- case '%':
- if (next == '=' || next == '{' || next == '}' || next == '%') _value += (char) istr.get();
- break;
- default:
- poco_bugcheck();
- }
-}
-
-
-int Operator::asInteger() const
-{
- OpMap::const_iterator it = _opMap.find(_value);
- if (it != _opMap.end())
- return it->second;
- else
- return 0;
-}
-
-
-}
-}
-}
diff --git a/FSM/src/Parameter.cpp b/FSM/src/Parameter.cpp
deleted file mode 100644
index 4c8c9b483..000000000
--- a/FSM/src/Parameter.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Parameter.cpp
- *
- * Created on: 16 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "model/Parameter.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace MODEL
-{
-const string Parameter::display() const
-{
- if (oneline.empty())
- {
- oneline += name();
- oneline += ':';
- oneline += _type;
- }
- return oneline;
-}
-}
-}
-}
\ No newline at end of file
diff --git a/FSM/src/ParameterForCpp.cpp b/FSM/src/ParameterForCpp.cpp
deleted file mode 100644
index a29a0d65d..000000000
--- a/FSM/src/ParameterForCpp.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * ParameterForCpp.cpp
- *
- * Created on: 19 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include
-#include "cpp/ParameterForCpp.h"
-using namespace std;
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-namespace CPP
-{
-void ParameterForCpp::generateInclude(ostream& inc, bool debug) const
-{
- inc << type() << ' ' << name();
-}
-void ParameterForCpp::generateCode(ostream& cpp, bool debug) const
-{
- cpp << type() << ' ' << name();
-}
-}
-}
-}
-}
\ No newline at end of file
diff --git a/FSM/src/Parser.cpp b/FSM/src/Parser.cpp
deleted file mode 100644
index bcc6c39c8..000000000
--- a/FSM/src/Parser.cpp
+++ /dev/null
@@ -1,1021 +0,0 @@
-/*
- * Parser.cpp
- *
- * Created on: 16 janv. 2016
- * Author: FrancisANDRE
- */
-#include
-#include
-#include
-#include
-#include
-
-#include "Poco/Bugcheck.h"
-#include "Poco/NumberFormatter.h"
-#include "Poco/StreamTokenizer.h"
-#include "Poco/Path.h"
-#include "Poco/File.h"
-#include "Poco/Ascii.h"
-
-#include "Poco/String.h"
-
-using Poco::Bugcheck;
-using Poco::NumberFormatter;
-using Poco::StreamTokenizer;
-using Poco::SyntaxException;
-using Poco::InvalidToken;
-using Poco::EOFToken;
-using Poco::WhitespaceToken;
-using Poco::Path;
-using Poco::File;
-using Poco::Ascii;
-
-#include "parser/Parser.h"
-#include "parser/Identifier.h"
-#include "parser/Number.h"
-#include "parser/Keyword.h"
-#include "parser/Comment.h"
-#include "parser/Character.h"
-#include "parser/Operator.h"
-#include "parser/String.h"
-
-#include "model/Action.h"
-#include "model/FSM.h"
-#include "model/Guard.h"
-#include "model/Map.h"
-#include "model/Parameter.h"
-#include "model/State.h"
-#include "model/Entry.h"
-#include "model/Exit.h"
-#include "model/Transition.h"
-#include "model/Expression.h"
-#include "model/Transition.h"
-#include "model/Reference.h"
-#include "model/Variable.h"
-#include "model/Function.h"
-#include "model/Literal.h"
-#include "model/Reference.h"
-#include "model/Argument.h"
-#include "model/UnaryOperation.h"
-#include "model/BinaryOperation.h"
-
-#include "model/Factory.h"
-#include "cpp/FactoryForCpp.h"
-
-using namespace std;
-
-using Poco::FSM::MODEL::Action;
-using Poco::FSM::MODEL::FSM;
-using Poco::FSM::MODEL::Guard;
-using Poco::FSM::MODEL::Map;
-using Poco::FSM::MODEL::Parameter;
-using Poco::FSM::MODEL::State;
-using Poco::FSM::MODEL::Transition;
-using Poco::FSM::MODEL::ActionPtr;
-using Poco::FSM::MODEL::FSMPtr;
-using Poco::FSM::MODEL::GuardPtr;
-using Poco::FSM::MODEL::MapPtr;
-using Poco::FSM::MODEL::ParameterPtr;
-using Poco::FSM::MODEL::StatePtr;
-using Poco::FSM::MODEL::TransitionPtr;
-using Poco::FSM::MODEL::FunctionPtr;
-using Poco::FSM::MODEL::VariablePtr;
-using Poco::FSM::MODEL::LiteralPtr;
-using Poco::FSM::MODEL::ExpressionPtr;
-using Poco::FSM::MODEL::ArgumentPtr;
-using Poco::FSM::MODEL::UnaryOperation;
-using Poco::FSM::MODEL::BinaryOperation;
-
-static const char TAB = '\t';
-
-static const Poco::FSM::MODEL::Factory& factory = Poco::FSM::PARSER::CPP::FactoryForCpp();
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-
-Parser::Parser(Logger& logger, const File& file, istream& istr) :
- _logger(logger),
- _istr(istr),
- _tokenizer(_istr),
- _file(file)
-{
-}
-Parser:: ~Parser()
-{
-}
-
-FSMPtr Parser::parse(const Path& out)
-{
- try
- {
- fsm = factory.newFSM(this);
- const Poco::Token* next = nextToken();
- next = parseFile(next, out);
- if (next && !isEOF(next))
- syntaxError("Additional tokens behind supposed EOF");
- }
- catch (SyntaxException& exc)
- {
- string m(exc.message());
- string where(_currentPath);
- where.append("(");
- where.append(NumberFormatter::format(_istr.getCurrentLineNumber()));
- where.append(")");
- throw SyntaxException(m, where);
- }
- return fsm;
-}
-inline bool Parser::isString(const Poco::Token* token)
-{
- return token->is(Token::STRING_LITERAL_TOKEN);
-}
-inline bool Parser::isCharacter(const Poco::Token* token)
-{
- return token->is(Token::CHAR_LITERAL_TOKEN);
-}
-inline bool Parser::isNumber(const Poco::Token* token)
-{
- return token->is(Token::INTEGER_LITERAL_TOKEN) || token->is(Token::LONG_INTEGER_LITERAL_TOKEN);
-}
-
-inline bool Parser::isIdentifier(const Poco::Token* token)
-{
- return token->is(Token::IDENTIFIER_TOKEN) || isOperator(token, Operator::DBL_COLON);
-}
-
-
-inline bool Parser::isOperator(const Poco::Token* token)
-{
- return token->is(Token::OPERATOR_TOKEN);
-}
-
-inline bool Parser::isOperator(const Poco::Token* token, int kind)
-{
- return token->is(Token::OPERATOR_TOKEN) && token->asInteger() == kind;
-}
-
-
-inline bool Parser::isKeyword(const Poco::Token* token, int kind)
-{
- return token->is(Token::KEYWORD_TOKEN) && token->asInteger() == kind;
-}
-
-
-inline bool Parser::isEOF(const Poco::Token* token)
-{
- return token->is(Token::EOF_TOKEN);
-}
-const char* classToString(Token::Class klass)
-{
- switch (klass)
- {
- case Token::IDENTIFIER_TOKEN:
- return "IDENTIFIER";
- case Token::KEYWORD_TOKEN:
- return "KEYWORD";
- case Token::SEPARATOR_TOKEN:
- return "SEPARATOR";
- case Token::OPERATOR_TOKEN:
- return "OPERATOR";
- case Token::STRING_LITERAL_TOKEN:
- return "STRING_LITERAL";
- case Token::CHAR_LITERAL_TOKEN:
- return "CHAR_LITERAL";
- case Token::INTEGER_LITERAL_TOKEN:
- return "INTEGER_LITERAL";
- case Token::LONG_INTEGER_LITERAL_TOKEN:
- return "LONG_INTEGER_LITERAL";
- case Token::FLOAT_LITERAL_TOKEN:
- return "FLOAT_LITERAL";
- case Token::DOUBLE_LITERAL_TOKEN:
- return "DOUBLE_LITERAL";
- case Token::COMMENT_TOKEN:
- return "COMMENT";
- case Token::SPECIAL_COMMENT_TOKEN:
- return "SPECIAL_COMMENT";
- case Token::PREPROCESSOR_TOKEN:
- return "PREPROCESSOR";
- case Token::WHITESPACE_TOKEN:
- return "WHITESPACE";
- case Token::EOF_TOKEN:
- return "EOF";
- case Token::INVALID_TOKEN:
- return "INVALID";
- case Token::USER_TOKEN:
- return "USER";
- }
- return "???";
-}
-
-const Poco::Token* Parser::parseFile(const Poco::Token* next, const Path& out)
-{
- while (next->is(Token::KEYWORD_TOKEN) || next->is(Token::OPERATOR_TOKEN))
- {
- if (next->is(Token::KEYWORD_TOKEN))
- switch (next->asInteger())
- {
- case Keyword::START: // %start
- next = parseStart(next);
- break;
- case Keyword::CLASS: // %class
- next = parseClass(next);
- break;
- case Keyword::FSMFILE: // %fsmfile
- next = parseFSMFile(next);
- break;
- case Keyword::FFSMLASS: // %fsmclass
- next = parseFFSMlass(next);
- break;
- case Keyword::HEADER: // %header
- next = parseHeader(next);
- break;
- case Keyword::INCLUDE: // %include
- next = parseIncludes(next);
- break;
- case Keyword::PACKAGE: // %package
- next = parsePackage(next);
- break;
- case Keyword::IMPORT: // %import
- next = parseImport(next);
- break;
- case Keyword::DECLARE: // %declare
- next = parseDeclare(next);
- break;
- case Keyword::ACCESS: // %access
- next = parseAccess(next);
- break;
- case Keyword::MAP: // %map
- if (fsm->fsmfile().empty())
- fsm->fsmfile() = fsm->klass() + "_sm";
- fsm->setcontext();
-
- if (fsm->updated(out))
- {
- fsm->updated() = true;
- return nullptr;
- }
-
- next = parseMap(next);
- break;
- case Keyword::RETURN: // %return
- next = parseReturn(next);
- break;
- default:
- poco_bugcheck();
- break;
- }
- else if (next->is(Token::OPERATOR_TOKEN))
- switch (next->asInteger())
- {
- case Operator::OPENCODE: // %{
- next = parseRawCode(next);
- break;
- default:
- poco_bugcheck();
- }
- }
- return next;
-}
-const Poco::Token* Parser::parseSource(const Poco::Token* next)
-{
- return next;
-}
-const Poco::Token* Parser::parseReturn(const Poco::Token* next)
-{
- poco_assert(isKeyword(next, Keyword::RETURN));
- const string rcclass = next->tokenString();
- next = nextToken();
- if (next->is(Token::IDENTIFIER_TOKEN))
- {
- string klass = next->tokenString();
- fsm->returnt() = klass;
- next = nextToken();
- }
- return next;
-}
-const Poco::Token* Parser::parseStart(const Poco::Token* next)
-{
- poco_assert(isKeyword(next, Keyword::START));
- const string keyword = next->tokenString();
-
- next = nextToken();
- if (next->is(Token::IDENTIFIER_TOKEN))
- {
- string startstate = next->tokenString();
- next = nextToken();
- if (isOperator(next, Operator::DBL_COLON))
- {
- startstate += next->tokenString();
- next = nextToken();
- if (next->is(Token::IDENTIFIER_TOKEN))
- {
- startstate += next->tokenString();
- next = nextToken();
- }
- }
- fsm->startState() = startstate;
-
- }
- return next;
-}
-const Poco::Token* Parser::parseClass(const Poco::Token* next)
-{
- poco_assert(isKeyword(next, Keyword::CLASS));
- const string pcclass = next->tokenString();
- next = nextToken();
- if (next->is(Token::IDENTIFIER_TOKEN))
- {
- string klass = next->tokenString();
- fsm->klass() = klass;
- next = nextToken();
- }
- return next;
-}
-const Poco::Token* Parser::parseFSMFile(const Poco::Token* next)
-{
- poco_assert(isKeyword(next, Keyword::FSMFILE));
- next = nextToken();
- if (next->is(Token::IDENTIFIER_TOKEN))
- {
- string fsmfile = next->tokenString();
- fsm->fsmfile() = fsmfile;
- next = nextToken();
- }
- return next;
-}
-const Poco::Token* Parser::parseFFSMlass(const Poco::Token* next)
-{
- poco_assert(isKeyword(next, Keyword::FFSMLASS));
- next = nextToken();
- if (next->is(Token::IDENTIFIER_TOKEN))
- {
- string fsmclass = next->tokenString();
- fsm->fsmclass() = fsmclass;
- next = nextToken();
- }
- return next;
-}
-const Poco::Token* Parser::parseHeader(const Poco::Token* next)
-{
- poco_assert(isKeyword(next, Keyword::HEADER));
- const string pcheader = next->tokenString();
- next = nextToken();
- string file;
- do
- {
- file += next->tokenString();
- next = nextToken();
- }
- while (!next->is(Token::KEYWORD_TOKEN));
- fsm->header() = file;
- return next;
-}
-const Poco::Token* Parser::parseIncludes(const Poco::Token* next)
-{
- poco_assert(isKeyword(next, Keyword::INCLUDE));
- next = nextToken();
- for (;;)
- {
- next = parseInclude(next);
- if (isOperator(next, Operator::COMMA))
- next = nextToken();
- else
- break;
- }
- return next;
-}
-const Poco::Token* Parser::parseInclude(const Poco::Token* next)
-{
- if (next->is(Token::STRING_LITERAL_TOKEN))
- {
- string file = next->tokenString().substr(1); // remove begin "
- file = file.substr(0, file.size() - 1); // remove ending "
- fsm->includes().push_back(file);
- next = nextToken();
- }
- else if (next->is(Token::IDENTIFIER_TOKEN))
- {
- string file = next->tokenString();
- next = nextToken();
- if (isOperator(next, Operator::PERIOD))
- {
- file += '.';
- next = nextToken();
- if (next->is(Token::IDENTIFIER_TOKEN))
- {
- file += next->tokenString();
- fsm->includes().push_back(file);
- next = nextToken();
- }
- }
- }
- return next;
-}
-const Poco::Token* Parser::parsePackage(const Poco::Token* next)
-{
- poco_assert(isKeyword(next, Keyword::PACKAGE));
- const string pcpackage = next->tokenString();
- next = nextToken();
- string packages;
- do
- {
- if (next->is(Token::IDENTIFIER_TOKEN))
- {
- string package = next->tokenString();
- fsm->addPackage(package);
- packages += package;
- next = nextToken();
- if (isOperator(next, Operator::DBL_COLON))
- {
- packages += next->tokenString();
- next = nextToken();
- }
- }
- }
- while (!next->is(Token::KEYWORD_TOKEN));
- return next;
-}
-const Poco::Token* Parser::parseImport(const Poco::Token* next)
-{
- poco_assert(isKeyword(next, Keyword::IMPORT));
- const string pcimport = next->tokenString();
- next = nextToken();
- if (next->is(Token::IDENTIFIER_TOKEN))
- {
- string import = next->tokenString();
- next = nextToken();
- }
- return next;
-}
-const Poco::Token* Parser::parseDeclare(const Poco::Token* next)
-{
- poco_assert(isKeyword(next, Keyword::DECLARE));
- const string pcdeclare = next->tokenString();
- next = nextToken();
- if (next->is(Token::IDENTIFIER_TOKEN))
- {
- string declare = next->tokenString();
- next = nextToken();
- }
- return next;
-}
-const Poco::Token* Parser::parseAccess(const Poco::Token* next)
-{
- poco_assert(isKeyword(next, Keyword::ACCESS));
- const Poco::Token* token = next;
- next = nextToken();
- if (next->is(Token::IDENTIFIER_TOKEN))
- {
- string access = next->tokenString();
- next = nextToken();
- }
- return next;
-}
-const Poco::Token* Parser::parseMap(const Poco::Token* next)
-{
- poco_assert(isKeyword(next, Keyword::MAP));
- next = nextToken();
- if (next->is(Token::IDENTIFIER_TOKEN))
- {
- map = factory.newMap(next->tokenString());
- fsm->add(map);
- next = nextToken();
- next = parseStates(next);
- if (map->defaultState() == nullptr)
- map->defaultState() = factory.newState("Default");
- }
- return next;
-}
-const Poco::Token* Parser::parseStates(const Poco::Token* next)
-{
- poco_assert(isOperator(next, Operator::FSM));
- const Poco::Token* token = next;
-// OPEN { // Transport connection is open
-// WAIT CLOSING {}
-// TDISreq(tsdu: TPDU::DR&) [P7()] CLOSING {DR(tsdu);}
-// }
- next = nextToken();
- do
- {
- next = parseState(next);
- }
- while (!isOperator(next, Operator::FSM));
- next = nextToken();
- return next;
-}
-const Poco::Token* Parser::parseState(const Poco::Token* next)
-{
- poco_assert(isIdentifier(next));
- state = map->lookfor(next->tokenString());
- if (state == nullptr)
- {
- state = factory.newState(next->tokenString());
- map->add(state);
- }
- map->add(state);
- next = nextToken();
- next = parseEntry(next);
- state->entry() = entry;
- next = parseExit(next);
- state->exit() = exit;
- next = parseTransitions(next);
- next = nextToken();
- return next;
-}
-const Poco::Token* Parser::parseEntry(const Poco::Token* next)
-{
- entry = nullptr;
- if (isOperator(next, Operator::OPENBRACE))
- return next;
- poco_assert(next->tokenString() == "Entry");
- entry = factory.newEntry("Entry");
- next = nextToken();
- next = parseActions(next, entry->actions());
- return next;
-}
-const Poco::Token* Parser::parseExit(const Poco::Token* next)
-{
- exit = nullptr;
- if (isOperator(next, Operator::OPENBRACE))
- return next;
- poco_assert(next->tokenString() == "Exit");
- exit = factory.newExit("Exit");
- next = nextToken();
- next = parseActions(next, exit->actions());
- return next;
-}
-const Poco::Token* Parser::parseTransitions(const Poco::Token* next)
-{
- poco_assert(isOperator(next, Operator::OPENBRACE));
- next = nextToken();
- while (!isOperator(next, Operator::CLOSBRACE))
- {
- next = parseTransition(next);
- }
- return next;
-}
-const Poco::Token* Parser::parseTransition(const Poco::Token* next)
-{
- poco_assert(isIdentifier(next));
- string name = next->tokenString();
- next = nextToken();
- next = parseParameters(next);
- transition = state->get(name, parameters);
- if (transition == nullptr)
- {
- transition = factory.newTransition(name);
- for (auto parameter : parameters)
- if (parameter != nullptr)
- transition->add(parameter);
- state->add(transition);
- map->add(transition);
- }
- guard = nullptr;
- next = parseGuard(next);
- transition->add(guard);
- next = parseNext(next);
- next = parseActions(next, guard->actions());
-// _dump(transition, guard);
- return next;
-}
-const Poco::Token* Parser::parseTransitionArgs(const Poco::Token* next)
-{
- next = nextToken();
- return next;
-}
-const Poco::Token* Parser::parseGuard(const Poco::Token* next)
-{
- guard = factory.newGuard("");
- if (isOperator(next, Operator::OPENBRACKET))
- {
- do
- {
- next = nextToken();
- next = parseExpression(next, guard->condition());
- }
- while (!isOperator(next, Operator::CLOSBRACKET));
- guard->condition()->guard() = guard;
- next = nextToken();
- }
- return next;
-}
-const Poco::Token* Parser::parseTerminal(const Poco::Token* next, ReferencePtr& reference)
-{
- poco_assert(isIdentifier(next));
- if (isIdentifier(next))
- {
- const Poco::Token* identifier = next; // true/false not supported
- next = nextToken();
- if (isOperator(next, Operator::OPENPARENT))
- {
- FunctionPtr function = factory.newFunction(identifier->tokenString());
- next = parseArguments(next, function->arguments());
- reference = factory.newReference(function);
- }
- else
- {
- VariablePtr variable = factory.newVariable(identifier->tokenString());
- reference = factory.newReference(variable);
- }
- reference->guard() = guard;
- }
- return next;
-}
-void Parser::reduce()
-{
- ExpressionPtr top;
- ExpressionPtr right;
- BinaryOperationPtr binop;
- ExpressionPtr left;
- ReferencePtr ref;
-
- right = _stack.top();
- _stack.pop();
- poco_check_ptr(right);
- top = _stack.top();
- if (top == nullptr)
- {
- _stack.pop();
- _stack.push(right);
- }
- else
- {
- binop = dynamic_cast(top);
- _stack.pop();
- left = _stack.top();
- _stack.pop();
- poco_check_ptr(left);
- binop->left() = left;
- left->operation() = binop;
- binop->right() = right;
- right->operation() = binop;
- if (_stack.size() > 1)
- if (_stack.top() == nullptr)
- _stack.pop();
-
- _stack.push(binop);
- }
-}
-const Poco::Token* Parser::parseExpression(const Poco::Token* next, ExpressionPtr& expression)
-{
- poco_assert(isIdentifier(next) || isOperator(next, Operator::NOT) || isOperator(next, Operator::OPENPARENT));
- poco_assert(_stack.size() == 0);
-
- for (;;)
- {
- if (isOperator(next, Operator::CLOSBRACKET))
- break;
-
- if (isIdentifier(next))
- {
- ReferencePtr reference;
- next = parseTerminal(next, reference);
- expression = reference;
- if (_stack.size() > 0)
- {
- ExpressionPtr top = _stack.top();
- if (top != nullptr)
- {
- //
- // TODO: to be improved using true operator's precedence.
- /*
- 1 () [] -> . :: Function call, scope, array/member access
- 2 ! ~ - + * & sizeof type cast ++ -- (most) unary operators, sizeof and type casts (right to left)
- 3 * / % MOD Multiplication, division, modulo
- 4 + - Addition and subtraction
- 5 << >> Bitwise shift left and right
- 6 < <= > >= Comparisons: less-than, ...
- 7 == != Comparisons: equal and not equal
- 8 & Bitwise AND
- 9 ^ Bitwise exclusive OR (XOR)
- 10 | Bitwise inclusive (normal) OR
- 11 && Logical AND
- 12 || Logical OR
- 13 ? : Conditional expression (ternary)
- 14 = += -= *= /= %= &= |= ^= <<= >>= Assignment operators (right to left)
- 15 , Comma operator
- */
- //
- UnaryOperation* monop = dynamic_cast(top);
- BinaryOperation* binop = dynamic_cast(top);
- if (monop)
- {
- monop->operand() = reference;
- reference->operation() = monop;
- expression = monop;
- _stack.pop();
- }
- else if (binop && (binop->op() == FSM::MODEL::Operator::equal || binop->op() == FSM::MODEL::Operator::notequal))
- {
- _stack.pop();
- binop->right() = reference;
- reference->operation() = binop;
- binop->left() = _stack.top();
- _stack.top()->operation() = binop;
- expression = binop;
- _stack.pop();
- }
- }
- }
- _stack.push(expression);
- }
- else if (isOperator(next, Operator::OPENPARENT))
- {
- _stack.push(nullptr);
- next = nextToken();
- }
- else if (isOperator(next, Operator::CLOSPARENT))
- {
- reduce();
- next = nextToken();
- }
- else if (isOperator(next))
- {
- switch (next->asInteger())
- {
- case Operator::NE:
- case Operator::EQ:
- case Operator::AND:
- case Operator::OR:
- case Operator::XOR:
- {
- FSM::MODEL::Operator op = FSM::MODEL::Operator::none;
- switch (next->asInteger())
- {
- case Operator::NE:
- op = FSM::MODEL::Operator::notequal;
- break;
- case Operator::EQ:
- op = FSM::MODEL::Operator::equal;
- break;
- case Operator::AND:
- op = FSM::MODEL::Operator::and;
- break;
- case Operator::OR:
- op = FSM::MODEL::Operator::or;
- break;
- case Operator::XOR:
- op = FSM::MODEL::Operator::xor;
- break;
- default:
- poco_assert(false);
- }
- BinaryOperation* binop = factory.newBinaryOperation(op);
- _stack.push(binop);
- next = nextToken();
- }
- break;
- case Operator::NOT:
- {
- UnaryOperation* not = factory.newUnaryOperation(FSM::MODEL::Operator::not);
- _stack.push(not);
- next = nextToken();
- }
- break;
- default:
- poco_assert(false);
- break;
- }
- }
- }
- while (_stack.size() > 1)
- reduce();
- expression = _stack.top();
- _stack.pop();
- return next;
-}
-const Poco::Token* Parser::parseNext(const Poco::Token* next)
-{
- poco_assert(isIdentifier(next));
-
- StatePtr endstate = map->lookfor(next->tokenString());
- if (endstate == nullptr && next->tokenString() != "nil")
- {
- endstate = factory.newState(next->tokenString());
- map->add(endstate);
- }
- guard->endstate() = endstate;
- next = nextToken();
- return next;
-}
-const Poco::Token* Parser::parseParameters(const Poco::Token* next)
-{
- parameters.clear();
- if (isOperator(next, Operator::OPENPARENT))
- {
- do
- {
- next = nextToken();
- next = parseParameter(next);
- parameters.push_back(parameter);
- }
- while (!isOperator(next, Operator::CLOSPARENT));
- next = nextToken();
- }
- return next;
-}
-const Poco::Token* Parser::parseParameter(const Poco::Token* next)
-{
- poco_assert(isIdentifier(next));
- parameter = factory.newParameter(next->tokenString());
- do
- {
- next = nextToken();
- poco_assert(isOperator(next, Operator::COLON));
- string type;
- for (;;)
- {
- next = nextToken();
- if (isOperator(next, Operator::CLOSPARENT) || isOperator(next, Operator::COMMA))
- break;
- string token = next->tokenString();
- if (token == "const")
- token += ' ';
- type += token;
- }
- parameter->type()= type;
- }
- while (!(isOperator(next, Operator::CLOSPARENT) || isOperator(next, Operator::COMMA)));
- return next;
-}
-const Poco::Token* Parser::parsePushTransition(const Poco::Token* next)
-{
- next = nextToken();
- return next;
-}
-const Poco::Token* Parser::parsePopTransition(const Poco::Token* next)
-{
- next = nextToken();
- return next;
-}
-const Poco::Token* Parser::parsePopArguments(const Poco::Token* next)
-{
- next = nextToken();
- return next;
-}
-const Poco::Token* Parser::parseActions(const Poco::Token* next, List& actions)
-{
- poco_assert(isOperator(next, Operator::OPENBRACE));
- const Poco::Token* token = next;
- next = nextToken();
- for (;;)
- {
- if (isOperator(next, Operator::CLOSBRACE))
- break;
- action = nullptr;
- next = parseAction(next);
- actions.push_back(action);
- }
- next = nextToken();
- return next;
-}
-const Poco::Token* Parser::parseAction(const Poco::Token* next)
-{
- poco_assert(isIdentifier(next));
- action = factory.newAction(next->tokenString());
- next = nextToken();
- next = parseArguments(next, action->arguments());
- poco_assert(isOperator(next, Operator::SEMICOLON));
- next = nextToken();
- return next;
-}
-const Poco::Token* Parser::parseArguments(const Poco::Token* next, List& arguments)
-{
- poco_assert(isOperator(next, Operator::OPENPARENT));
- next = nextToken();
- for (;;)
- {
- if (isOperator(next, Operator::CLOSPARENT))
- break;
- if (isOperator(next, Operator::COMMA))
- next = nextToken();
- next = parseArgument(next, arguments);
- }
- poco_assert(isOperator(next, Operator::CLOSPARENT));
- next = nextToken();
- return next;
-}
-const Poco::Token* Parser::parseArgument(const Poco::Token* next, List& arguments)
-{
- poco_assert(isIdentifier(next) || isNumber(next) || isString(next) || isCharacter(next));
- string code;
- int count = 0;
- for (;;)
- {
- if (isOperator(next, Operator::COMMA))
- break;
- if (isOperator(next, Operator::CLOSPARENT) && count-- == 0)
- {
- break;
- }
- if (isOperator(next, Operator::OPENPARENT))
- count += 1;
- code += next->tokenString();
- next = nextToken();
- }
- ArgumentPtr argument = factory.newArgument(code);
- arguments.push_back(argument);
- return next;
-}
-const Poco::Token* Parser::parseRawCode(const Poco::Token* next)
-{
- do
- {
- next = nextToken();
- }
- while (!isOperator(next, Operator::CLOSCODE));
- next = nextToken();
- return next;
-}
-const Poco::Token* Parser::nextToken()
-{
- const Poco::Token* next = nextPreprocessed();
- while (!_inFile && !isEOF(next))
- next = nextPreprocessed();
- return next;
-}
-const Poco::Token* Parser::nextPreprocessed()
-{
- const Poco::Token* next = nextParserToken();
- while (next->is(Token::PREPROCESSOR_TOKEN))
- {
- istringstream pps(next->tokenString());
- pps.get();
- Tokenizer ppt(pps);
- const Poco::Token* pPPT = ppt.nextToken();
- if (pPPT->tokenString() == "line" || pPPT->is(Token::INTEGER_LITERAL_TOKEN))
- {
- if (!pPPT->is(Token::INTEGER_LITERAL_TOKEN))
- pPPT = ppt.nextToken();
- int line = pPPT->asInteger();
- _istr.setCurrentLineNumber(line);
- pPPT = ppt.nextToken();
- if (pPPT->is(Token::STRING_LITERAL_TOKEN))
- {
- string path = pPPT->asString();
- Path p(path);
- p.makeAbsolute();
- _currentPath = p.toString();
- _inFile = (Poco::icompare(_path.toString(), _currentPath) == 0);
- }
- }
- next = nextParserToken();
- }
- return next;
-}
-
-
-const Poco::Token* Parser::nextParserToken()
-{
- const Poco::Token* next = _tokenizer.nextToken();
- while (next->is(Token::COMMENT_TOKEN) || next->is(Token::SPECIAL_COMMENT_TOKEN))
- {
- if (next->is(Token::SPECIAL_COMMENT_TOKEN))
- {
-#if 0
- if (_pCurrentSymbol)
- {
- _pCurrentSymbol->addDocumentation(next->asString());
- _doc.clear();
- }
- else
-#endif
- if (_inFile)
- {
- if (!_doc.empty()) _doc += "\n";
- _doc += next->asString();
- }
- }
- else if (next->is(Token::COMMENT_TOKEN) && _inFile)
- {
- const string& comment = next->tokenString();
- if (comment.compare(0, 3, "//@") == 0)
- {
- _attrs.append(comment.substr(3));
- }
- else if (comment.compare(0, 11, "// Package:") == 0)
- {
- _package = comment.substr(11);
- Poco::trimInPlace(_package);
- }
- else if (comment.compare(0, 11, "// Library:") == 0)
- {
- _library = comment.substr(11);
- Poco::trimInPlace(_library);
- }
- }
- next = _tokenizer.nextToken();
- }
- return next;
-}
-void Parser::syntaxError(const string& msg)
-{
- throw SyntaxException("Expected", msg);
-}
-}
-}
-}
diff --git a/FSM/src/Print.cpp b/FSM/src/Print.cpp
deleted file mode 100644
index 7b2daff20..000000000
--- a/FSM/src/Print.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Print.cpp
- *
- * Created on: 22 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include
-using std::max;
-
-#include "Poco/Logger.h"
-using Poco::Logger;
-
-#include "model/Parameter.h"
-#include "model/Guard.h"
-#include "model/Transition.h"
-#include "model/Print.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace MODEL
-{
-void Print::operator()(const char* message)
-{
- logger.information(message);
-}
-void Print::operator()(const string& message)
-{
- logger.information(message);
-}
-void Print::operator()(const TransitionPtr transition, const GuardPtr guard)
-{
- string line = transition->name();
-
- string parameters;
- if (!transition->parameters().empty())
- parameters += '(';
- for (auto parameter : transition->parameters())
- {
- parameters += parameter->display();
- }
- if (!transition->parameters().empty())
- parameters += ')';
-
- line += parameters;
- line.resize(max(line.size(), (size_t)34), ' ');
-
- string guards = guard->display();
- logger.information("\t%s%s", line, guards);
-
-}
-
-}
-}
-}
diff --git a/FSM/src/Reference.cpp b/FSM/src/Reference.cpp
deleted file mode 100644
index 4391ee050..000000000
--- a/FSM/src/Reference.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Reference.cpp
- *
- * Created on: 1 févr. 2016
- * Author: FrancisANDRE
- */
-
-#include "model/Reference.h"
-#include "model/Guard.h"
-#include "model/Transition.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace MODEL
-{
-bool Reference::isParameter() const
-{
- GuardPtr g = guard();
- TransitionPtr transition = guard()->transition();
- if (transition->hasParameter(reference()->Element::name()))
- return true;
- else
- return false;
-}
-const string Reference::display() const
-{
- return reference()->display();
-}
-}
-}
-}
diff --git a/FSM/src/ReferenceForCpp.cpp b/FSM/src/ReferenceForCpp.cpp
deleted file mode 100644
index 16bbcb5fb..000000000
--- a/FSM/src/ReferenceForCpp.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * ReferenceForCpp.cpp
- *
- * Created on: 24 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "cpp/ReferenceForCpp.h"
-#include "cpp/VariableForCpp.h"
-#include "cpp/FunctionForCpp.h"
-
-using namespace Poco::FSM::MODEL;
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-namespace CPP
-{
-void ReferenceForCpp::generateInclude(ostream& inc, bool debug) const
-{
-}
-void ReferenceForCpp::generateCode(ostream& cpp, bool debug) const
-{
-}
-const string ReferenceForCpp::display(const string& prefix) const
-{
- VariableForCpp* vfc;
- FunctionForCpp* ffc;
- vfc = dynamic_cast(reference());
- ffc = dynamic_cast(reference());
- if (isParameter() || (operation() && !operation()->contextuel()))
- {
- if (operation())
- operation()->setNoContextuel();
- if (vfc)
- return vfc->Variable::display();
- else if (ffc)
- return ffc->Function::display();
- else
- poco_assert(false);
- }
- else
- {
- if (vfc)
- return vfc->display(prefix);
- else if (ffc)
- return ffc->display(prefix);
- else
- poco_assert(false);
- }
-}
-}
-}
-}
-}
diff --git a/FSM/src/State.cpp b/FSM/src/State.cpp
deleted file mode 100644
index 409c2abc2..000000000
--- a/FSM/src/State.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * State.cpp
- *
- * Created on: 16 janv. 2016
- * Author: FrancisANDRE
- */
-#include
-#include "Poco/Format.h"
-using Poco::format;
-
-
-#include "model/State.h"
-#include "model/Entry.h"
-#include "model/Exit.h"
-#include "model/Transition.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace MODEL
-{
-TransitionPtr State::get(const string& name, const List& parameters) const
-{
- TransitionPtr transition = nullptr;
- string signature = Transition::signature(name, parameters);
- try
- {
- transition = maps.at(signature);
- }
- catch (std::out_of_range e)
- {
- }
- return transition;
-}
-TransitionPtr State::add(TransitionPtr transition)
-{
- transition->begstate() = this;
- _transitions.push_back(transition);
- maps[transition->signature()] = transition;
- return transition;
-}
-void State::print(Print& print) const
-{
- print(Element::name());
- if (entry())
- entry()->print(print);
- if (exit())
- exit()->print(print);
- print("{");
- for (const auto& transition : transitions())
- {
- transition->print(print);
- }
- print("}");
-}
-const string State::display() const
-{
- if (oneline.empty())
- {
- oneline = name();
- }
- return oneline;
-}
-}
-}
-}
\ No newline at end of file
diff --git a/FSM/src/StateForCpp.cpp b/FSM/src/StateForCpp.cpp
deleted file mode 100644
index a5453429a..000000000
--- a/FSM/src/StateForCpp.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * StateForCpp.cpp
- *
- * Created on: 19 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include
-#include "cpp/MapForCpp.h"
-#include "cpp/StateForCpp.h"
-#include "cpp/EntryForCpp.h"
-#include "cpp/ExitForCpp.h"
-#include "cpp/ActionForCpp.h"
-#include "cpp/TransitionForCpp.h"
-#include "parser/IndentStream.h"
-#include "model/FSM.h"
-
-using namespace std;
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-namespace CPP
-{
-string StateForCpp::statename() const
-{
- return map()->name() + '_' + name();
-}
-void StateForCpp::generateForwarDeclaration(ostream& inc, bool debug) const
-{
- inc << "class " << statename() << ';' << endl;
-}
-void StateForCpp::generateVirtualTransitions(ostream& inc, bool debug) const
-{
- for (const auto& transition : _transitions)
- {
- TransitionForCpp* tfc = dynamic_cast(transition);
- if (tfc)
- tfc->generateVirtualTransitions(inc, debug);
- }
-}
-void StateForCpp::generateDefinition(ostream& inc, bool debug) const
-{
- inc << "// --------------------------------------------------" << endl;
- inc << "class " << statename() << ": public " << map()->name() <<"_Default { " << endl;
- inc << "public:" << endl << tab;
- inc << statename() << "(const char* name, int no) : " << map()->name() << "_Default(name, no) {}" << endl;
-
- inc << endl;
- if (entry())
- {
- inc << "void " << "Entry" << "(" << map()->fsm()->context() << "& context);" << endl;
- }
- if (exit())
- {
- inc << "void " << "Exit" << "(" << map()->fsm()->context() << "& context);" << endl;
- }
- inc << endl;
-
- for (auto transition : _transitions)
- {
- TransitionForCpp* tfc = dynamic_cast(transition);
- if (tfc)
- tfc->generateDefinition(inc, debug);
- }
- inc << back << "};" << endl;
- inc << endl;
-}
-
-
-void StateForCpp::generateInclude(ostream& inc, bool debug) const
-{
-}
-void StateForCpp::generateDeclaration(ostream& cpp, int no) const
-{
-// cpp << name() << "\t\t" << map()->name() << "::" << State::name();
- cpp << State::name() << '(' << '"' << State::name() << '"' << ", " << no << ")";
-}
-void StateForCpp::generateCode(ostream& cpp, bool debug) const
-{
- if (entry())
- {
- cpp << "void " << statename() << "::Entry" << "(" << map()->fsm()->context() << "& context) {" << endl;
- cpp << " " << map()->fsm()->klass() << "& ctxt = context.getOwner();" << endl;
- for (const auto& action : entry()->actions())
- if (action)
- {
- ActionForCpp* afc = static_cast(action);
- cpp << tab << "ctxt." << afc->display() << endl << back;
- }
- cpp << "}" << endl;
- }
- if (exit())
- {
- cpp << "void " << statename() << "::Exit" << "(" << map()->fsm()->context() << "& context) {" << endl;
- cpp << " " << map()->fsm()->klass() << "& ctxt = context.getOwner();" << endl;
- for (const auto& action : exit()->actions())
- if (action)
- {
- ActionForCpp* afc = static_cast(action);
- cpp << tab << "ctxt." << afc->display() << endl << back;
- }
- cpp << "}" << endl;
- }
- for (const auto& transition : _transitions)
- {
- TransitionForCpp* tfc = dynamic_cast(transition);
- if (tfc)
- tfc->generateCode(cpp, debug);
- }
-}
-}
-}
-}
-}
\ No newline at end of file
diff --git a/FSM/src/String.cpp b/FSM/src/String.cpp
deleted file mode 100644
index 671ced50d..000000000
--- a/FSM/src/String.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * String.cpp
- *
- * Created on: 3 août 2014
- * Author: FrancisANDRE
- */
-
-#include "Poco/Ascii.h"
-#include "Poco/StreamTokenizer.h"
-#include "Poco/Exception.h"
-
-using Poco::StreamTokenizer;
-using Poco::SyntaxException;
-using Poco::Token;
-using Poco::InvalidToken;
-using Poco::EOFToken;
-using Poco::WhitespaceToken;
-using Poco::Ascii;
-
-#include "parser/String.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-
-String::String()
-{
-}
-
-
-String::~String()
-{
-}
-
-
-Token::Class String::tokenClass() const
-{
- return Token::STRING_LITERAL_TOKEN;
-}
-
-
-bool String::start(char c, std::istream& istr)
-{
- _value = c;
- return c == '"';
-}
-
-
-void String::finish(std::istream& istr)
-{
- int next = istr.peek();
- while (next != -1 && next != '"' && next != '\n' && next != '\r')
- {
- if (next == '\\') _value += (char) istr.get();
- _value += (char) istr.get();
- next = istr.peek();
- }
- if (next == '"')
- {
- next = istr.get();
- _value += (char) next;
- }
- else throw SyntaxException("Unterminated string literal");
-}
-
-
-std::string String::asString() const
-{
- std::string result;
- std::string::const_iterator it = _value.begin();
- std::string::const_iterator end = _value.end();
- if (it != end)
- {
- if (*it == '"') ++it;
- while (it != end && *it != '"')
- {
- if (*it == '\\') ++it;
- if (it != end) result += *it++;
- }
- }
- return result;
-}
-
-
-}
-}
-}
diff --git a/FSM/src/Token.cpp b/FSM/src/Token.cpp
deleted file mode 100644
index 7751171e2..000000000
--- a/FSM/src/Token.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Token.cpp
- *
- * Created on: 3 août 2014
- * Author: FrancisANDRE
- */
-
-#include "Poco/Ascii.h"
-#include "Poco/StreamTokenizer.h"
-#include "Poco/Token.h"
-#include "Poco/Exception.h"
-using Poco::StreamTokenizer;
-using Poco::Token;
-using Poco::InvalidToken;
-using Poco::EOFToken;
-using Poco::WhitespaceToken;
-using Poco::Ascii;
-using Poco::SyntaxException;
-
-#include "parser/Token.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-
-Token::Token()
-{
-}
-
-
-Token::~Token()
-{
-}
-
-
-void Token::syntaxError(const std::string& expected, const std::string& actual)
-{
- std::string msg("expected: ");
- msg.append(expected);
- msg.append(", got: ");
- msg.append(actual);
- throw SyntaxException(msg);
-}
-
-}
-}
-}
diff --git a/FSM/src/Tokenizer.cpp b/FSM/src/Tokenizer.cpp
deleted file mode 100644
index fa674d805..000000000
--- a/FSM/src/Tokenizer.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Tokenizer.cpp
- *
- * Created on: 3 août 2014
- * Author: FrancisANDRE
- */
-
-#include "Poco/Token.h"
-using Poco::WhitespaceToken;
-#include "parser/Tokenizer.h"
-#include "parser/Identifier.h"
-#include "parser/Number.h"
-#include "parser/Keyword.h"
-#include "parser/Comment.h"
-#include "parser/Character.h"
-#include "parser/Operator.h"
-#include "parser/String.h"
-
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-Tokenizer::Tokenizer(std::istream& istr):
- StreamTokenizer(istr)
-{
- addToken(new WhitespaceToken());
- addToken(new Comment());
- addToken(new Identifier());
- addToken(new Number());
- addToken(new Keyword());
- addToken(new Operator());
- addToken(new Character());
- addToken(new String());
-
-}
-
-
-Tokenizer::~Tokenizer()
-{
-}
-
-}
-}
-}
diff --git a/FSM/src/Transition.cpp b/FSM/src/Transition.cpp
deleted file mode 100644
index f9f4e4faa..000000000
--- a/FSM/src/Transition.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Transition.cpp
- *
- * Created on: 16 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include
-using std::max;
-using std::binary_search;
-
-#include "Poco/Format.h"
-using Poco::format;
-
-#include "model/Transition.h"
-#include "model/Parameter.h"
-#include "model/Guard.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace MODEL
-{
-Transition::Transition(const string& name, int lineno) : Element(name, lineno)
-{
-}
-Transition::~Transition()
-{
-}
-
-bool parameterEqual(const Parameter* left, const Parameter* right)
-{
- return left->Element::name() < right->Element::name();
-}
-bool Transition::hasParameter(const string& name) const
-{
- for (const auto& parameter : _parameters)
- {
- if (parameter->Element::name() == name)
- return true;
- }
- return false;
-}
-string Transition::declaration(const Parameter* added) const
-{
- string declaration(name());
- declaration += '(';
- if (added != nullptr)
- {
- declaration += added->type();
- declaration += ' ';
- declaration += added->name();
- if (!parameters().empty())
- declaration += ", ";
- }
- if (!parameters().empty())
- {
- for (int no = 0; no < parameters().size(); ++no)
- {
- declaration += parameters()[no]->type();
- declaration += ' ';
- declaration += parameters()[no]->name();
- if (no + 1 < parameters().size())
- declaration += ", ";
- }
- }
- declaration += ')';
- return declaration;
-}
-string Transition::call(const char* c) const
-{
- string embed(name());
- embed += '(';
- if (c != nullptr)
- {
- embed += c;
- if (!parameters().empty())
- {
- embed += ", ";
- }
- }
- if (!parameters().empty())
- {
- for (int no = 0; no < parameters().size(); ++no)
- {
- embed += parameters()[no]->name();
- if (no + 1 < parameters().size())
- embed += ", ";
- }
- }
- embed += ')';
- return embed;
-}
-string Transition::signature(const string& name, const List& parameters)
-{
- string signature(name);
- signature += '(';
- if (!parameters.empty())
- {
- for (int no = 0; no < parameters.size(); ++no)
- {
- signature += parameters[no]->type();
- if (no + 1 < parameters.size())
- signature += ", ";
- }
- }
- signature += ')';
- return signature;
-}
-const string& Transition::signature() const
-{
- if (_signature.empty())
- {
- _signature = signature(Element::name(), _parameters);
- }
- return _signature;
-}
-const string Transition::display() const
-{
- if (oneline.empty())
- {
- string transition = name();
-
- string parameters;
- if (!_parameters.empty())
- parameters += '(';
- for (auto parameter : _parameters)
- {
- parameters += parameter->display();
- }
- if (!_parameters.empty())
- parameters += ')';
-
- transition += parameters;
- transition.resize(max(transition.size(), (size_t)30), ' ');
-
- string guards = _guards.at(0)->display();
-
- oneline = format("\t%s%s", transition, guards);
- }
- return oneline;
-}
-void Transition::print(Print& print) const
-{
- for (auto guard : guards())
- {
- const TransitionPtr transitionptr = const_cast(this);
- const GuardPtr guardptr = guard;
- print(transitionptr, guardptr);
- }
-}
-}
-}
-}
\ No newline at end of file
diff --git a/FSM/src/TransitionForCpp.cpp b/FSM/src/TransitionForCpp.cpp
deleted file mode 100644
index 2a5ec1590..000000000
--- a/FSM/src/TransitionForCpp.cpp
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * TransitionForCpp.cpp
- *
- * Created on: 19 janv. 2016
- * Author: FrancisANDRE
- */
-#include
-#include
-#include "cpp/TransitionForCpp.h"
-#include "cpp/ParameterForCpp.h"
-#include "cpp/FSMForCpp.h"
-#include "cpp/MapForCpp.h"
-#include "cpp/StateForCpp.h"
-#include "cpp/GuardForCpp.h"
-#include "cpp/ActionForCpp.h"
-#include "cpp/ExpressionForCpp.h"
-#include "parser/IndentStream.h"
-#include "model/Parameter.h"
-
-using Poco::FSM::MODEL::Parameter;
-using namespace std;
-
-static const bool RAPP = false;
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-namespace CPP
-{
-
-const string TransitionForCpp::name() const
-{
- string cppname = Element::name();
- replace(cppname.begin(), cppname.end(), '-', '_');
- return cppname;
-}
-void TransitionForCpp::generateVirtualTransitions(ostream& inc, bool debug) const
-{
- if (begstate()->entry())
- {
- inc << "virtual void " << "Entry" << "(" << begstate()->map()->fsm()->context() << "& context);";
- }
- if (begstate()->exit())
- {
- inc << "virtual void " << "Exit" << "(" << begstate()->map()->fsm()->context() << "& context);";
- }
- inc << "virtual void " << name() << "(" << begstate()->map()->fsm()->context() << "& context";
- if (!_parameters.empty())
- {
- inc << ", ";
- for (int no = 0; no < _parameters.size(); ++no)
- {
- dynamic_cast(_parameters[no])->generateInclude(inc, debug);
- if (no + 1 < _parameters.size())
- inc << ", ";
- }
- }
- inc << ");" << endl;
-}
-void TransitionForCpp::generateDefinition(ostream& inc, bool debug) const
-{
- inc << "void " << name() << "(" << begstate()->map()->fsm()->context() << "& context";
- if (!_parameters.empty())
- {
- inc << ", ";
- for (int no = 0; no < _parameters.size(); ++no)
- {
- dynamic_cast(_parameters[no])->generateInclude(inc, debug);
- if (no + 1 < _parameters.size())
- inc << ", ";
- }
- }
- inc << ");" << endl;
-}
-void TransitionForCpp::generateInclude(ostream& inc, bool debug) const
-{
-}
-void TransitionForCpp::generateCode(ostream& cpp, bool debug) const
-{
- cpp << endl;
- cpp << "// ----------------------------------------------------" << endl;
- cpp << "void " << _begstate->map()->name() << '_' << _begstate->name() << "::";
- Parameter context("context");
- context.type() = begstate()->map()->fsm()->context() + '&';
- cpp << declaration(&context) << " {"<< endl;
-// cpp << "(" << begstate()->map()->fsm()->context() << "&context) {" << endl ;
- cpp << tab;
-
- cpp << _begstate->map()->fsm()->klass() << "& ctxt = context.getOwner();" << endl;
- cpp << endl;
-
-
- for (auto guard : _guards)
- {
- if (guard != nullptr)
- {
- if (guard->endstate() == nullptr)
- {
- for (auto action : guard->actions())
- if (action != nullptr)
- {
- ActionForCpp* afc = static_cast(action);
- cpp << "ctxt." << action->display() << endl;
- }
- continue;
- }
-
- if (guard->condition())
- {
- ExpressionForCpp* efc = dynamic_cast(guard->condition());
- cpp << "if (" << efc->display("ctxt.") << ") {" << endl << tab;
- }
- cpp << "(context.getState()).Exit(context);" << endl;
-
- if (guard->actions().size() > 0)
- {
- if (RAPP)
- {
- cpp << "context.clearState();" << endl;
- }
- if (RAPP)
- {
- cpp << "try {" << endl << tab;
- }
- }
-
- cpp << "context.setState(context." << guard->endstate()->name() << ");" << endl;
- if (!RAPP)
- {
- cpp << "(context.getState()).Entry(context);" << endl;
- }
-
- for (auto action : guard->actions())
- if (action != nullptr)
- {
- ActionForCpp* afc = static_cast(action);
- cpp << "ctxt." << action->display() << endl;
- }
-
- if (guard->actions().size() > 0)
- {
- if (RAPP)
- {
- cpp << back << "} catch (...) {" << endl << tab;
- cpp << "context.setState(context." << guard->endstate()->name() << ");" << endl;
- cpp << "throw;" << endl << back;
- cpp << "}" << endl;
- }
- }
- if (RAPP)
- {
- cpp << "(context.getState()).Entry(context);" << endl;
- }
- if (guard->condition())
- cpp << back << "} else " << endl;
- }
- }
- if (_guards[0]->condition())
- {
- Parameter context("context");
- cpp << "{" << endl;
- MapForCpp* mfcpp = dynamic_cast(_begstate->map());
- cpp << " " << mfcpp->defaultStateName() << "::" << call("context") << ";" << endl;
- cpp << "}" << endl;
- }
- cpp << "return;" << back << endl;
- cpp << "};" << endl;
-}
-}
-}
-}
-}
diff --git a/FSM/src/UnaryOperation.cpp b/FSM/src/UnaryOperation.cpp
deleted file mode 100644
index 6779c15de..000000000
--- a/FSM/src/UnaryOperation.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * UnaryOperation.cpp
- *
- * Created on: 20 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "model/UnaryOperation.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace MODEL
-{
-const string UnaryOperation::display() const
-{
- if (_asstring.empty())
- {
- switch (_operator)
- {
- case Operator::not:
- _asstring += '!';
- }
- _asstring += _operand->display();
- }
- return _asstring;
-}
-}
-}
-}
\ No newline at end of file
diff --git a/FSM/src/UnaryOperationForCpp.cpp b/FSM/src/UnaryOperationForCpp.cpp
deleted file mode 100644
index 47a7a8c42..000000000
--- a/FSM/src/UnaryOperationForCpp.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * UnaryOperationForCpp.cpp
- *
- * Created on: 24 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "cpp/UnaryOperationForCpp.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-namespace CPP
-{
-const string UnaryOperationForCpp::display(const string& prefix) const
-{
- string value;
- switch (_operator)
- {
- case Poco::FSM::MODEL::Operator::not:
- value += "!";
- break;
- default:
- value += "???";
- break;
- }
- value += dynamic_cast(operand())->display(prefix);
- return value;
-}
-}
-}
-}
-}
diff --git a/FSM/src/Variable.cpp b/FSM/src/Variable.cpp
deleted file mode 100644
index ca72992fe..000000000
--- a/FSM/src/Variable.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Variable.cpp
- *
- * Created on: 21 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "model/Variable.h"
-
-namespace Poco
-{
-namespace FSM
-{
-namespace MODEL
-{
-const string Variable::display() const
-{
- return name();
-}
-}
-}
-}
\ No newline at end of file
diff --git a/FSM/src/VariableForCpp.cpp b/FSM/src/VariableForCpp.cpp
deleted file mode 100644
index 2c1273766..000000000
--- a/FSM/src/VariableForCpp.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * VariableForCpp.cpp
- *
- * Created on: 21 janv. 2016
- * Author: FrancisANDRE
- */
-
-#include "cpp/VariableForCpp.h"
-
-using namespace Poco::FSM::MODEL;
-
-namespace Poco
-{
-namespace FSM
-{
-namespace PARSER
-{
-namespace CPP
-{
-const string VariableForCpp::display(const string& prefix) const
-{
- return prefix + name();
-}
-}
-}
-}
-}
diff --git a/FSM/src/cpp/ActionForCpp.h b/FSM/src/cpp/ActionForCpp.h
deleted file mode 100644
index cd92979fc..000000000
--- a/FSM/src/cpp/ActionForCpp.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * ActionForCpp.h
- *
- * Created on: 19 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef POCO_FSM_CPP_ACTION_H_
-#define POCO_FSM_CPP_ACTION_H_
-
-#include "model/Action.h"
-#include "CompilableForCpp.h"
-
-namespace Poco {
- namespace FSM {
- namespace PARSER {
- namespace CPP {
-
- class ActionForCpp : public CompilableForCpp, public FSM::MODEL::Action {
- public:
- ActionForCpp(const string& name, int lineno = 0) :
- FSM::MODEL::Action(name, lineno) {
- }
- virtual ~ActionForCpp() {
- }
- virtual const string name() const;
- virtual void generateInclude(ostream& inc, bool debug) const;
- virtual void generateCode(ostream& cpp, bool debug) const;
- };
-
- }
- }
- }
-}
-#endif
diff --git a/FSM/src/cpp/ArgumentForCpp.h b/FSM/src/cpp/ArgumentForCpp.h
deleted file mode 100644
index 6046a34d2..000000000
--- a/FSM/src/cpp/ArgumentForCpp.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * ArgumentForCpp.h
- *
- * Created on: 21 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef ARGUMENTFORCPP_H_
-#define ARGUMENTFORCPP_H_
-
-#include "model/Argument.h"
-#include "CompilableForCpp.h"
-
-namespace Poco {
- namespace FSM {
- namespace PARSER {
- namespace CPP {
- class ArgumentForCpp : public CompilableForCpp, public FSM::MODEL::Argument {
- public:
- ArgumentForCpp(const string& name, int lineno = 0) :
- FSM::MODEL::Argument(name, lineno) {
- }
- virtual ~ArgumentForCpp() {
- }
- virtual void generateInclude(ostream& inc, bool debug) const;
- virtual void generateCode(ostream& cpp, bool debug) const;
- };
-
- }
- }
- }
-}
-
-#endif
diff --git a/FSM/src/cpp/BinaryOperationForCpp.h b/FSM/src/cpp/BinaryOperationForCpp.h
deleted file mode 100644
index 92d917d5e..000000000
--- a/FSM/src/cpp/BinaryOperationForCpp.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * BinaryOperationForCpp.h
- *
- * Created on: 24 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef BINARYOPERATIONFORCPP_H_
-#define BINARYOPERATIONFORCPP_H_
-
-#include "model/BinaryOperation.h"
-#include "ExpressionForCpp.h"
-
-namespace Poco {
- namespace FSM {
- namespace PARSER {
- namespace CPP {
-
- class BinaryOperationForCpp : public ExpressionForCpp, public FSM::MODEL::BinaryOperation {
-
- public:
- BinaryOperationForCpp(Poco::FSM::MODEL::Operator op) :
- FSM::MODEL::BinaryOperation(op) {
- }
- virtual ~BinaryOperationForCpp() {
- }
- const string display(const string& prefix) const;
- };
- }
- }
- }
-}
-
-#endif
diff --git a/FSM/src/cpp/CompilableForCpp.h b/FSM/src/cpp/CompilableForCpp.h
deleted file mode 100644
index f01303203..000000000
--- a/FSM/src/cpp/CompilableForCpp.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * CompilableForCpp.h
- *
- * Created on: 24 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef COMPILABLEFORCPP_H_
-#define COMPILABLEFORCPP_H_
-
-#include
-using std::ostream;
-
-#include "model/Compilable.h"
-using Poco::FSM::MODEL::FSMPtr;
-
-namespace Poco {
-namespace FSM {
-namespace PARSER {
-namespace CPP {
-
-class CompilableForCpp : public Poco::FSM::MODEL::Compilable {
-public:
- CompilableForCpp() : Poco::FSM::MODEL::Compilable() {
- }
- virtual ~CompilableForCpp() {
- }
- virtual void generate(const Path& path, bool debug) const {}
- virtual void generateInclude(ostream& inc, bool debug) const = 0;
- virtual void generateCode(ostream& cpp, bool debug) const = 0;
-};
-
-}
-}
-}
-}
-
-#endif
diff --git a/FSM/src/cpp/ElementForCpp.h b/FSM/src/cpp/ElementForCpp.h
deleted file mode 100644
index 0da2b804a..000000000
--- a/FSM/src/cpp/ElementForCpp.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * ElementForCpp.h
- *
- * Created on: 2 févr. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef ELEMENTFORCPP_H_
-#define ELEMENTFORCPP_H_
-
-#include
-using std::replace;
-
-#include "model/Element.h"
-
-namespace Poco {
- namespace FSM {
- namespace PARSER {
- namespace CPP {
-
- class ElementForCpp : public virtual MODEL::Element {
- private:
- string _cppname;
-
- public:
- ElementForCpp(const string& name, int lineno = 0) :
- MODEL::Element(name, lineno) {
- _cppname = name;
- replace(_cppname.begin(), _cppname.end(), '-', '_');
- }
- virtual ~ElementForCpp() {
- }
- protected:
- const string& cppname() const { return _cppname; }
- };
-
- }
- }
- }
-}
-
-#endif
diff --git a/FSM/src/cpp/EntryForCpp.h b/FSM/src/cpp/EntryForCpp.h
deleted file mode 100644
index d0cdb356e..000000000
--- a/FSM/src/cpp/EntryForCpp.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * EntryForCpp.h
- *
- * Created on: 26 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef ENTRYFORCPP_H_
-#define ENTRYFORCPP_H_
-
-#include "model/Entry.h"
-#include "CompilableForCpp.h"
-
-namespace Poco {
- namespace FSM {
- namespace PARSER {
- namespace CPP {
-
- class EntryForCpp : public CompilableForCpp, public FSM::MODEL::Entry {
- public:
- EntryForCpp(const string& name, int lineno = 0) :
- FSM::MODEL::Entry(name, lineno) {
- }
- virtual ~EntryForCpp() {
- }
- virtual void generateInclude(ostream& inc, bool debug) const;
- virtual void generateCode(ostream& cpp, bool debug) const;
- };
-
- }
- }
- }
-}
-
-#endif
diff --git a/FSM/src/cpp/ExitForCpp.h b/FSM/src/cpp/ExitForCpp.h
deleted file mode 100644
index 30dabea90..000000000
--- a/FSM/src/cpp/ExitForCpp.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * ExitForCpp.h
- *
- * Created on: 26 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef EXITFORCPP_H_
-#define EXITFORCPP_H_
-
-#include "model/Exit.h"
-#include "CompilableForCpp.h"
-
-namespace Poco {
- namespace FSM {
- namespace PARSER {
- namespace CPP {
-
- class ExitForCpp : public CompilableForCpp, public FSM::MODEL::Exit {
- public:
- ExitForCpp(const string& name, int lineno = 0) :
- FSM::MODEL::Exit(name, lineno) {
- }
- virtual ~ExitForCpp() {
- }
- virtual void generateInclude(ostream& inc, bool debug) const;
- virtual void generateCode(ostream& cpp, bool debug) const;
- };
-
- }
- }
- }
-}
-
-#endif
diff --git a/FSM/src/cpp/ExpressionForCpp.h b/FSM/src/cpp/ExpressionForCpp.h
deleted file mode 100644
index db7304bd9..000000000
--- a/FSM/src/cpp/ExpressionForCpp.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * ExpressionForCpp.h
- *
- * Created on: 24 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef EXPRESSIONFORCPP_H_
-#define EXPRESSIONFORCPP_H_
-
-#include "model/Expression.h"
-
-namespace Poco {
-namespace FSM {
-namespace PARSER {
-namespace CPP {
-
-class ExpressionForCpp : public virtual Poco::FSM::MODEL::Expression {
-public:
- ExpressionForCpp() {
- }
- virtual ~ExpressionForCpp() {
- }
- virtual const string display(const string& prefix) const = 0;
-};
-
-}
-}
-}
-}
-
-#endif
diff --git a/FSM/src/cpp/FSMForCpp.h b/FSM/src/cpp/FSMForCpp.h
deleted file mode 100644
index ff26b0f5d..000000000
--- a/FSM/src/cpp/FSMForCpp.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * FSMForCpp.h
- *
- * Created on: 19 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef POCO_FSM_CPP_FSM_H_
-#define POCO_FSM_CPP_FSM_H_
-
-
-#include "model/FSM.h"
-#include "CompilableForCpp.h"
-#include "parser/IndentStream.h"
-
-namespace Poco {
- namespace FSM {
- namespace PARSER {
- namespace CPP {
-
- class FSMForCpp : public Poco::FSM::MODEL::FSM {
- public:
- FSMForCpp(Parser* parser) :
- Poco::FSM::MODEL::FSM(parser) {
- }
- virtual ~FSMForCpp() {
- }
- void generate(const Path& out, bool debug) const;
- virtual bool updated(const Path& out);
-
- private:
- void openNamespaces(IndentStream& os) const;
- void closeNamespaces(IndentStream& os) const;
- };
-
- }
- }
- }
-}
-#endif
diff --git a/FSM/src/cpp/FactoryForCpp.h b/FSM/src/cpp/FactoryForCpp.h
deleted file mode 100644
index d212c7e47..000000000
--- a/FSM/src/cpp/FactoryForCpp.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * FactoryForCpp.h
- *
- * Created on: 20 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef POCO_FSM_PARSER_CPP_FACTORY_H_
-#define POCO_FSM_PARSER_CPP_FACTORY_H_
-#include
-using std::string;
-
-
-#include "model/SMC.h"
-#include "model/Operation.h"
-#include "model/Factory.h"
-
-namespace Poco {
- namespace FSM {
- namespace PARSER {
- namespace CPP {
-
- class FactoryForCpp : public Poco::FSM::MODEL::Factory {
- public:
- FactoryForCpp() {
- }
- virtual ~FactoryForCpp() {
- }
- FSMPtr newFSM(Parser* parser) const;
- ActionPtr newAction(const string& name, int lineno = 0) const;
- GuardPtr newGuard(const string& name, int lineno = 0) const;
- MapPtr newMap(const string& name, int lineno = 0) const;
- ParameterPtr newParameter(const string& name, int lineno = 0) const;
- StatePtr newState(const string& name, int lineno = 0) const;
- EntryPtr newEntry(const string& name, int lineno = 0) const;
- ExitPtr newExit(const string& name, int lineno = 0) const;
- TransitionPtr newTransition(const string& name, int lineno = 0) const;
- VariablePtr newVariable(const string& name, int lineno = 0) const;
- FunctionPtr newFunction(const string& name, int lineno = 0) const;
- LiteralPtr newLiteral(const string& name, int lineno = 0) const;
- ReferencePtr newReference(const VariablePtr variable, int lineno = 0) const;
- ReferencePtr newReference(const LiteralPtr literal, int lineno = 0) const;
- ReferencePtr newReference(const FunctionPtr function, int lineno = 0) const;
- ArgumentPtr newArgument(const string& name, int lineno = 0) const;
- UnaryOperationPtr newUnaryOperation(Poco::FSM::MODEL::Operator op) const;
- BinaryOperationPtr newBinaryOperation(Poco::FSM::MODEL::Operator op) const;
- };
- }
- }
- }
-}
-#endif
diff --git a/FSM/src/cpp/FunctionForCpp.h b/FSM/src/cpp/FunctionForCpp.h
deleted file mode 100644
index 9640b1c6b..000000000
--- a/FSM/src/cpp/FunctionForCpp.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * FunctionForCpp.h
- *
- * Created on: 21 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef FUNCTIONFORCPP_H_
-#define FUNCTIONFORCPP_H_
-
-#include "model/Function.h"
-#include "CompilableForCpp.h"
-#include "ReferenceForCpp.h"
-
-namespace Poco {
- namespace FSM {
- namespace PARSER {
- namespace CPP {
-
- class FunctionForCpp : public FSM::MODEL::Function {
- public:
- FunctionForCpp(const string& name, int lineno = 0) :
- FSM::MODEL::Function(name, lineno) {
- }
- virtual ~FunctionForCpp() {
- }
- const string display(const string& prefix) const;
- };
-
- }
- }
- }
-}
-
-#endif
diff --git a/FSM/src/cpp/GuardForCpp.h b/FSM/src/cpp/GuardForCpp.h
deleted file mode 100644
index edd255776..000000000
--- a/FSM/src/cpp/GuardForCpp.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * GuardForCpp.h
- *
- * Created on: 19 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef POCO_FSM_CPP_GUARD_H_
-#define POCO_FSM_CPP_GUARD_H_
-
-#include "model/Guard.h"
-#include "CompilableForCpp.h"
-
-namespace Poco {
- namespace FSM {
- namespace PARSER {
- namespace CPP {
-
- class GuardForCpp : public CompilableForCpp, public FSM::MODEL::Guard {
- public:
- GuardForCpp(const string& name, int lineno = 0) :
-
- FSM::MODEL::Guard(name, lineno) {
- }
- virtual ~GuardForCpp() {
- }
- virtual void generateInclude(ostream& inc, bool debug) const;
- virtual void generateCode(ostream& cpp, bool debug) const;
- };
-
- }
- }
- }
-}
-
-#endif
diff --git a/FSM/src/cpp/LiteralForCpp.h b/FSM/src/cpp/LiteralForCpp.h
deleted file mode 100644
index 9dbd320c9..000000000
--- a/FSM/src/cpp/LiteralForCpp.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * LiteralForCpp.h
- *
- * Created on: 21 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef LITERALFORCPP_H_
-#define LITERALFORCPP_H_
-
-#include "model/Literal.h"
-#include "CompilableForCpp.h"
-
-namespace Poco {
- namespace FSM {
- namespace PARSER {
- namespace CPP {
-
- class LiteralForCpp : public FSM::MODEL::Literal {
- public:
- LiteralForCpp(const string& name, int lineno = 0) :
- FSM::MODEL::Literal(name, lineno) {
- }
- virtual ~LiteralForCpp() {
- }
- };
-
- }
- }
- }
-}
-
-#endif
diff --git a/FSM/src/cpp/MapForCpp.h b/FSM/src/cpp/MapForCpp.h
deleted file mode 100644
index 7e07683a7..000000000
--- a/FSM/src/cpp/MapForCpp.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * MapForCpp.h
- *
- * Created on: 19 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef POCO_FSM_CPP_MAP_H_
-#define POCO_FSM_CPP_MAP_H_
-
-#include "model/Map.h"
-#include "CompilableForCpp.h"
-
-namespace Poco {
- namespace FSM {
- namespace PARSER {
- namespace CPP {
-
- class MapForCpp : public CompilableForCpp, public FSM::MODEL::Map {
- public:
- MapForCpp(const string& name, int lineno = 0) :
-
- FSM::MODEL::Map(name, lineno) {
- }
- virtual ~MapForCpp() {
- }
- virtual void generateInclude(ostream& inc, bool debug) const;
- virtual void generateCode(ostream& cpp, bool debug) const;
-
- string defaultStateName() const;
- string startStateName() const;
- };
-
- }
- }
- }
-}
-#endif
diff --git a/FSM/src/cpp/ParameterForCpp.h b/FSM/src/cpp/ParameterForCpp.h
deleted file mode 100644
index 50a4927cb..000000000
--- a/FSM/src/cpp/ParameterForCpp.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * ParameterForCpp.h
- *
- * Created on: 19 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef POCO_FSM_CPP_PARAMETER_H_
-#define POCO_FSM_CPP_PARAMETER_H_
-
-#include "model/Parameter.h"
-#include "CompilableForCpp.h"
-
-namespace Poco {
- namespace FSM {
- namespace PARSER {
- namespace CPP {
-
- class ParameterForCpp : public CompilableForCpp, public FSM::MODEL::Parameter {
- public:
- ParameterForCpp(const string& name, int lineno = 0) :
- FSM::MODEL::Parameter(name, lineno) {
- }
- virtual ~ParameterForCpp() {
- }
- virtual void generateInclude(ostream& inc, bool debug) const;
- virtual void generateCode(ostream& cpp, bool debug) const;
- };
-
- }
- }
- }
-}
-#endif
diff --git a/FSM/src/cpp/ReferenceForCpp.h b/FSM/src/cpp/ReferenceForCpp.h
deleted file mode 100644
index 6b7e814be..000000000
--- a/FSM/src/cpp/ReferenceForCpp.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * ReferenceForCpp.h
- *
- * Created on: 24 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef REFERENCEFOCCPP_H_
-#define REFERENCEFOCCPP_H_
-
-#include "model/Reference.h"
-#include "ExpressionForCpp.h"
-#include "ReferenceForCpp.h"
-#include "CompilableForCpp.h"
-#include
-using std::string;
-
-using Poco::FSM::MODEL::VariablePtr;
-using Poco::FSM::MODEL::FunctionPtr;
-using Poco::FSM::MODEL::LiteralPtr;
-using Poco::FSM::MODEL::OperationPtr;
-
-namespace Poco {
- namespace FSM {
- namespace PARSER {
- namespace CPP {
-
- class ReferenceForCpp :
- public ExpressionForCpp,
- public CompilableForCpp,
- public Poco::FSM::MODEL::Reference {
- public:
- ReferenceForCpp(const VariablePtr variable, int lineno = 0):
- Reference(variable, lineno) {
- }
- ReferenceForCpp(const FunctionPtr function, int lineno = 0):
- Reference(function, lineno) {
- }
- ReferenceForCpp(const LiteralPtr literal, int lineno = 0):
- Reference(literal, lineno) {
- }
- virtual ~ReferenceForCpp() {
- }
- virtual void generateInclude(ostream& inc, bool debug) const;
- virtual void generateCode(ostream& cpp, bool debug) const;
- const string display(const string& prefix) const;
- };
-
- }
- }
- }
-}
-
-#endif
diff --git a/FSM/src/cpp/StateForCpp.h b/FSM/src/cpp/StateForCpp.h
deleted file mode 100644
index 2bf0f7ab9..000000000
--- a/FSM/src/cpp/StateForCpp.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * StateForCpp.h
- *
- * Created on: 19 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef POCO_FSM_CPP_STATE_H_
-#define POCO_FSM_CPP_STATE_H_
-
-#include "model/State.h"
-#include "CompilableForCpp.h"
-
-namespace Poco {
- namespace FSM {
- namespace PARSER {
- namespace CPP {
-
- class StateForCpp : public CompilableForCpp, public FSM::MODEL::State {
- public:
- StateForCpp(const string& name, int lineno = 0) :
- FSM::MODEL::State(name, lineno) {
- }
- virtual ~StateForCpp() {
- }
- virtual void generateInclude(ostream& inc, bool debug) const;
- virtual void generateCode(ostream& cpp, bool debug) const;
-
- void generateForwarDeclaration(ostream& inc, bool debug) const;
- void generateVirtualTransitions(ostream& inc, bool debug) const;
- void generateDefinition(ostream& inc, bool debug) const;
- void generateDeclaration(ostream& cpp, int no) const;
-
- private:
- string statename() const;
-
- };
-
- }
- }
- }
-}
-#endif
diff --git a/FSM/src/cpp/TransitionForCpp.h b/FSM/src/cpp/TransitionForCpp.h
deleted file mode 100644
index 06725d2fb..000000000
--- a/FSM/src/cpp/TransitionForCpp.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * TransitionForCpp.h
- *
- * Created on: 19 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef POCO_FSM_CPP_TRANSITION_H_
-#define POCO_FSM_CPP_TRANSITION_H_
-
-#include "model/Transition.h"
-#include "CompilableForCpp.h"
-
-namespace Poco {
- namespace FSM {
- namespace PARSER {
- namespace CPP {
-
- class TransitionForCpp : public CompilableForCpp, public FSM::MODEL::Transition {
- public:
- TransitionForCpp(const string& name, int lineno = 0) :
- FSM::MODEL::Transition(name, lineno) {
- }
- virtual ~TransitionForCpp() {
- }
- virtual const string name() const;
- virtual void generateInclude(ostream& inc, bool debug) const;
- virtual void generateCode(ostream& cpp, bool debug) const;
- void generateVirtualTransitions(ostream& inc, bool debug) const;
- void generateDefinition(ostream& inc, bool debug) const;
- };
-
- }
- }
- }
-}
-#endif
diff --git a/FSM/src/cpp/UnaryOperationForCpp.h b/FSM/src/cpp/UnaryOperationForCpp.h
deleted file mode 100644
index 308e23a05..000000000
--- a/FSM/src/cpp/UnaryOperationForCpp.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * UnaryOperationForCpp.h
- *
- * Created on: 24 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef UNARYOPERATIONFORCPP_H_
-#define UNARYOPERATIONFORCPP_H_
-
-#include "model/UnaryOperation.h"
-#include "ExpressionForCpp.h"
-
-namespace Poco {
- namespace FSM {
- namespace PARSER {
- namespace CPP {
-
- class UnaryOperationForCpp : public ExpressionForCpp, public FSM::MODEL::UnaryOperation {
- public:
- UnaryOperationForCpp(Poco::FSM::MODEL::Operator op) :
- FSM::MODEL::UnaryOperation(op) {
- }
- virtual ~UnaryOperationForCpp() {
- }
- const string display(const string& prefix) const;
- };
-
- }
- }
- }
-}
-
-#endif
diff --git a/FSM/src/cpp/VariableForCpp.h b/FSM/src/cpp/VariableForCpp.h
deleted file mode 100644
index 1c92247b8..000000000
--- a/FSM/src/cpp/VariableForCpp.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * VariableForCpp.h
- *
- * Created on: 21 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef VARIABLEFORCPP_H_
-#define VARIABLEFORCPP_H_
-
-#include "model/Variable.h"
-
-namespace Poco {
- namespace FSM {
- namespace PARSER {
- namespace CPP {
-
- class VariableForCpp : public FSM::MODEL::Variable {
- public:
- VariableForCpp(const string& name, int lineno = 0) :
- FSM::MODEL::Variable(name, lineno) {
- }
- virtual ~VariableForCpp() {
- }
- const string display(const string& prefix) const;
- };
-
- }
- }
- }
-}
-
-#endif
diff --git a/FSM/src/fsmc.cpp b/FSM/src/fsmc.cpp
deleted file mode 100644
index f4ddf0518..000000000
--- a/FSM/src/fsmc.cpp
+++ /dev/null
@@ -1,191 +0,0 @@
-#include
-#include
-#include
-
-using std::cout;
-using std::cerr;
-using std::clog;
-using std::hex;
-using std::endl;
-
-#include "Poco/DateTime.h"
-#include "Poco/DateTimeFormatter.h"
-#include "Poco/Util/LoggingConfigurator.h"
-#include "Poco/Util/PropertyFileConfiguration.h"
-#include "Poco/Exception.h"
-#include "Poco/Thread.h"
-#include "Poco/Util/Application.h"
-#include "Poco/Util/Option.h"
-#include "Poco/Util/OptionSet.h"
-#include "Poco/Util/OptionCallback.h"
-#include "Poco/Util/HelpFormatter.h"
-#include "Poco/Path.h"
-#include "Poco/File.h"
-#include "Poco/FileStream.h"
-#include "model/SMC.h"
-#include "model/FSM.h"
-#include "model/Print.h"
-#include "parser/Parser.h"
-
-using Poco::Thread;
-using Poco::Util::Application;
-using Poco::Util::Option;
-using Poco::Util::OptionSet;
-using Poco::Util::OptionCallback;
-using Poco::Util::HelpFormatter;
-using Poco::Util::LoggingConfigurator;
-using Poco::Util::PropertyFileConfiguration;
-using Poco::Path;
-using Poco::File;
-using Poco::FileStream;
-using Poco::FileInputStream;
-using Poco::FileOutputStream;
-
-using Poco::FSM::PARSER::Parser;
-using Poco::FSM::MODEL::Print;
-
-const static string NL = "\n";
-
-class FFSMompiler: public Application
-{
-public:
- FFSMompiler()
- {
-
- }
-protected:
- void initialize(Application& self)
- {
- loadConfiguration(); // load default configuration files, if present
- Application::initialize(self);
- }
-
- void uninitialize()
- {
- Application::uninitialize();
- }
-
- void reinitialize(Application& self)
- {
- Application::reinitialize(self);
- }
- void defineOptions(OptionSet& options)
- {
- Application::defineOptions(options);
-
- options.addOption(
- Option("help", "h", "display help information on command line arguments")
- .required(false)
- .repeatable(false)
- .callback(OptionCallback(this, &FFSMompiler::handleHelp)));
-
- options.addOption(
- Option("out", "o", "the out directory where to generate the c++ code, defaulted to the fsm file directory")
- .required(false)
- .repeatable(false)
- .argument("file")
- .callback(OptionCallback(this, &FFSMompiler::handleOutdir)));
-
- options.addOption(
- Option("verbose", "v", "output the parsed FSM file on the console")
- .required(false)
- .repeatable(false)
- .callback(OptionCallback(this, &FFSMompiler::handleVerbose)));
-
- options.addOption(
- Option("debug", "d", "generate debug log")
- .required(false)
- .repeatable(false)
- .callback(OptionCallback(this, &FFSMompiler::handleDebug)));
-
- }
-
- void handleHelp(const std::string& name, const std::string& value)
- {
- help = true;
- displayHelp();
- stopOptionsProcessing();
- }
-
- void handleOutdir(const std::string& name, const std::string& value)
- {
- out = Path(value);
- }
- void handleVerbose(const std::string& name, const std::string& value)
- {
- verbose = true;
- }
-
- void handleDebug(const std::string& name, const std::string& value)
- {
- debug = true;
- }
-
- void displayHelp()
- {
- HelpFormatter helpFormatter(options());
- helpFormatter.setCommand(commandName());
- helpFormatter.setUsage(" .sm");
- helpFormatter.setHeader("A FiniteStateMachine compiler for the ISODE++ stack.");
- helpFormatter.format(std::cout);
- }
-
- int main(const std::vector& args)
- {
- Logger& logger = Application::instance().logger();
- if (!help)
- {
- if (args.size() == 0)
- {
- logger.error("Missing .sm file");
- return Application::EXIT_NOINPUT;
- }
- smPath = args[0];
- if (!smPath.isFile())
- {
- logger.error("file %s is not a file", smPath.toString());
- return Application::EXIT_USAGE;
- }
- if (smPath.getExtension() != "sm")
- {
- logger.error("file %s is not a FSM file", smPath.toString());
- return Application::EXIT_USAGE;
- }
- if (!out.isDirectory())
- {
- logger.error("%s is not a directory", out.toString());
- return Application::EXIT_USAGE;
- }
- if (out.depth() <= 0)
- {
- out = smPath;
- out = out.makeParent();
- }
- smFile = File(smPath.makeAbsolute());
- logger.information("fsmc %s", smPath.toString());
-
- FileInputStream fis(smPath.toString());
- Parser parser(logger, smFile, fis);
- FSMPtr fsm;
-
- fsm = parser.parse(out);
- if (fsm && !fsm->updated())
- {
- Print print(logger);
- if (verbose)
- fsm->print(print);
- fsm->generate(out, debug);
- }
- }
- return Application::EXIT_OK;
- }
-
-private:
- bool help = false;
- bool verbose = false;
- bool debug = false;
- Path out;
- Path smPath;
- File smFile;
-};
-POCO_APP_MAIN(FFSMompiler)
diff --git a/FSM/src/model/Action.h b/FSM/src/model/Action.h
deleted file mode 100644
index 721209990..000000000
--- a/FSM/src/model/Action.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Action.h
- *
- * Created on: 16 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef POCO_FSM_MODEL_ACTION_H_
-#define POCO_FSM_MODEL_ACTION_H_
-
-#include "SMC.h"
-#include "Argument.h"
-#include "Element.h"
-
-namespace Poco {
- namespace FSM {
- namespace MODEL {
-
- class Action : public Element {
- private:
- List _arguments;
-
- public:
- Action(const string& name, int lineno = 0) : Element(name, lineno) {
- }
- virtual ~Action() {
- }
- List& arguments() { return _arguments; }
- const List& arguments() const { return _arguments; }
-
- void add(const ArgumentPtr argument) { _arguments.push_back(argument); }
- virtual const string display() const;
- void print(Print& print) const;
- };
-
- }
- }
-}
-#endif
diff --git a/FSM/src/model/Actions.h b/FSM/src/model/Actions.h
deleted file mode 100644
index b980cbcda..000000000
--- a/FSM/src/model/Actions.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Actions.h
- *
- * Created on: 26 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef POCO_FSM_MODEL_ACTIONS_H_
-#define POCO_FSM_MODEL_ACTIONS_H_
-
-#include "Element.h"
-
-namespace Poco {
- namespace FSM {
- namespace MODEL {
-
- class Actions {
- protected:
- List _actions;
- public:
- Actions() {
- }
- virtual ~Actions() {
- }
-
- List& actions() { return _actions; }
- const List& actions() const { return _actions; }
-
- void add(ActionPtr action) { _actions.push_back(action); }
- };
-
- }
- }
-}
-
-#endif
diff --git a/FSM/src/model/Argument.h b/FSM/src/model/Argument.h
deleted file mode 100644
index 6dedbbb7c..000000000
--- a/FSM/src/model/Argument.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Argument.h
- *
- * Created on: 21 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef POCO_FSM_MODEL_ARGUMENT_H_
-#define POCO_FSM_MODEL_ARGUMENT_H_
-
-#include "Element.h"
-
-namespace Poco {
- namespace FSM {
- namespace MODEL {
-
- class Argument : public Element {
- public:
- Argument(const string& name, int lineno = 0) : Element(name, lineno) {
- }
- virtual ~Argument() {
- }
- virtual const string display() const;
- };
-
- }
- }
-}
-
-#endif
diff --git a/FSM/src/model/BinaryOperation.h b/FSM/src/model/BinaryOperation.h
deleted file mode 100644
index 0da131faf..000000000
--- a/FSM/src/model/BinaryOperation.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * BinaryOperation.h
- *
- * Created on: 20 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef POCO_FSM_MODEL_BINARY_OPERATION_H_
-#define POCO_FSM_MODEL_BINARY_OPERATION_H_
-
-#include "Expression.h"
-#include "Operation.h"
-
-namespace Poco {
- namespace FSM {
- namespace MODEL {
-
- class BinaryOperation : public Operation {
- private:
- ExpressionPtr _left;
- ExpressionPtr _right;
-
- public:
- BinaryOperation(Operator op) : Operation(op) {
- }
- virtual ~BinaryOperation() {
- }
- ExpressionPtr& left() { return _left; }
- ExpressionPtr& right() { return _right; }
- const ExpressionPtr left() const { return _left; }
- const ExpressionPtr right()const { return _right; }
- virtual const string display() const;
- };
-
- }
- }
-}
-
-#endif
-
-#if 0
-conditional-expression:
- logical-or-expression
- logical-or-expression ? expression : conditional-expression
-logical-or-expression:
- logical-and-expression
- logical-or-expression || logical-and-expression
-logical-and-expression:
- inclusive-or-expression
- logical-and-expression && inclusive-or-expression
-inclusive-or-expression:
- exclusive-or-expression
- inclusive-or-expression | exclusive-or-expression
-exclusive-or-expression:
- and-expression
- exclusive-or-expression ^ and-expression
-and-expression:
- equality-expression
- and-expression & equality-expression
-equality-expression:
- relational-expression
- equality-expression == relational-expression
- equality-expression != relational-expression
-relational-expression:
- shift-expression
- relational-expression < shift-expression
- relational-expression > shift-expression
- relational-expression <= shift-expression
- relational-expression => shift-expression
-shift-expression:
- additive-expression
- shift-expression << additive-expression
- shift-expression >> additive-expression
-additive-expression:
- multiplicative-expression
- additive-expression + multiplicative-expression
- additive-expression – multiplicative-expression
-multiplicative-expression:
- segment-expression
- multiplicative-expression * segment-expression
- multiplicative-expression / segment-expression
- multiplicative-expression % segment-expression
-segment-expression:
- pm-expression
- segment-expression :> pm-expression
-pm-expression:
- cast-expression
- pm-expression .* cast-expression
- pm-expression –>* cast-expression
-cast-expression:
- unary-expression
- ( type-name ) cast-expression
-unary-expression:
- postfix-expression
- ++ unary-expression
- –– unary-expression
- unary-operator cast-expression
- sizeof unary-expression
- sizeof ( type-name )
- allocation-expression
- deallocation-expression
-unary-operator: one of
- * & + – ! ~
-#endif
diff --git a/FSM/src/model/Compilable.h b/FSM/src/model/Compilable.h
deleted file mode 100644
index 24ba0819f..000000000
--- a/FSM/src/model/Compilable.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Compilable.h
- *
- * Created on: 22 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef POCO_FSM_MODEL_COMPILABLE_H_
-#define POCO_FSM_MODEL_COMPILABLE_H_
-
-#include "Poco/Path.h"
-using Poco::Path;
-
-
-#include "SMC.h"
-
-namespace Poco {
- namespace FSM {
- namespace MODEL {
-
- class Compilable {
-
- public:
- virtual void generate(const Path& out, bool debug) const = 0;
- };
-
- }
- }
-}
-
-#endif
diff --git a/FSM/src/model/Dumper.h b/FSM/src/model/Dumper.h
deleted file mode 100644
index e84fb8fe0..000000000
--- a/FSM/src/model/Dumper.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Dumper.h
- *
- * Created on: 8 févr. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef POCO_FSM_MODEL_DUMPER_H_
-#define POCO_FSM_MODEL_DUMPER_H_
-
-#include
-using std::string;
-
-#include "FSM.h"
-using Poco::FSM::MODEL::TransitionPtr;
-using Poco::FSM::MODEL::GuardPtr;
-
-namespace Poco {
-namespace FSM {
-namespace MODEL {
-
-class Dumper {
-public:
- virtual void operator()(const char* message) = 0;
- virtual void operator()(const string& message) = 0;
- virtual void operator()(const TransitionPtr transition, const GuardPtr guard) = 0;
-};
-
-}
-}
-}
-
-#endif
diff --git a/FSM/src/model/Element.h b/FSM/src/model/Element.h
deleted file mode 100644
index fe5c77ab4..000000000
--- a/FSM/src/model/Element.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Element.h
- *
- * Created on: 16 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef POCO_FSM_MODEL_ELEMENT_H_
-#define POCO_FSM_MODEL_ELEMENT_H_
-
-#include "SMC.h"
-
-namespace Poco {
- namespace FSM {
- namespace MODEL {
-
- class Element {
- private:
- string _name; // An element has a unique name.
- int _lineno;
-
- protected:
- mutable string oneline;
-
- public:
- Element(int lineno = 0) : _lineno(lineno) {
- }
- Element(const string& name, int lineno = 0) : _name(name), _lineno(lineno) {
- }
- virtual ~Element() {
- }
-
- virtual const string name() const { return _name; }
- const int lineno() const { return _lineno; }
-
- virtual const string display() const = 0;
- };
-
- }
- }
-}
-#endif
diff --git a/FSM/src/model/Entry.h b/FSM/src/model/Entry.h
deleted file mode 100644
index 99458d161..000000000
--- a/FSM/src/model/Entry.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Entry.h
- *
- * Created on: 26 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef POCO_FSM_MODEL_ENTRY_H_
-#define POCO_FSM_MODEL_ENTRY_H_
-
-#include "Element.h"
-#include "Actions.h"
-
-namespace Poco {
- namespace FSM {
- namespace MODEL {
-
- class Entry : public Actions, public Element {
- public:
- Entry(const string& name, int lineno = 0) : Element(name, lineno) {
- }
- virtual ~Entry() {
- }
- virtual const string display() const;
- void print(Print& print) const;
- };
- }
- }
-}
-#endif
diff --git a/FSM/src/model/Exit.h b/FSM/src/model/Exit.h
deleted file mode 100644
index 0568c4e39..000000000
--- a/FSM/src/model/Exit.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Exit.h
- *
- * Created on: 26 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef POCO_FSM_MODEL_EXIT_H_
-#define POCO_FSM_MODEL_EXIT_H_
-
-#include "Print.h"
-#include "Element.h"
-#include "Actions.h"
-
-namespace Poco {
-namespace FSM {
-namespace MODEL {
-
- class Exit : public Actions, public Element {
- public:
- Exit(const string& name, int lineno = 0) : Element(name, lineno) {
- }
- virtual ~Exit() {
- }
- virtual const string display() const;
- void print(Print& print) const;
- };
-
-}
-}
-}
-
-#endif
diff --git a/FSM/src/model/Expression.h b/FSM/src/model/Expression.h
deleted file mode 100644
index d71800fd5..000000000
--- a/FSM/src/model/Expression.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Expression.h
- *
- * Created on: 21 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef POCO_FSM_MODEL_EXPRESSION_H_
-#define POCO_FSM_MODEL_EXPRESSION_H_
-
-#include "SMC.h"
-
-namespace Poco {
- namespace FSM {
- namespace MODEL {
-
- class Expression {
- protected:
- OperationPtr _operation = NULL;
- mutable string _asstring;
- GuardPtr _guard = NULL;
-
- public:
- Expression() {
- }
- virtual ~Expression() {
- }
- GuardPtr& guard() { return _guard; }
- const GuardPtr guard() const { return _guard; }
-
- virtual const string display() const = 0;
- OperationPtr& operation() { return _operation; }
- const OperationPtr& operation() const { return _operation; }
- };
-
- }
- }
-}
-#endif
diff --git a/FSM/src/model/FSM.h b/FSM/src/model/FSM.h
deleted file mode 100644
index 21f87fd29..000000000
--- a/FSM/src/model/FSM.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * FSM.h
- *
- * Created on: 16 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef POCO_FSM_MODEL_FSM_H_
-#define POCO_FSM_MODEL_FSM_H_
-#include "Poco/FileStream.h"
-#include "Poco/Path.h"
-using Poco::Path;
-
-#include "SMC.h"
-#include "Compilable.h"
-
-namespace Poco {
- namespace FSM {
- namespace PARSER {
- class Parser;
- }
- }
-}
-using Poco::FSM::PARSER::Parser;
-
-namespace Poco {
- namespace FSM {
- namespace MODEL {
-
- class FSM : public Compilable {
- public:
- FSM(PARSER::Parser* parser) : Compilable(), _parser(parser) {
- }
- virtual ~FSM() {
- }
-
-
- void setcontext() { _context = _fsmClass + "<" + _klass + ">"; }
- string& startState() { return _startState; }
- string& source() { return _source; }
-// string& context() { return _fsmClass; }
- string& fsmfile() { return _fsmFile; }
- string& fsmclass() { return _fsmClass; }
- string& klass() { return _klass; }
- string& header() { return _header; }
- string& returnt() { return _return; }
- List& packages() { return _packages; }
- List& includes() { return _includes; }
- List& imports() { return _imports; }
- List& declares() { return _declares; }
- bool& updated() { return _updated; }
- Parser* parser() const { return _parser; }
-
- const string& startState() const { return _startState; }
- const string& context()const { return _context; }
- const string& fsmfile()const { return _fsmFile; }
- const string& fsmclass()const { return _fsmClass; }
- const string& klass()const { return _klass; }
- const string& header()const { return _header; }
- const List& packages()const { return _packages; }
- const List& includes()const { return _includes; }
- const List& imports()const { return _imports; }
- const List& declares()const { return _declares; }
- const List& maps()const { return _maps; }
- bool updated() const { return _updated; }
-
- void add(MapPtr map);
- void addPackage(const string& package);
- void addImport(const string& import);
- void addInclude(const string& inc);
- void addDeclare(const string& declare);
- void print(Print& print) const;
-
- virtual bool updated(const Path& out) = 0;
-
- protected:
- Parser* _parser = nullptr;
-
- // The state map's initial state.
- string _startState;
-
- // Raw source code appearing at the beginning of the state
- // map source file.
- string _source;
-
- // This state map is associated with this class.
- string _context;
- string _fsmClass;
-
- // generated finite state machine class file name.
- string _fsmFile;
-
- // This map is implemented in the class with given name
- string _klass;
-
- // Where the associated class is defined.
- string _header;
-
- // For C++ only. List of include files. Will be output to
- // the .cpp file in the same order as they appear in the
- // .sm file.
- List _includes;
-
- // This code is placed in this package/namespace.
- List _packages;
-
- // Place names of imports in this list.
- List _imports;
-
- // Place forward declarations in this list.
- List _declares;
-
- // The context class access level. Empty string by default.
- string _accessLevel;
-
- // The line where %start, etc. should appear.
- // Used in error messages.
- int _headerLine;
-
- // The state maps.
- List _maps;
-
- string _return;
-
- bool _updated = false;
-
- };
-
- }
- }
-}
-#endif
diff --git a/FSM/src/model/Factory.h b/FSM/src/model/Factory.h
deleted file mode 100644
index ecb39d7e5..000000000
--- a/FSM/src/model/Factory.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Factory.h
- *
- * Created on: 26 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef POCO_FSM_MODEL_FACTORY_H_
-#define POCO_FSM_MODEL_FACTORY_H_
-
-#include "SMC.h"
-#include "Operation.h"
-
-using Poco::FSM::MODEL::ActionPtr;
-using Poco::FSM::MODEL::FSMPtr;
-using Poco::FSM::MODEL::GuardPtr;
-using Poco::FSM::MODEL::MapPtr;
-using Poco::FSM::MODEL::ParameterPtr;
-using Poco::FSM::MODEL::StatePtr;
-using Poco::FSM::MODEL::EntryPtr;
-using Poco::FSM::MODEL::ExitPtr;
-using Poco::FSM::MODEL::TransitionPtr;
-using Poco::FSM::MODEL::ExpressionPtr;
-using Poco::FSM::MODEL::ReferencePtr;
-using Poco::FSM::MODEL::VariablePtr;
-using Poco::FSM::MODEL::FunctionPtr;
-using Poco::FSM::MODEL::LiteralPtr;
-using Poco::FSM::MODEL::ArgumentPtr;
-using Poco::FSM::MODEL::OperationPtr;
-using Poco::FSM::MODEL::UnaryOperationPtr;
-using Poco::FSM::MODEL::BinaryOperationPtr;
-
-namespace Poco {
- namespace FSM {
- namespace MODEL {
-
- class Factory {
- public:
- Factory() {
- }
- virtual ~Factory() {
- }
- virtual FSMPtr newFSM(Parser* parser) const = 0;
- virtual ActionPtr newAction(const string& name, int lineno = 0) const = 0;
- virtual GuardPtr newGuard(const string& name, int lineno = 0) const = 0;
- virtual MapPtr newMap(const string& name, int lineno = 0) const = 0;
- virtual ParameterPtr newParameter(const string& name, int lineno = 0) const = 0;
- virtual StatePtr newState(const string& name, int lineno = 0) const = 0;
- virtual EntryPtr newEntry(const string& name, int lineno = 0) const = 0;
- virtual ExitPtr newExit(const string& name, int lineno = 0) const = 0;
- virtual TransitionPtr newTransition(const string& name, int lineno = 0) const = 0;
- virtual VariablePtr newVariable(const string& name, int lineno = 0) const = 0;
- virtual FunctionPtr newFunction(const string& name, int lineno = 0) const = 0;
- virtual LiteralPtr newLiteral(const string& name, int lineno = 0) const = 0;
- virtual ReferencePtr newReference(const VariablePtr variable, int lineno = 0) const = 0;
- virtual ReferencePtr newReference(const LiteralPtr literal, int lineno = 0) const = 0;
- virtual ReferencePtr newReference(const FunctionPtr function, int lineno = 0) const = 0;
- virtual ArgumentPtr newArgument(const string& name, int lineno = 0) const = 0;
- virtual UnaryOperationPtr newUnaryOperation(Operator op) const = 0;
- virtual BinaryOperationPtr newBinaryOperation(Operator op) const = 0;
- };
- }
- }
-}
-
-#endif
diff --git a/FSM/src/model/Function.h b/FSM/src/model/Function.h
deleted file mode 100644
index 432783f6d..000000000
--- a/FSM/src/model/Function.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Function.h
- *
- * Created on: 21 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef POCO_FSM_MODEL_FUNCTION_H_
-#define POCO_FSM_MODEL_FUNCTION_H_
-
-#include "SMC.h"
-#include "Expression.h"
-#include "Element.h"
-
-namespace Poco {
- namespace FSM {
- namespace MODEL {
-
- class Function : public Element {
- private:
- List _arguments;
-
- public:
- Function(const string& name, int lineno = 0) : Element(name, lineno) {
- }
- virtual ~Function() {
- }
- List& arguments() { return _arguments; }
- const List& arguments() const { return _arguments; }
-
- void add(const ArgumentPtr argument) { _arguments.push_back(argument); }
- virtual const string display() const;
- };
-
- }
- }
-}
-#endif
diff --git a/FSM/src/model/Guard.h b/FSM/src/model/Guard.h
deleted file mode 100644
index 0022a296b..000000000
--- a/FSM/src/model/Guard.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Guard.h
- *
- * Created on: 16 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef POCO_FSM_MODEL_GUARD_H_
-#define POCO_FSM_MODEL_GUARD_H_
-
-#include "SMC.h"
-#include "Element.h"
-
-namespace Poco {
- namespace FSM {
- namespace MODEL {
- enum TransType
- {
- /**
- * Transitions may be instantiated before all information
- * is gathered. This is the default transition type.
- */
- TRANS_NOT_SET,
-
- /**
- * A standard transition which goes from one state to the
- * next.
- */
- TRANS_SET,
-
- /**
- * This transition pushes the current state on top of the
- * state stack before setting the next state. The previous
- * state may be restored using a pop transition. A push
- * transtion may be used in conjunction with a set
- * transition. In that case the specified next state is
- * pushed on top of the state stack and not the current
- * state.
- */
- TRANS_PUSH,
-
- /**
- * Pop the state off the state stack and make it the next
- * state.
- */
- TRANS_POP
- }; // end of enum TransType
-
- class Guard : public Element {
- private:
- TransitionPtr _transition = nullptr;
- ExpressionPtr _condition = nullptr;
- TransType _transType;
- StatePtr _endstate = nullptr;
- StatePtr _pushState = nullptr;
- StatePtr _popArgs = nullptr;
- List _actions;
-
- public:
- Guard(const string& name, int lineno = 0) : Element(name, lineno) {
- }
- virtual ~Guard() {
- }
-
- TransitionPtr& transition() { return _transition; }
- ExpressionPtr& condition() { return _condition; }
- StatePtr& endstate() { return _endstate; }
- StatePtr& pushState() { return _pushState; }
- StatePtr& popArgs() { return _popArgs; }
- List& actions() { return _actions; }
-
- const TransitionPtr& transition()const { return _transition; }
- const ExpressionPtr& condition()const { return _condition; }
- const StatePtr& endstate()const { return _endstate; }
- const StatePtr& pushState()const { return _pushState; }
- const StatePtr& popArgs()const { return _popArgs; }
- const List& actions() const { return _actions; }
-
- void add(ActionPtr action) { _actions.push_back(action); }
-
- virtual const string display() const;
- };
-
- }
- }
-}
-#endif
diff --git a/FSM/src/model/Literal.h b/FSM/src/model/Literal.h
deleted file mode 100644
index 15983818b..000000000
--- a/FSM/src/model/Literal.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Literal.h
- *
- * Created on: 21 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef POCO_FSM_MODEL_LITERAL_H_
-#define POCO_FSM_MODEL_LITERAL_H_
-
-#include "SMC.h"
-#include "Expression.h"
-#include "Element.h"
-
-namespace Poco {
- namespace FSM {
- namespace MODEL {
-
- class Literal : public Element {
- public:
- Literal(const string& name, int lineno = 0) : Element(name, lineno) {
- }
- virtual ~Literal() {
- }
- virtual const string display() const;
- virtual const string display(const string& prefix) const;
- };
-
- }
- }
-}
-#endif
diff --git a/FSM/src/model/Map.h b/FSM/src/model/Map.h
deleted file mode 100644
index 4dfe164e0..000000000
--- a/FSM/src/model/Map.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Map.h
- *
- * Created on: 16 janv. 2016
- * Author: FrancisANDRE
- */
-
-#ifndef POCO_FSM_MODEL_MAP_H_
-#define POCO_FSM_MODEL_MAP_H_
-
-#include