summaryrefslogtreecommitdiff
path: root/TAO/CIAO/CIDLC/ServantGenerator.hpp
blob: 79ef0a0eab0977f51710a2ecae9e3395f4699e27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// $Id$
#ifndef SERVANT_GENERATOR_HPP
#define SERVANT_GENERATOR_HPP

#include "CCF/CodeGenerationKit/CommandLine.hpp"

#include "CCF/CIDL/CIDL_SyntaxTree.hpp"
#include "CCF/CIDL/CIDL_Traversal.hpp"

using namespace std;

using namespace CIDL;
using namespace CIDL::SyntaxTree;

// ProvidesCollector collects interfaces that appear in provides
// declaration of a component in question. Used as a building block
// by Collector.
//
class ProvidesCollector : public virtual Traversal::ComponentDef,
                          public virtual Traversal::ProvidesDecl
{
public:
  ProvidesCollector (UnconstrainedInterfaceDefSet& interface_set);

  virtual void
  visit_provides_decl (ProvidesDeclPtr const& p);

private:
  UnconstrainedInterfaceDefSet& interface_set_;
};

// Collector populates lists of declarations for which local facet
// executor mapping should be provided.
//
class Collector : public virtual Traversal::TranslationUnit,
                  public virtual Traversal::TranslationRegion,
                  public virtual Traversal::FileScope,
                  public virtual Traversal::Module,
                  public virtual Traversal::Composition,
                  public virtual Traversal::HomeExecutor
{
public:
  Collector (UnconstrainedInterfaceDefSet& interface_set,
             ComponentDefSet& component_set,
             HomeDefSet& home_set);

  virtual void
  visit_home_executor (HomeExecutorPtr const& he);

private:
  ComponentDefSet& component_set_;
  HomeDefSet& home_set_;

  ProvidesCollector provides_collector_;
};

class ServantGenerator
{
public:
  ServantGenerator (CommandLine const& cl);

  void
  generate (TranslationUnitPtr const& u);

private:
  void
  compute_export_macro (const fs::path& file_path);

  ostream&
  configure_stream (string const& suffix_option,
                    string const& default_suffix,
                    string const& regex_option,
                    fs::ofstream& ofs);

private:
  CommandLine const& cl_;
  string file_name_;
  string export_macro_;
};

#endif // SERVANT_GENERATOR_HPP