Skip to content

Commit

Permalink
quilt.cpp: remove type based containers
Browse files Browse the repository at this point in the history
- add a map of type index to formatters.
  • Loading branch information
mcraveiro committed Sep 22, 2016
1 parent aee55fa commit 5ed6f9a
Show file tree
Hide file tree
Showing 14 changed files with 265 additions and 374 deletions.
55 changes: 33 additions & 22 deletions doc/agile/sprint_backlog_88.org
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,48 @@
** Active

#+begin: clocktable :maxlevel 3 :scope subtree :indent nil :emphasize nil :scope file :narrow 75 :formula %
#+CAPTION: Clock summary at [2016-09-22 Thu 11:40]
#+CAPTION: Clock summary at [2016-09-22 Thu 14:23]
| <75> | | | | |
| Headline | Time | | | % |
|-----------------------------------------------------------------------------+---------+-------+-------+-------|
| *Total time* | *64:27* | | | 100.0 |
| *Total time* | *66:29* | | | 100.0 |
|-----------------------------------------------------------------------------+---------+-------+-------+-------|
| Stories | 64:27 | | | 100.0 |
| Active | | 64:27 | | 100.0 |
| STARTED Sprint and product backlog grooming | | | 3:53 | 6.0 |
| Stories | 66:29 | | | 100.0 |
| Active | | 66:29 | | 100.0 |
| STARTED Sprint and product backlog grooming | | | 3:53 | 5.8 |
| COMPLETED Fix chocolatey warning | | | 0:08 | 0.2 |
| COMPLETED Edit release notes for previous sprint | | | 0:27 | 0.7 |
| COMPLETED Analysis on current state of file path generation | | | 0:57 | 1.5 |
| COMPLETED Analysis on current state of file path generation | | | 0:57 | 1.4 |
| CANCELLED Remove inclusion dependencies builder factory | | | 0:14 | 0.4 |
| COMPLETED Analysis on formatters, elements and extensibility | | | 1:18 | 2.0 |
| COMPLETED Refactor =inclusion_dependencies_provider_interface= | | | 1:12 | 1.9 |
| COMPLETED Refactor =inclusion_dependencies_provider_interface= | | | 1:12 | 1.8 |
| COMPLETED Investigate broken windows builds | | | 0:32 | 0.8 |
| COMPLETED Refactor path derivatives factory for usage in formatters | | | 5:14 | 8.1 |
| COMPLETED Move file path generation to formatters | | | 1:58 | 3.1 |
| CANCELLED Path derivatives factory generates all possible includes | | | 3:07 | 4.8 |
| COMPLETED Analysis on inclusion derivatives and path derivatives | | | 1:04 | 1.7 |
| COMPLETED Split path factory from provider factory | | | 2:32 | 3.9 |
| COMPLETED Use providers when building inclusion directives | | | 12:01 | 18.6 |
| COMPLETED Refactor path derivatives factory for usage in formatters | | | 5:14 | 7.9 |
| COMPLETED Move file path generation to formatters | | | 1:58 | 3.0 |
| CANCELLED Path derivatives factory generates all possible includes | | | 3:07 | 4.7 |
| COMPLETED Analysis on inclusion derivatives and path derivatives | | | 1:04 | 1.6 |
| COMPLETED Split path factory from provider factory | | | 2:32 | 3.8 |
| COMPLETED Use providers when building inclusion directives | | | 12:01 | 18.1 |
| COMPLETED Fix AppVeyor notifications | | | 0:22 | 0.6 |
| COMPLETED Static use of element types does more harm than good | | | 0:32 | 0.8 |
| COMPLETED Analysis: major rethink of the implementation of quilt | | | 1:30 | 2.3 |
| CANCELLED Create a simple Emacs mode for stitch | | | 1:12 | 1.9 |
| COMPLETED Add facet folder and formatter enablement to formatter properties | | | 2:52 | 4.4 |
| COMPLETED Move =cmakelists_info= to fabric | | | 6:34 | 10.2 |
| COMPLETED Move =odb_options_info= to fabric | | | 1:29 | 2.3 |
| CANCELLED Create a simple Emacs mode for stitch | | | 1:12 | 1.8 |
| COMPLETED Add facet folder and formatter enablement to formatter properties | | | 2:52 | 4.3 |
| COMPLETED Move =cmakelists_info= to fabric | | | 6:34 | 9.9 |
| COMPLETED Move =odb_options_info= to fabric | | | 1:29 | 2.2 |
| COMPLETED Remove =formattable_origin_type= | | | 0:17 | 0.4 |
| COMPLETED Remove formattable origin type | | | 2:25 | 3.7 |
| COMPLETED Remove formattable origin type | | | 2:25 | 3.6 |
| COMPLETED Rename config model to options | | | 1:07 | 1.7 |
| COMPLETED Rename annotation to decoration in formatters model | | | 0:30 | 0.8 |
| COMPLETED Fix appveyor Visual Studio build | | | 1:04 | 1.7 |
| COMPLETED Big rename for "final" terminology clean up | | | 2:19 | 3.6 |
| COMPLETED Tidy-up file configuration in formatters | | | 3:03 | 4.7 |
| COMPLETED Fix appveyor Visual Studio build | | | 1:04 | 1.6 |
| COMPLETED Big rename for "final" terminology clean up | | | 2:19 | 3.5 |
| COMPLETED Tidy-up file configuration in formatters | | | 3:03 | 4.6 |
| COMPLETED Stitch still uses "properties" | | | 0:27 | 0.7 |
| CANCELLED Add a stitch prefix to stitch fields | | | 0:03 | 0.1 |
| COMPLETED Formatter properties are not optional in assistant | | | 0:10 | 0.3 |
| COMPLETED Consider removing the overwrite flag in =formatters::file= | | | 0:22 | 0.6 |
| STARTED Add type index to name and to formatter interface | | | 3:32 | 5.5 |
| COMPLETED Handle module generability in yarn | | | 0:20 | 0.5 |
| STARTED Add type index to name and to formatter interface | | | 5:14 | 7.9 |
#+TBLFM: $5='(org-clock-time% @3$2 $2..$4);%.1f
#+end:

Expand Down Expand Up @@ -1017,7 +1018,17 @@ For now we have abused this flag to allow legacy files overrides of
the new world formatters. This is just until we move totally to new
world though.

*** COMPLETED Handle module generability in yarn :story:
CLOSED: [2016-09-22 Thu 13:34]
CLOCK: [2016-09-22 Thu 13:14]--[2016-09-22 Thu 13:34] => 0:20

At present we are filtering out modules in =quilt.cpp= just as we are
about to format them. It probably makes more sense to update the
generability in yarn.

*** STARTED Add type index to name and to formatter interface :story:
CLOCK: [2016-09-22 Thu 13:34]--[2016-09-22 Thu 14:23] => 0:49
CLOCK: [2016-09-22 Thu 12:20]--[2016-09-22 Thu 13:13] => 0:53
CLOCK: [2016-09-22 Thu 09:01]--[2016-09-22 Thu 11:40] => 2:39
CLOCK: [2016-09-21 Wed 09:16]--[2016-09-21 Wed 09:31] => 0:15
CLOCK: [2016-09-21 Wed 09:01]--[2016-09-21 Wed 09:15] => 0:14
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,75 +45,50 @@ class container final {
private:
friend class registrar;

public:
/**
* @brief Returns all available object formatters.
*/
const std::forward_list<std::shared_ptr<file_formatter_interface>>&
object_formatters() const;

/**
* @brief Returns all available enumeration formatters.
*/
const std::forward_list<std::shared_ptr<file_formatter_interface>>&
enumeration_formatters() const;

/**
* @brief Returns all available exception formatters.
*/
const std::forward_list<std::shared_ptr<file_formatter_interface>>&
exception_formatters() const;

/**
* @brief Returns all available module formatters.
*/
const std::forward_list<std::shared_ptr<file_formatter_interface>>&
module_formatters() const;

private:
/**
* @brief Returns all available namespace formatters.
* @brief Returns all available file formatters by type indx.
*/
const std::forward_list<std::shared_ptr<file_formatter_interface>>&
visitor_formatters() const;
std::unordered_map<
std::type_index,
std::forward_list<std::shared_ptr<file_formatter_interface>>>&
file_formatters_by_type_index();

/**
* @brief Returns all available forward declarations formatters.
* @brief Returns all available file formatters.
*/
const std::forward_list<std::shared_ptr<file_formatter_interface>>&
forward_declarations_formatters() const;
std::forward_list<std::shared_ptr<file_formatter_interface>>&
file_formatters();

/**
* @brief Returns all available odb options formatters.
*/
const std::forward_list<std::shared_ptr<file_formatter_interface>>&
odb_options_formatters() const;

/**
* @brief Returns all available CMakeLists formatters.
* @brief Returns all available helpers.
*/
const std::forward_list<std::shared_ptr<file_formatter_interface>>&
cmakelists_formatters() const;
std::unordered_map<
std::string,
std::unordered_map<std::string,
std::list<
std::shared_ptr<helper_formatter_interface>>>>&
helper_formatters();

public:
/**
* @brief Returns all available registrar formatters.
* @brief Returns all available file formatters by type indx.
*/
const std::forward_list<std::shared_ptr<file_formatter_interface>>&
registrar_formatters() const;
const std::unordered_map<
std::type_index,
std::forward_list<std::shared_ptr<file_formatter_interface>>>&
file_formatters_by_type_index() const;

/**
* @brief Returns all available master header formatters.
* @brief Returns all available file formatters.
*/
const std::forward_list<std::shared_ptr<file_formatter_interface>>&
master_header_formatters() const;
file_formatters() const;

public:
/**
* @brief Returns all available file formatters.
* @brief Returns all available helpers.
*/
const std::forward_list<std::shared_ptr<file_formatter_interface>>&
all_file_formatters() const;

public:
const std::unordered_map<
std::string,
std::unordered_map<std::string,
Expand All @@ -122,34 +97,18 @@ class container final {
helper_formatters() const;

private:
std::unordered_map<
std::type_index,
std::forward_list<std::shared_ptr<file_formatter_interface>>>
file_formatters_by_type_index_;
std::forward_list<std::shared_ptr<file_formatter_interface>>
object_formatters_;
std::forward_list<std::shared_ptr<file_formatter_interface>>
enumeration_formatters_;
std::forward_list<std::shared_ptr<file_formatter_interface>>
exception_formatters_;
std::forward_list<std::shared_ptr<file_formatter_interface>>
module_formatters_;
std::forward_list<std::shared_ptr<file_formatter_interface>>
visitor_formatters_;
std::forward_list<std::shared_ptr<file_formatter_interface>>
forward_declarations_formatters_;
std::forward_list<std::shared_ptr<file_formatter_interface>>
odb_options_formatters_;
std::forward_list<std::shared_ptr<file_formatter_interface>>
cmakelists_formatters_;
std::forward_list<std::shared_ptr<file_formatter_interface>>
registrar_formatters_;
std::forward_list<std::shared_ptr<file_formatter_interface>>
master_header_formatters_;
std::forward_list<std::shared_ptr<file_formatter_interface>>
all_file_formatters_;
file_formatters_;
std::unordered_map<
std::string,
std::unordered_map<std::string,
std::list<
std::shared_ptr<helper_formatter_interface>>>>
helper_formatters_;
helper_formatters_;
};

} } } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <forward_list>
#include "dogen/formatters/types/file.hpp"
#include "dogen/quilt.cpp/types/formatters/container.hpp"
#include "dogen/quilt.cpp/types/formatters/file_formatter_interface.hpp"
#include "dogen/quilt.cpp/types/formatters/context_factory.hpp"

namespace dogen {
Expand All @@ -39,6 +40,11 @@ class element_formatter final {
public:
element_formatter(const context_factory& f, const container& c);

private:
std::forward_list<dogen::formatters::file> format(
const std::forward_list<std::shared_ptr<file_formatter_interface>>&
formatters, const yarn::element& e) const;

public:
std::forward_list<dogen::formatters::file>
format(const yarn::element& e) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ class registrar final {
*/
void validate() const;

private:
/**
* @brief Perform common registration.
*/
void common_registration(
std::shared_ptr<formatters::file_formatter_interface> f);

public:
void register_formatter_helper(
std::shared_ptr<helper_formatter_interface> fh);
Expand Down
32 changes: 20 additions & 12 deletions projects/quilt.cpp/src/io/formatters/container_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,30 @@ inline std::ostream& to_stream(std::ostream& s,
return s;
}

inline std::ostream& to_stream(std::ostream& s,
const std::unordered_map<std::type_index,
std::forward_list<std::shared_ptr<file_formatter_interface>>>& ffti) {
s << "\"file_formatters_by_type_index\": " << "[ ";

for(auto i(ffti.begin()); i != ffti.end(); ++i) {
if (i != ffti.begin()) s << ", ";
s << "{ \"" << i->first.name() << "\":" << "[ ";
for(auto j(i->second.begin()); j != i->second.end(); ++j) {
if (j != i->second.begin()) s << ", ";
s << "\"" << (*j)->id() << "\"";
}
s << "] }";
}
s << "], ";
return s;
}


std::ostream& operator<<(std::ostream& s, const container& c) {
s << "{ " << "\"__type__\": "
<< "\"dogen::quilt::cpp::formatters::container\", ";
to_stream(s, "object_formatters", c.object_formatters());
to_stream(s, "enumeration_formatters", c.enumeration_formatters());
to_stream(s, "exception_formatters", c.exception_formatters());
to_stream(s, "module_formatters", c.module_formatters());
to_stream(s, "visitor_formatters", c.visitor_formatters());
to_stream(s, "odb_options_formatters", c.odb_options_formatters());
to_stream(s, "cmakelists_formatters", c.cmakelists_formatters());
to_stream(s, "registrar_formatters", c.registrar_formatters());
to_stream(s, "master_header_formatters", c.master_header_formatters());
to_stream(s, "forward_declarations_formatters",
c.forward_declarations_formatters());
to_stream(s, "all_file_formatters", c.all_file_formatters());
to_stream(s, c.file_formatters_by_type_index());
to_stream(s, "all_file_formatters", c.file_formatters());
to_stream(s, c.helper_formatters());
s << " }";
return s;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ make_field_definitions(const dynamic::repository& rp,
const formatters::container& fc) const {
std::unordered_map<std::string, field_definitions> r;

for (const auto f : fc.all_file_formatters()) {
for (const auto f : fc.file_formatters()) {
const auto& oh(f->ownership_hierarchy());
const auto fn(oh.formatter_name());

Expand Down
Loading

0 comments on commit 5ed6f9a

Please sign in to comment.