Main Page Class Hierarchy Compound List File List Compound Members File Members

# Script Class Reference

`#include <cmt_script.h>`

Collaboration diagram for Script:

[legend]
List of all members.

## Public Types
typedef cmt_vector<Script> | ScriptVector
## Public Methods
| Script ()
| ~Script ()
int | print (PrintMode mode, const Use* use)
## Public Attributes
cmt_string | name
ScriptType | type
## Static Public Methods
void | action (const CmtSystem::cmt_string_vector& words, ScriptType type, Use* use)
Script* | find (const cmt_string& name, Use* use)
Script* | add (const cmt_string& name, ScriptType type, Use* use)
void | all_print_clean (PrintMode mode)
void | all_print (PrintMode mode)
void | clear_all ()

## Member Typedef Documentation

typedef cmt_vector<Script> Script::ScriptVector

| Definition at line 10 of file cmt_script.h.

## Constructor & Destructor Documentation

Script::Script ( | )

| Definition at line 184 of file cmt_script.cxx.
    00186 {
    00187 }

Script::~Script ( | )

| Definition at line 190 of file cmt_script.cxx.
    00192 {
    00193 }

## Member Function Documentation

void Script::action ( | const CmtSystem::cmt_string_vector & words,
| ScriptType type,
| Use * use )`[static]`

| Definition at line 16 of file cmt_script.cxx. Referenced by Cmt::select().
    00020 {
    00021   cmt_string name;
    00022   Script* script;
    00023
    00024   if (use == 0) use = &(Use::current());
    00025
    00026   name = words[1];
    00027   if (name == "") return;
    00028
    00029   script = add (name, type, use);
    00030 }

Script * Script::add ( | const cmt_string & name,
| ScriptType type,
| Use * use )`[static]`

| Definition at line 58 of file cmt_script.cxx.
    00060 {
    00061   cmt_string short_name = name;
    00062
    00063   if (use == 0) use = &(Use::current());
    00064
    00065   int pos;
    00066
    00067   pos = short_name.find (".csh");
    00068   if (pos != cmt_string::npos)
    00069     {
    00070       short_name.erase (pos);
    00071     }
    00072
    00073   pos = short_name.find (".sh");
    00074   if (pos != cmt_string::npos)
    00075     {
    00076       short_name.erase (pos);
    00077     }
    00078
    00079   {
    00080     Script* script;
    00081
    00082     if (short_name == "") return (0);
    00083     script = find (short_name, use);
    00084     if (script != 0)
    00085       {
    00086         script->type = type;
    00087         return (script);
    00088       }
    00089   }
    00090
    00091   Script& script = use->scripts.add ();
    00092
    00093   script.name = short_name;
    00094   script.type = type;
    00095
    00096   return (&script);
    00097 }

void Script::all_print ( | PrintMode mode )`[static]`

| Definition at line 131 of file cmt_script.cxx.
    00133 {
    00134   int number;
    00135   int script_number;
    00136   Use::UsePtrVector& uses = Use::uses ();
    00137
    00138   if (uses.size () > 0)
    00139     {
    00140       for (number = 0; number < uses.size (); number++)
    00141         {
    00142           const Use* use = uses[number];
    00143
    00144           if (use->package == "CMT") continue;
    00145
    00146           for (script_number = 0;
    00147                script_number < use->scripts.size ();
    00148                script_number++)
    00149             {
    00150               Script& script = use->scripts[script_number];
    00151
    00152               if (script.type == SetupScript)
    00153                 {
    00154                   if (script.print (mode, use)) cout << "; ";
    00155                 }
    00156             }
    00157         }
    00158     }
    00159
    00160   {
    00161     const Use& use = Use::current ();
    00162
    00163     for (script_number = 0;
    00164          script_number < use.scripts.size ();
    00165          script_number++)
    00166       {
    00167         Script& script = use.scripts[script_number];
    00168
    00169         if (script.type == SetupScript)
    00170           {
    00171             if (script.print (mode, &use)) cout << "; ";
    00172           }
    00173       }
    00174   }
    00175 }

void Script::all_print_clean ( | PrintMode mode )`[static]`

| Definition at line 100 of file cmt_script.cxx. Referenced by Cmt::print_clean().
    00102 {
    00103   int number;
    00104   int script_number;
    00105   Use::UsePtrVector& uses = Use::uses ();
    00106
    00107   if (uses.size () > 0)
    00108     {
    00109       for (number = 0; number < uses.size (); number++)
    00110         {
    00111           const Use* use = uses[number];
    00112
    00113           if (use->package == "CMT") continue;
    00114
    00115           for (script_number = 0;
    00116                script_number < use->scripts.size ();
    00117                script_number++)
    00118             {
    00119               Script& script = use->scripts[script_number];
    00120
    00121               if (script.type == CleanupScript)
    00122                 {
    00123                   if (script.print (mode, use)) cout << "; ";
    00124                 }
    00125             }
    00126         }
    00127     }
    00128 }

void Script::clear_all ( | )`[static]`

| Definition at line 178 of file cmt_script.cxx. Referenced by Cmt::clear().
    00180 {
    00181 }

Script * Script::find ( | const cmt_string & name,
| Use * use )`[static]`

| Definition at line 33 of file cmt_script.cxx.
    00035 {
    00036   int script_index;
    00037
    00038   if (use == 0) use = &(Use::current());
    00039
    00040   if (use->scripts.size () == 0) return (0);
    00041
    00042   for (script_index = 0;
    00043        script_index < use->scripts.size ();
    00044        script_index++)
    00045     {
    00046       Script& script = use->scripts[script_index];
    00047
    00048       if (script.name == name)
    00049         {
    00050           return (&script);
    00051         }
    00052     }
    00053
    00054   return (0);
    00055 }

int Script::print ( | PrintMode mode,
| const Use * use )

| Definition at line 196 of file cmt_script.cxx. Referenced by all_print(), and all_print_clean().
    00198 {
    00199   int result = 1;
    00200   cmt_string suffix;
    00201
    00202   if (name == "") return (0);
    00203
    00204   switch (mode)
    00205     {
    00206       case Csh :
    00207         suffix = ".csh";
    00208         cout << "source ";
    00209         break;
    00210       case Sh :
    00211         suffix = ".sh";
    00212         cout << ". ";
    00213         break;
    00214     }
    00215
    00216   if (name.find (SLASH) == cmt_string::npos)
    00217     {
    00218       cout << "${" << use->prefix << "ROOT}/";
    00219       if (use->style == cmt_style) cout << "cmt/";
    00220       else cout << "mgr/";
    00221     }
    00222
    00223   cout << name << suffix;
    00224
    00225   return (result);
    00226 }

## Member Data Documentation

cmt_string Script::name

| Definition at line 26 of file cmt_script.h.

ScriptType Script::type

| Definition at line 27 of file cmt_script.h.

The documentation for this class was generated from the following files:

- cmt_script.h
- cmt_script.cxx