yasmine
json_writer.hpp
Go to the documentation of this file.
1 // //
3 // This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). //
4 // Copyright (C) 2016-2017 Seadex GmbH //
5 // //
6 // Licensing information is available in the folder "license" which is part of this distribution. //
7 // The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. //
8 // //
10 
11 #ifndef JSON_WRITER_F29233A0_535E_4285_AE04_E0E163819CB2
12 #define JSON_WRITER_F29233A0_535E_4285_AE04_E0E163819CB2
13 
14 
15 #include <vector>
16 
17 #define RAPIDJSON_NO_SIZETYPEDEFINE
18 
19 
20 namespace rapidjson
21 {
22 
23 
24 typedef std::size_t SizeType;
25 
26 
27 }
28 
29 #include <document.h>
30 
31 #include "state_machine_model.hpp"
32 
33 
34 namespace sxy
35 {
36 
37 
38 namespace model
39 {
40 
41 
42 class state_machine_element_model;
43 class transition_model_impl;
44 class simple_state_model;
45 class pseudostate_model_impl;
46 class pseudostate_model;
47 class region_model;
48 class composite_state_model;
49 class final_state_model;
50 
51 
52 }
53 
54 
57 class json_writer SX_FINAL
58 {
59 public:
63  json_writer( const std::string & _json_file_name, const model::state_machine_model &_state_machine_model );
64  ~json_writer() SX_NOEXCEPT;
65  SX_NO_COPY( json_writer )
66 
67 
68 private:
69  void write_json_to_file( const std::string& _json_file, const model::state_machine_model& _state_machine_model );
70  // cppcheck-suppress unusedPrivateFunction
71  static void write_text_to_file( const char* _json_char, const std::string& _json_file );
72  static void add_version( rapidjson::Value& _document, rapidjson::MemoryPoolAllocator< >& _allocator );
73  static void add_events_from_model( const model::state_machine_model& _state_machine_model,
74  rapidjson::Value& _events, rapidjson::MemoryPoolAllocator< >& _allocator );
75  // cppcheck-suppress unusedPrivateFunction
76  static void add_transitions_from_model( const model::state_machine_model& _state_machine_model,
77  rapidjson::Value& _transitions, rapidjson::MemoryPoolAllocator< >& _allocator );
78  static void add_regions_from_model( const model::composite_state_model& _composite_state_model,
79  rapidjson::Value& _regions, rapidjson::MemoryPoolAllocator< >& _allocator );
80  static void fill_region_object( const model::region_model& _region_model, rapidjson::Value& _region,
81  rapidjson::MemoryPoolAllocator< >& _allocator );
82  static void fill_pseudostate_object( const model::pseudostate_model& _pseudostate_model, rapidjson::Value& _pseudostate,
83  rapidjson::MemoryPoolAllocator< >& _allocator );
84  static void fill_simple_state_object( const model::simple_state_model& _simple_state_model, rapidjson::Value& _simple_state,
85  rapidjson::MemoryPoolAllocator< >& _allocator );
86  static void fill_composite_state_object( const model::composite_state_model& _composite_state_model,
87  rapidjson::Value& _composite_state, rapidjson::MemoryPoolAllocator< >& _allocator );
88  static void fill_final_state_object( const model::final_state_model& _final_state_model,
89  rapidjson::Value& _final_state, rapidjson::MemoryPoolAllocator< >& _allocator );
90  static void add_state_pseudostates_from_model( const model::composite_state_model& _composite_state_model,
91  rapidjson::Value& _state_pseudostates, rapidjson::MemoryPoolAllocator< >& _allocator );
92  static rapidjson::Value& create_rapidjson_string_value( const std::string& _string,
93  rapidjson::Value& _json_string_value );
94  static void fill_base_info( rapidjson::Value& _json_val, const model::state_machine_element_model& _element,
95  rapidjson::MemoryPoolAllocator< >& _allocator );
96  static const std::string get_event_name_by_id( const sxy::model::event_id& _event_id,
97  const model::state_machine_model& _state_machine_model );
98 };
99 
100 
101 }
102 
103 
104 #endif
sxe::uint32_t event_id
The type alias for yasmine model&#39;s event IDs.
Definition: event_model_id.hpp:29
std::size_t SizeType
Definition: json_writer.hpp:24
Definition: algorithm_parameters.hpp:16
Provides the ability to write a model to a file.
Definition: json_writer.hpp:20