Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

ConstituentsMakefileGenerator Class Reference

#include <cmt_generators.h>

Inheritance diagram for ConstituentsMakefileGenerator:

Inheritance graph
[legend]
Collaboration diagram for ConstituentsMakefileGenerator:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ConstituentsMakefileGenerator ()
void build (const cmt_string &package, const CmtSystem::cmt_string_vector &arguments)

Private Member Functions

void reset ()

Private Attributes

FragmentHandle constituents_header_fragment
FragmentHandle constituents_trailer_fragment
FragmentHandle group_fragment
FragmentHandle constituent_fragment
FragmentHandle check_application_header_fragment

Constructor & Destructor Documentation

ConstituentsMakefileGenerator::ConstituentsMakefileGenerator  ) 
 

Definition at line 2389 of file cmt_generators.cxx.

References check_application_header_fragment, constituent_fragment, constituents_header_fragment, constituents_trailer_fragment, group_fragment, and FragmentHandle::set().

02390 {
02391   constituents_header_fragment.set ("constituents_header");
02392   constituents_trailer_fragment.set ("constituents_trailer");
02393   group_fragment.set ("group");
02394   constituent_fragment.set ("constituent");
02395   check_application_header_fragment.set ("check_application_header");
02396 }


Member Function Documentation

void ConstituentsMakefileGenerator::build const cmt_string package,
const CmtSystem::cmt_string_vector arguments
 

Definition at line 2409 of file cmt_generators.cxx.

References Cmt::build_nmake(), check_application_header_fragment, CmtSystem::cmt_string_vector, CmtGenerator::commit(), constituent_fragment, Constituent::constituents(), constituents_header_fragment, constituents_trailer_fragment, Constituent::ConstituentVector, FragmentHandle::copy(), cmt_string::erase(), group_fragment, Group::groups(), Group::GroupVector, Constituent::has_target_tag, Constituent::name, Group::name(), Constituent::need_check, reset(), cmt_vector< T >::size(), cmt_string::substr(), Constituent::suffix, CmtSystem::test_file(), and Constituent::variables.

Referenced by Generator::build_constituents_makefile().

02411 {
02412   reset ();
02413 
02414   cmt_string file_name;
02415 
02416   if (arguments.size () > 0)
02417     {
02418       cmt_string arg = arguments[0];
02419       if (arg.substr (0, 5) == "-out=")
02420         {
02421           arg.erase (0, 5);
02422           file_name = arg;
02423         }
02424     }
02425 
02426   if (file_name == "")
02427     {
02428       file_name = "constituents.";
02429 
02430       //--- Build the constituents fragment -----
02431 
02432       if (Cmt::build_nmake ())
02433         {
02434           file_name += "nmake";
02435         }
02436       else
02437         {
02438           file_name += "make";
02439         }
02440     }
02441 
02442   cmt_string save_file_name = file_name;
02443   save_file_name += "sav";
02444 
02445   if (CmtSystem::test_file (file_name))
02446     {
02447       rename (file_name, save_file_name);
02448     }
02449 
02450   cmt_string new_file_name = file_name;
02451   new_file_name += "new";
02452 
02453   m_output_file = fopen (new_file_name, "wb");
02454   if (m_output_file != NULL)
02455     {
02456       int number;
02457       const Constituent::ConstituentVector&
02458         constituents = Constituent::constituents ();
02459 
02460       m_PACKAGE = package;
02461 
02462       constituents_header_fragment.copy (m_output_file, 1, &m_PACKAGE);
02463 
02464       m_GROUP = "all";
02465       group_fragment.copy (m_output_file, 1, &m_GROUP);
02466 
02467       const Group::GroupVector& groups = Group::groups ();
02468 
02469       for (number = 0; number < groups.size (); number++)
02470         {
02471           const Group& group = groups[number];
02472 
02473           m_GROUP = group.name ();
02474 
02475           group_fragment.copy (m_output_file, 1, &m_GROUP);
02476         }
02477       
02478       for (number = 0; number < constituents.size (); number++)
02479         {
02480           const Constituent& constituent = constituents[number];
02481 
02482           m_CONSTITUENT = constituent.name;
02483           m_CONSTITUENTSUFFIX = constituent.suffix;
02484 
02485           m_LINE = "";
02486 
02487           if (constituent.has_target_tag)
02488             {
02489               m_HASTARGETTAG = "has_target_tag";
02490             }
02491           else
02492             {
02493               m_HASTARGETTAG = "has_no_target_tag";
02494             }
02495 
02496           constituent_fragment.copy (m_output_file, constituent.variables, 5, 
02497                                      &m_PACKAGE,
02498                                      &m_CONSTITUENT, 
02499                                      &m_CONSTITUENTSUFFIX,
02500                                      &m_LINE,
02501                                      &m_HASTARGETTAG);
02502 
02503           if (constituent.need_check)
02504             {
02505               check_application_header_fragment.copy (m_output_file, 
02506                                                       constituent.variables, 3,
02507                                                       &m_PACKAGE,
02508                                                       &m_CONSTITUENT,
02509                                                       &m_CONSTITUENTSUFFIX);
02510             }
02511         }
02512 
02513       constituents_trailer_fragment.copy (m_output_file, 0);
02514 
02515       fclose (m_output_file);
02516 
02517       commit (new_file_name);
02518     }
02519 }

void ConstituentsMakefileGenerator::reset  )  [private]
 

Reimplemented from CmtGenerator.

Definition at line 2398 of file cmt_generators.cxx.

References check_application_header_fragment, constituent_fragment, constituents_header_fragment, constituents_trailer_fragment, group_fragment, FragmentHandle::reset(), and CmtGenerator::reset().

Referenced by build().


Member Data Documentation

FragmentHandle ConstituentsMakefileGenerator::check_application_header_fragment [private]
 

Definition at line 207 of file cmt_generators.h.

Referenced by build(), ConstituentsMakefileGenerator(), and reset().

FragmentHandle ConstituentsMakefileGenerator::constituent_fragment [private]
 

Definition at line 206 of file cmt_generators.h.

Referenced by build(), ConstituentsMakefileGenerator(), and reset().

FragmentHandle ConstituentsMakefileGenerator::constituents_header_fragment [private]
 

Definition at line 203 of file cmt_generators.h.

Referenced by build(), ConstituentsMakefileGenerator(), and reset().

FragmentHandle ConstituentsMakefileGenerator::constituents_trailer_fragment [private]
 

Definition at line 204 of file cmt_generators.h.

Referenced by build(), ConstituentsMakefileGenerator(), and reset().

FragmentHandle ConstituentsMakefileGenerator::group_fragment [private]
 

Definition at line 205 of file cmt_generators.h.

Referenced by build(), ConstituentsMakefileGenerator(), and reset().


The documentation for this class was generated from the following files:
Generated on Mon May 2 10:25:35 2005 for CMT by doxygen 1.3.5