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

assets.C

Go to the documentation of this file.
00001 #include "asset.h"
00002 #include "assets.h"
00003 #include "awindowgui.inc"
00004 #include "batch.h"
00005 #include "cache.h"
00006 #include "defaults.h"
00007 #include "edl.h"
00008 #include "file.h"
00009 #include "filexml.h"
00010 #include "filesystem.h"
00011 #include "indexfile.h"
00012 #include "quicktime.h"
00013 #include "mainsession.h"
00014 #include "threadindexer.h"
00015 #include <string.h>
00016 
00017 Assets::Assets(EDL *edl) : List<Asset>()
00018 {
00019         this->edl = edl;
00020 }
00021 
00022 Assets::~Assets()
00023 {
00024         delete_all();
00025 }
00026 
00027 int Assets::load(ArrayList<PluginServer*> *plugindb, 
00028         FileXML *file, 
00029         uint32_t load_flags)
00030 {
00031         int result = 0;
00032 
00033 //printf("Assets::load 1\n");
00034         while(!result)
00035         {
00036                 result = file->read_tag();
00037                 if(!result)
00038                 {
00039                         if(file->tag.title_is("/ASSETS"))
00040                         {
00041                                 result = 1;
00042                         }
00043                         else
00044                         if(file->tag.title_is("ASSET"))
00045                         {
00046 //printf("Assets::load 2\n");
00047                                 char *path = file->tag.get_property("SRC");
00048 //printf("Assets::load 3\n");
00049                                 Asset new_asset(path ? path : SILENCE);
00050 //printf("Assets::load 4\n");
00051                                 new_asset.read(file);
00052 //printf("Assets::load 5\n");
00053                                 update(&new_asset);
00054 //printf("Assets::load 6\n");
00055                         }
00056                 }
00057         }
00058 //printf("Assets::load 7\n");
00059         return 0;
00060 }
00061 
00062 int Assets::save(ArrayList<PluginServer*> *plugindb, FileXML *file, char *path)
00063 {
00064         file->tag.set_title("ASSETS");
00065         file->append_tag();
00066         file->append_newline();
00067 
00068         for(Asset* current = first; current; current = NEXT)
00069         {
00070                 current->write(file, 
00071                         0, 
00072                         path);
00073         }
00074 
00075         file->tag.set_title("/ASSETS");
00076         file->append_tag();
00077         file->append_newline(); 
00078         file->append_newline(); 
00079         return 0;
00080 }
00081 
00082 void Assets::copy_from(Assets *assets)
00083 {
00084         while(last) delete last;
00085 
00086         for(Asset *current = assets->first; current; current = NEXT)
00087         {
00088                 Asset *new_asset;
00089                 append(new_asset = new Asset);
00090                 new_asset->copy_from(current, 1);
00091         }
00092 }
00093 
00094 Assets& Assets::operator=(Assets &assets)
00095 {
00096 printf("Assets::operator= 1\n");
00097         copy_from(&assets);
00098         return *this;
00099 }
00100 
00101 
00102 void Assets::update_index(Asset *asset)
00103 {
00104         for(Asset* current = first; current; current = NEXT)
00105         {
00106                 if(current->test_path(asset->path))
00107                 {
00108                         current->update_index(asset);
00109                 }
00110         }
00111 }
00112 
00113 Asset* Assets::update(Asset *asset)
00114 {
00115         if(!asset) return 0;
00116 
00117         for(Asset* current = first; current; current = NEXT)
00118         {
00119 // Asset already exists.
00120                 if(current->test_path(asset->path)) 
00121                 {
00122                         return current;
00123                 }
00124         }
00125 
00126 // Asset doesn't exist.
00127         Asset *asset_copy = new Asset(*asset);
00128         append(asset_copy);
00129         return asset_copy;
00130 }
00131 
00132 int Assets::delete_all()
00133 {
00134         while(last)
00135         {
00136                 remove(last);
00137         }
00138         return 0;
00139 }
00140 
00141 Asset* Assets::update(const char *path)
00142 {
00143         Asset* current = first;
00144 
00145         while(current)
00146         {
00147                 if(current->test_path(path)) 
00148                 {
00149                         return current;
00150                 }
00151                 current = NEXT;
00152         }
00153 
00154         return append(new Asset(path));
00155 }
00156 
00157 Asset* Assets::get_asset(const char *filename)
00158 {
00159         Asset* current = first;
00160         Asset* result = 0;
00161 
00162         while(current)
00163         {
00164 //printf("Assets::get_asset %p %s\n", filename, filename);
00165                 if(current->test_path(filename))
00166                 {
00167                         result = current;
00168                         break;
00169                 }
00170                 current = current->next;
00171         }
00172 
00173         return result;  
00174 }
00175 
00176 Asset* Assets::remove_asset(Asset *asset)
00177 {
00178         delete asset;
00179 }
00180 
00181 
00182 int Assets::number_of(Asset *asset)
00183 {
00184         int i;
00185         Asset *current;
00186 
00187         for(i = 0, current = first; current && current != asset; i++, current = NEXT)
00188                 ;
00189 
00190         return i;
00191 }
00192 
00193 Asset* Assets::asset_number(int number)
00194 {
00195         int i;
00196         Asset *current;
00197 
00198         for(i = 0, current = first; i < number && current; i++, current = NEXT)
00199                 ;
00200         
00201         return current;
00202 }
00203 
00204 int Assets::update_old_filename(char *old_filename, char *new_filename)
00205 {
00206         for(Asset* current = first; current; current = NEXT)
00207         {
00208                 if(!strcmp(current->path, old_filename))
00209                 {
00210                         current->update_path(new_filename);
00211                 }
00212         }
00213         return 0;
00214 }
00215 
00216 
00217 int Assets::dump()
00218 {
00219         for(Asset *current = first; current; current = NEXT)
00220         {
00221                 current->dump();
00222         }
00223         return 0;
00224 }
00225 
00226 

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