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

batch.C

Go to the documentation of this file.
00001 #include "asset.h"
00002 #include "batch.h"
00003 #include "channel.h"
00004 #include "channeldb.h"
00005 #include "edl.h"
00006 #include "record.h"
00007 #include "recordlabel.h"
00008 
00009 #include <string.h>
00010 
00011 
00012 
00013 
00014 Batch::Batch(MWindow *mwindow, Record *record)
00015 {
00016         this->mwindow = mwindow;
00017         this->record = record;
00018         channel = 0;
00019         start_type = RECORD_START;
00020         duration = 0;
00021         enabled = 1;
00022         file_exists = 0;
00023         start_time = 0;
00024         start_day = 0;
00025         record_mode = RECORD_INFINITE;
00026         news[0] = 0;
00027 // Create default asset
00028         current_asset = 0;
00029         recorded = 0;
00030         file_offset = 0;
00031         waiting = 0;
00032         total_samples = 0;
00033         total_frames = 0;
00034         current_sample = 0;
00035         current_frame = 0;
00036         session_samples = 0;
00037         session_frames = 0;
00038         assets.append(new Asset);
00039         labels = new RecordLabels;
00040         edl = 0;
00041 }
00042 
00043 Batch::~Batch()
00044 {
00045         for(int i = 0; i < assets.total; i++)
00046                 delete assets.values[i];
00047         assets.remove_all();
00048         delete labels;
00049         if(edl) delete edl;
00050 }
00051 
00052 int Batch::create_objects()
00053 {
00054         return 0;
00055 }
00056 
00057 void Batch::start_over()
00058 {
00059         file_offset = 0;
00060         calculate_news();
00061 
00062         while(labels->last) delete labels->last;
00063         total_frames = 0;
00064         total_samples = 0;
00065         current_frame = 0;
00066         current_sample = 0;
00067 }
00068 
00069 void Batch::copy_from(Batch *batch)
00070 {
00071         enabled = batch->enabled;
00072         channel = batch->channel;
00073         start_type = batch->start_type;
00074         duration = batch->duration;
00075         start_time = batch->start_time;
00076         start_day = batch->start_day;
00077         record_mode = batch->record_mode;
00078 }
00079 
00080 
00081 void Batch::calculate_news()
00082 {
00083 // File open
00084         if(record->get_current_batch() == this && record->file)
00085         {
00086                 sprintf(news, _("Open"));
00087         }
00088         else
00089         {
00090 // Test file existance
00091                 FILE *test = fopen(get_current_asset()->path, "r");
00092 
00093                 if(test)
00094                 {
00095                         sprintf(news, _("File exists"));
00096                         fclose(test);
00097                 }
00098                 else
00099                         sprintf(news, _("OK"));
00100         }
00101 }
00102 
00103 void Batch::create_default_path()
00104 {
00105         char *path = get_current_asset()->path;
00106         char string[BCTEXTLEN];
00107         int i, j = -1, k = -1;
00108         int number = record->batches.total;
00109 
00110         strcpy(string, record->default_asset->path);
00111         strcpy(path, record->default_asset->path);
00112 
00113 // Find first number in path
00114         for(i = 0; i < strlen(path); i++)
00115         {
00116                 if(path[i] >= '0' && path[i] <= '9') j = i;
00117                 if((path[i] < '0' || path[i] > '9') && j >= 0 && k < 0) k = i;
00118         }
00119 
00120         if(j < 0)
00121         {
00122                 j = strlen(path);
00123         }
00124         
00125         if(k < 0)
00126         {
00127                 k = strlen(path);
00128         }
00129 
00130         
00131         sprintf(&path[j], "%d", record->batches.total);
00132         strcat(path, &string[k]);
00133 }
00134 
00135 
00136 int Batch::text_to_mode(char *text)
00137 {
00138         if(!strcasecmp(mode_to_text(RECORD_INFINITE), text)) return RECORD_INFINITE;
00139         if(!strcasecmp(mode_to_text(RECORD_TIMED), text)) return RECORD_TIMED;
00140 //      if(!strcasecmp(mode_to_text(RECORD_LOOP), text)) return RECORD_LOOP;
00141 //      if(!strcasecmp(mode_to_text(RECORD_SCENETOSCENE), text)) return RECORD_SCENETOSCENE;
00142         return RECORD_INFINITE;
00143 }
00144 
00145 char* Batch::mode_to_text(int record_mode)
00146 {
00147         switch(record_mode)
00148         {
00149                 case RECORD_INFINITE:
00150                         return _("Untimed");
00151                         break;
00152                 case RECORD_TIMED:
00153                         return _("Timed");
00154                         break;
00155 //              case RECORD_LOOP:
00156 //                      return "Loop";
00157 //                      break;
00158 //              case RECORD_SCENETOSCENE:
00159 //                      return "Scene to scene";
00160 //                      break;
00161         }
00162         return _("Unknown");
00163 }
00164 
00165 Asset* Batch::get_current_asset()
00166 {
00167         return assets.values[current_asset];
00168 }
00169 
00170 
00171 Channel* Batch::get_current_channel_struct()
00172 {
00173         if(channel >= 0 && channel < record->channeldb->size())
00174         {
00175                 return record->channeldb->get(channel);
00176         }
00177         return 0;
00178 }
00179 
00180 
00181 char* Batch::get_source_text()
00182 {
00183         // Driver sensitive
00184         Channel *channel = get_current_channel_struct();
00185         if(channel)
00186                 return channel->title;
00187         else
00188                 return "";
00189 }
00190 
00191 void Batch::toggle_label(double position)
00192 {
00193         labels->toggle_label(position);
00194 }

Generated on Sun Jan 8 13:38:50 2006 for Cinelerra-svn by  doxygen 1.4.4