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

CmtLock Class Reference

#include

List of all members.


Public Types

enum ? status {
??locked_by_user, locked_by_another_user, not_locked, still_locked,
??still_unlocked
}

Static Public Methods

status? lock ()
status? unlock ()
status? check ()

Member Enumeration Documentation

enum CmtLock::status
?

Enumeration values:
locked_by_user ?
locked_by_another_user ?
not_locked ?
still_locked ?
still_unlocked ?

Definition at line 7 of file cmt_lock.h.

00008         {
00009                 locked_by_user, 
00010                 locked_by_another_user, 
00011                 not_locked,
00012                 still_locked,
00013                 still_unlocked
00014         }

Member Function Documentation

CmtLock::status CmtLock::check ( ) [static]
?

Definition at line 102 of file cmt_lock.cxx.

Referenced by Cmt::do_broadcast(), Cmt::do_build_constituent_makefile(), Cmt::do_build_constituents_makefile(), Cmt::do_build_dependencies(), Cmt::do_build_library_links(), Cmt::do_build_make_setup(), Cmt::do_build_msdev(), Cmt::do_build_os9_makefile(), Cmt::do_build_prototype(), Cmt::do_build_readme(), Cmt::do_build_tag_makefile(), Cmt::do_build_triggers(), Cmt::do_build_vsnet(), Cmt::do_build_windefs(), Cmt::do_config(), and Cmt::do_remove_library_links().

00104 {
00105         cmt_string me = CmtSystem::user ();
00106         cmt_string text;
00107 
00108         if (text.read ("lock.cmt"))
00109         {
00110                 CmtSystem::cmt_string_vector words;
00111 
00112                 CmtSystem::split (text, " ", words);
00113 
00114                 if (words.size () >= 3)
00115                 {
00116                         if (words[2] == me)
00117                         {
00118                                 return (locked_by_user);
00119                         }
00120                         else
00121                         {
00122                                 return (locked_by_another_user);
00123                         }
00124                 }
00125         }
00126         
00127         return (not_locked);
00128 }

CmtLock::status CmtLock::lock ( ) [static]
?

Definition at line 9 of file cmt_lock.cxx.

Referenced by Cmt::do_lock().

00011 {
00012         status s = check ();
00013 
00014         switch (s)
00015         {
00016         case locked_by_user:
00017                 cout << "Package already locked by you" << endl;
00018                 return (s);
00019         case locked_by_another_user:
00020                 CmtError::set (CmtError::cannot_lock, "lock> Package already locked by another user");
00021                 return (s);
00022         case not_locked:
00023                 break;
00024         }
00025 
00026         cmt_string text = "locked by ";
00027         text += CmtSystem::user ();
00028         text += " date ";
00029         text += CmtSystem::now ();
00030 
00031         if (!text.write ("lock.cmt"))
00032         {
00033                 CmtError::set (CmtError::cannot_write_lock, "lock>");
00034                 return (still_unlocked);
00035         }
00036 
00037         Symbol* lock_command = Symbol::find ("lock_command");
00038         if (lock_command != 0)
00039         {
00040                 cmt_string command = lock_command->build_macro_value ();
00041 
00042                 if (command != "")
00043                 {
00044                         if (CmtSystem::execute (command) != 0)
00045                         {
00046                                 CmtError::set (CmtError::cannot_run_lock_command, "lock>");
00047                                 return (still_unlocked);
00048                         }
00049                 }
00050         }
00051 
00052         cout << "Package now locked" << endl;
00053 
00054         return (locked_by_user);
00055 }

CmtLock::status CmtLock::unlock ( ) [static]
?

Definition at line 58 of file cmt_lock.cxx.

Referenced by Cmt::do_unlock().

00060 {
00061         status s = check ();
00062 
00063         switch (s)
00064         {
00065         case locked_by_user:
00066                 break;
00067         case locked_by_another_user:
00068                 CmtError::set (CmtError::cannot_unlock, "unlock> Package locked by another user");
00069                 return (s);
00070         case not_locked:
00071                 cout << "The package was not locked" << endl;
00072                 return (s);
00073         }
00074 
00075         Symbol* unlock_command = Symbol::find ("unlock_command");
00076         if (unlock_command != 0)
00077         {
00078                 cmt_string command = unlock_command->build_macro_value ();
00079 
00080                 if (command != "")
00081                 {
00082                         if (CmtSystem::execute (command) != 0)
00083                         {
00084                                 CmtError::set (CmtError::cannot_run_unlock_command, "unlock>");
00085                                 return (still_locked);
00086                         }
00087                 }
00088         }
00089 
00090         if (!CmtSystem::remove_file ("lock.cmt"))
00091         {
00092                 CmtError::set (CmtError::cannot_remove_lock, "unlock>");
00093                 return (still_locked);
00094         }
00095 
00096         cout << "Package now unlocked" << endl;
00097 
00098         return (not_locked);
00099 }

The documentation for this class was generated from the following files:
Generated at Mon Aug 11 12:56:23 2003 for CMT by 1.2.3 written by , ??1997-2000