All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ow2.mind.adl.DefinitionMacroSourceGenerator Maven / Gradle / Ivy

The newest version!
/**
 * Copyright (C) 2009 STMicroelectronics
 *
 * This file is part of "Mind Compiler" is free software: you can redistribute 
 * it and/or modify it under the terms of the GNU Lesser General Public License 
 * as published by the Free Software Foundation, either version 3 of the 
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see .
 *
 * Contact: [email protected]
 *
 * Authors: Ali Erdem Ozcan
 * Contributors: 
 */

package org.ow2.mind.adl;

import static org.ow2.mind.PathHelper.fullyQualifiedNameToPath;

import org.objectweb.fractal.adl.Definition;

import com.google.inject.Inject;
import com.google.inject.name.Named;

/**
 * {@link DefinitionSourceGenerator} component that generated {@value #FILE_EXT}
 * files using the {@value #DEFAULT_TEMPLATE} template.
 */
public class DefinitionMacroSourceGenerator
    extends
      DefinitionIncSourceGenerator {

  /** The name to be used to inject the templateGroupName used by this class. */
  public static final String    TEMPLATE_NAME    = "definitions.implementations.macro";

  /** The default templateGroupName used by this class. */
  public static final String    DEFAULT_TEMPLATE = "st.definitions.implementations.Macro";

  protected static final String FILE_EXT         = ".macro";

  @Inject
  protected DefinitionMacroSourceGenerator(
      @Named(TEMPLATE_NAME) final String templateGroupName) {
    super(templateGroupName);
  }

  // ---------------------------------------------------------------------------
  // public static methods
  // ---------------------------------------------------------------------------

  /**
   * A static method that returns the name of the file that is generated by this
   * component for the given {@link Definition};
   * 
   * @param definition a {@link Definition} node.
   * @return the name of the file that is generated by this component for the
   *         given {@link Definition};
   */
  public static String getMacroFileName(final Definition definition) {
    return fullyQualifiedNameToPath(definition.getName(), FILE_EXT);
  }

  // ---------------------------------------------------------------------------
  // Overridden method
  // ---------------------------------------------------------------------------

  @Override
  protected String getOutputFileName(final Definition definition) {
    return getMacroFileName(definition);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy