예제 #1
0
//
// Visit_Event_i
//
void XSD_File_Generator::
Visit_Event_i (const PICML::Event & ev, bool anonymous)
{
  this->fout_ << "<xsd:complexType";

  if (!anonymous)
    this->fout_ << " name='" << ev.SpecifyIdTag () << "'";

  this->fout_ << ">" << std::endl;

  // Create the xsd:sequence element for the ev's members.
  this->fout_ << "<xsd:sequence>" << std::endl;

  // Visit all the members in this ev. We sort the members from
  // top to bottom on the page, just like a file.
  typedef
    UDM_Position_Sort_T <PICML::Member, PS_Top_To_Bottom>
    _sort_function;

  typedef std::set <PICML::Member, _sort_function> Member_Set;

  Member_Set members =
    ev.Member_kind_children_sorted (_sort_function ());

  std::for_each (members.begin (),
                 members.end (),
                 boost::bind (&Member_Set::value_type::Accept,
                              _1,
                              boost::ref (*this)));

  this->fout_ << "</xsd:sequence>" << std::endl
              << "</xsd:complexType>" << std::endl;
}
예제 #2
0
//
// write_method
//
void CUTS_EISA_Generator_Base::
write_method (const PICML::OutEventPort & source)
{
  PICML::Event event = source.ref ();

  if (event != Udm::null)
  {
    this->out_
      << "push_" << source.name () << " ("
      << scope (event, "::") << event.name () << " * ev)";
  }
}
예제 #3
0
//
// write_InEventPort_begin
//
void CUTS_EISA_Generator_Base::
write_InEventPort_begin (const PICML::InEventPort & sink)
{
  PICML::Event event = sink.ref ();

  if (event != Udm::null)
  {
    this->out_
      << "push_" << sink.name () << " ("
      << scope (event, "::") << event.name () << " * ev)";
  }
}
예제 #4
0
//
// write_static
//
void CUTS_BE_CAPI_Event_Impl_Generator::
write_static (const PICML::Event & event)
{
  this->outfile_ << std::endl
                 << "/// Mapping file for this event type." << std::endl
                 << "private static Mapping mapping_ = new Mapping ();" << std::endl
                 << "/// XML -> Java unmarshaller for this event type." << std::endl
                 << "private static Unmarshaller unmarshaller_ = new Unmarshaller ();" << std::endl
                 << "/// Java -> XML marshaller for this event type." << std::endl
                 << "private static Marshaller marshaller_ = new Marshaller ();" << std::endl
                 << "static {"
                 << "try {"
                 << "// Get the class for the type." << std::endl
                 << "Class thisClass = " << CUTS_BE_Java::classname (event.SpecifyIdTag ())
                 << ".class;" << std::endl
                 << "// Construct the name of the mapping file. This is necessary" << std::endl
                 << "// since Castor likes to construct *bad* tags." << std::endl
                 << "String packageName = thisClass.getPackage ().getName ();"
                 << "String mappingFile = packageName.replace ('.', '/') + \"/mapping.xml\";" << std::endl
                 << "// Load the mapping file for the type." << std::endl
                 << this->impl_ << ".mapping_.loadMapping (thisClass.getClassLoader ().getResource (mappingFile));"
                 << std::endl
                 << "// Set the mappings for the marshaller/unmarshaller." << std::endl
                 << this->impl_ << ".marshaller_.setMapping (" << this->impl_ << ".mapping_);"
                 << this->impl_ << ".marshaller_.setValidation (false);"
                 << std::endl
                 << this->impl_ << ".unmarshaller_.setMapping (" << this->impl_ << ".mapping_);"
                 << this->impl_ << ".marshaller_.setValidation (false);"
                 << "}"
                 << "catch (Exception ex) {"
                 << "ex.printStackTrace ();"
                 << "}"
                 << "}";
}
예제 #5
0
//
// Visit_Event
//
void CUTS_BE_CAPI_Event_Impl_Generator::
Visit_Event (const PICML::Event & ev)
{
  std::string fq_name = CUTS_BE_Java::fq_type (ev, "/", false);

  if (fq_name == "cuts/jbi/client/JbiAnyEvent")
    return;

  // Save the name of the class.
  this->type_ = CUTS_BE_Java::classname (ev.SpecifyIdTag ());
  this->impl_ = this->type_ + "Impl";

  // Construct the filename for the implementation.
  std::ostringstream filename;
  filename << this->outdir_ << "/" << fq_name
           << "/" << this->impl_ << ".java";

  this->outfile_.open (filename.str ().c_str ());

  if (this->outfile_.is_open ())
  {
    this->formatter_.reset (new _formatter_type (this->outfile_));

    // Write the preamble for the file.
    this->outfile_ << "package " << CUTS_BE_Java::fq_type (ev, ".", false) << ";";
    this->write_includes ();

    // Begin the class definition.
    this->outfile_ << "public class " << this->impl_ << std::endl
                   << "  extends JbiEvent < " << this->type_ << " > {";

    // Write the constructors for the file.
    this->write_constructors ();

    this->write_getter_methods ();

    // Write the static part of the event.
    this->write_static (ev);

    // End the class definition.
    this->outfile_ << "}";

    // Close the output file.
    this->formatter_.reset (0);
    this->outfile_.close ();
  }
}
예제 #6
0
//
// Visit_Event
//
void XSD_File_Generator::Visit_Event (const PICML::Event & ev)
{
  // Gather required information about the ev.
  std::string xmltag = ev.SpecifyIdTag ();
  std::string fq_name = CUTS_BE_Java::fq_type (ev, ".", false);
  std::string classname = fq_name + '.' + CUTS_BE_Java::classname (xmltag);

  // Construct the path for the filename. We need to make sure
  // this directory exist before trying to open the mapping file.
  std::ostringstream path;
  path
    << this->outdir_ << CUTS_BE_Java::fq_type (ev, "\\", true);

  Utils::CreatePath (path.str (), '\\');
  std::string filename = path.str () + "\\" + fq_name + ".xsd";

  // Open the file for writing.
  this->fout_.open (filename.c_str ());

  if (!this->fout_.is_open ())
    return;

  // Set the indentation implanter for the output file.
  typedef Indentation::Implanter <
    Indentation::XML, char> formatter_type;

  formatter_type formatter (this->fout_);

  // Write the header for the file.
  this->fout_ << "<?xml version='1.0' encoding='UTF-8' standalone='no' ?>" << std::endl
              << "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'"
              << " elementFormDefault='unqualified' version='";

  // Set the version number for the schema based on the ev's
  // version number.
  std::string version = ev.VersionTag ();

  if (version.empty ())
  {
    version = "1.0";
    ev.VersionTag () = version;
  }

  this->fout_ << version << "'>" << std::endl;

  // Push the root element onto the stack then finish visiting
  // the ev element.

  std::string name = ev.SpecifyIdTag ();

  this->fout_ << "<xsd:element name='" << name << "'>" << std::endl;
  this->Visit_Event_i (ev, true);
  this->fout_ << "</xsd:element>" << std::endl;

  while (!this->complex_types_.empty ())
  {
    // Visit all the complex types that we located, but have not
    // generate code for.
    PICML::Aggregate aggr = this->complex_types_.top ();
    this->complex_types_.pop ();

    this->Visit_Aggregate_i (aggr);
  }

  std::for_each (this->enum_types_.begin (),
                 this->enum_types_.end (),
                 boost::bind (&XSD_File_Generator::Visit_Enum_i,
                              this,
                              _1));

  this->fout_ << "</xsd:schema>" << std::endl
              << std::endl;

  // Close the file.
  this->fout_.close ();
}
예제 #7
0
 //
 //visit_OutEventPort
 //
 void Component_Asm_Visitor::visit_InEventPort (PICML::InEventPort_in item)
 {
   PICML::Event ev = item->refers_to_EventType ();
   this->factory_.create_TopicQosReference (DQML::DataReaderQos::_narrow (this->current_node_), ev->name ());
 }