5 basic_def(double,Frame_mean);
6 basic_def(double,Frame_std_dev);
7 basic_def(double,Frame_cx);
8 basic_def(double,Frame_cy);
9 basic_def(double,Frame_moment);
10 varray_def(unsigned char,Frame_data);
14 basic_ref(double,Frame_mean);
15 basic_ref(double,Frame_std_dev);
16 basic_ref(double,Frame_cx);
17 basic_ref(double,Frame_cy);
18 basic_ref(double,Frame_moment);
19 varray_ref(unsigned char,Frame_data);
21 class ikey_Frame_weight : public Db::iKey { public:
22 Video_frameObj::t_Frame_mean v_Frame_mean;
24 static int cmpr(char *a, char *b);
25 ikey_Frame_weight(ObjectLoc &loc,
26 double Frame_mean, int id=-1)
27 : iKey("Frame_weight",loc,cmpr),
28 v_Frame_mean(Frame_mean),
31 class rkey_Frame_weight : public Db::rKey { public:
32 static int cmpr(char *a, char *b);
33 rkey_Frame_weight(ObjectLoc &loc) : rKey("Frame_weight",loc,cmpr) {}
36 class ikey_Frame_center : public Db::iKey { public:
37 Video_frameObj::t_Frame_moment v_Frame_moment;
39 static int cmpr(char *a, char *b);
40 ikey_Frame_center(ObjectLoc &loc,
41 double Frame_moment, int id=-1)
42 : iKey("Frame_center",loc,cmpr),
43 v_Frame_moment(Frame_moment),
46 class rkey_Frame_center : public Db::rKey { public:
47 static int cmpr(char *a, char *b);
48 rkey_Frame_center(ObjectLoc &loc) : rKey("Frame_center",loc,cmpr) {}
58 basic_def(unsigned int,Clip_id);
59 basic_def(unsigned int,Sequence_no);
60 basic_def(unsigned int,Frame_id);
61 basic_def(unsigned int,Group);
62 basic_def(double,Time_offset);
66 basic_ref(unsigned int,Clip_id);
67 basic_ref(unsigned int,Sequence_no);
68 basic_ref(unsigned int,Frame_id);
69 basic_ref(unsigned int,Group);
70 basic_ref(double,Time_offset);
72 class ikey_Timelines : public Db::iKey { public:
73 TimelineObj::t_Frame_id v_Frame_id;
75 static int cmpr(char *a, char *b);
76 ikey_Timelines(ObjectLoc &loc,
77 unsigned int Frame_id, int id=-1)
78 : iKey("Timelines",loc,cmpr),
82 class rkey_Timelines : public Db::rKey { public:
83 static int cmpr(char *a, char *b);
84 rkey_Timelines(ObjectLoc &loc) : rKey("Timelines",loc,cmpr) {}
87 class ikey_Sequences : public Db::iKey { public:
88 TimelineObj::t_Clip_id v_Clip_id;
89 TimelineObj::t_Sequence_no v_Sequence_no;
90 static int cmpr(char *a, char *b);
91 ikey_Sequences(ObjectLoc &loc,
93 unsigned int Sequence_no)
94 : iKey("Sequences",loc,cmpr),
96 v_Sequence_no(Sequence_no) {}
98 class rkey_Sequences : public Db::rKey { public:
99 static int cmpr(char *a, char *b);
100 rkey_Sequences(ObjectLoc &loc) : rKey("Sequences",loc,cmpr) {}
110 sarray_def(char,Title);
111 sarray_def(char,Asset_path);
112 basic_def(double,Position);
113 basic_def(double,Framerate);
114 basic_def(double,Average_weight);
115 basic_def(unsigned int,Frames);
116 basic_def(unsigned int,Prefix_size);
117 basic_def(unsigned int,Suffix_size);
118 varray_def(unsigned char,Weights);
119 basic_def(long,System_time);
120 basic_def(long,Creation_time);
124 sarray_ref(char,Title);
125 sarray_ref(char,Asset_path);
126 basic_ref(double,Position);
127 basic_ref(double,Framerate);
128 basic_ref(double,Average_weight);
129 basic_ref(unsigned int,Frames);
130 basic_ref(unsigned int,Prefix_size);
131 basic_ref(unsigned int,Suffix_size);
132 varray_ref(unsigned char,Weights);
133 basic_ref(long,System_time);
134 basic_ref(long,Creation_time);
136 class ikey_Clip_title : public Db::iKey { public:
137 Clip_setObj::t_Title v_Title;
139 static int cmpr(char *a, char *b);
140 ikey_Clip_title(ObjectLoc &loc,
141 const Clip_setObj::t_Title &Title, int id=-1)
142 : iKey("Clip_title",loc,cmpr),
146 class rkey_Clip_title : public Db::rKey { public:
147 static int cmpr(char *a, char *b);
148 rkey_Clip_title(ObjectLoc &loc) : rKey("Clip_title",loc,cmpr) {}
151 class ikey_Clip_system_time : public Db::iKey { public:
152 Clip_setObj::t_System_time v_System_time;
154 static int cmpr(char *a, char *b);
155 ikey_Clip_system_time(ObjectLoc &loc,
156 long System_time, int id=-1)
157 : iKey("Clip_system_time",loc,cmpr),
158 v_System_time(System_time),
161 class rkey_Clip_system_time : public Db::rKey { public:
162 static int cmpr(char *a, char *b);
163 rkey_Clip_system_time(ObjectLoc &loc) : rKey("Clip_system_time",loc,cmpr) {}
166 class ikey_Clip_creation_time : public Db::iKey { public:
167 Clip_setObj::t_Creation_time v_Creation_time;
169 static int cmpr(char *a, char *b);
170 ikey_Clip_creation_time(ObjectLoc &loc,
171 long Creation_time, int id=-1)
172 : iKey("Clip_creation_time",loc,cmpr),
173 v_Creation_time(Creation_time),
176 class rkey_Clip_creation_time : public Db::rKey { public:
177 static int cmpr(char *a, char *b);
178 rkey_Clip_creation_time(ObjectLoc &loc) : rKey("Clip_creation_time",loc,cmpr) {}
188 basic_def(unsigned int,Access_clip_id);
189 basic_def(long,Access_time);
190 basic_def(unsigned int,Access_count);
194 basic_ref(unsigned int,Access_clip_id);
195 basic_ref(long,Access_time);
196 basic_ref(unsigned int,Access_count);
198 class ikey_Clip_access : public Db::iKey { public:
199 Clip_viewsObj::t_Access_clip_id v_Access_clip_id;
200 static int cmpr(char *a, char *b);
201 ikey_Clip_access(ObjectLoc &loc,
202 unsigned int Access_clip_id)
203 : iKey("Clip_access",loc,cmpr),
204 v_Access_clip_id(Access_clip_id) {}
206 class rkey_Clip_access : public Db::rKey { public:
207 static int cmpr(char *a, char *b);
208 rkey_Clip_access(ObjectLoc &loc) : rKey("Clip_access",loc,cmpr) {}
211 class ikey_Last_view : public Db::iKey { public:
212 Clip_viewsObj::t_Access_time v_Access_time;
214 static int cmpr(char *a, char *b);
215 ikey_Last_view(ObjectLoc &loc,
216 long Access_time, int id=-1)
217 : iKey("Last_view",loc,cmpr),
218 v_Access_time(Access_time),
221 class rkey_Last_view : public Db::rKey { public:
222 static int cmpr(char *a, char *b);
223 rkey_Last_view(ObjectLoc &loc) : rKey("Last_view",loc,cmpr) {}
226 class ikey_Total_views : public Db::iKey { public:
227 Clip_viewsObj::t_Access_count v_Access_count;
228 Clip_viewsObj::t_Access_clip_id v_Access_clip_id;
230 static int cmpr(char *a, char *b);
231 ikey_Total_views(ObjectLoc &loc,
232 unsigned int Access_count,
233 unsigned int Access_clip_id, int id=-1)
234 : iKey("Total_views",loc,cmpr),
235 v_Access_count(Access_count),
236 v_Access_clip_id(Access_clip_id),
239 class rkey_Total_views : public Db::rKey { public:
240 static int cmpr(char *a, char *b);
241 rkey_Total_views(ObjectLoc &loc) : rKey("Total_views",loc,cmpr) {}
250 int Video_frameLoc::ikey_Frame_weight::
251 cmpr(char *a, char *b)
253 ikey_Frame_weight *kp = (ikey_Frame_weight *)a;
255 if( kp->v_id == v ) return 0;
256 Video_frameLoc vloc(kp->loc.entity);
258 vloc.err_(Db::errCorrupt);
259 v = cmpr_double( kp->v_Frame_mean.addr(), kp->v_Frame_mean.size(),
260 vloc._Frame_mean(), vloc->v_Frame_mean.size());
261 if( v != 0 ) return v;
262 if( kp->v_id >= 0 ) {
263 v = cmpr_int(&kp->v_id, sizeof(kp->v_id),
264 vloc._id(), vloc._id_size());
265 if( v != 0 ) return v;
270 int Video_frameLoc::rkey_Frame_weight::
271 cmpr(char *a, char *b)
273 rkey_Frame_weight *kp = (rkey_Frame_weight *)a;
274 Video_frameLoc &kloc = (Video_frameLoc&)kp->loc;
275 int v = kloc->id, b_id = *(int*)b;
276 if( v == b_id ) return 0;
277 Video_frameLoc vloc(kloc.entity);
278 if( vloc.FindId(b_id) )
279 kloc.err_(Db::errCorrupt);
280 v = cmpr_double( kloc._Frame_mean(), kloc->v_Frame_mean.size(),
281 vloc._Frame_mean(), vloc->v_Frame_mean.size());
282 if( v != 0 ) return v;
283 v = cmpr_int(kloc._id(), kloc._id_size(),
284 vloc._id(), vloc._id_size());
285 if( v != 0 ) return v;
289 int Video_frameLoc::ikey_Frame_center::
290 cmpr(char *a, char *b)
292 ikey_Frame_center *kp = (ikey_Frame_center *)a;
294 if( kp->v_id == v ) return 0;
295 Video_frameLoc vloc(kp->loc.entity);
297 vloc.err_(Db::errCorrupt);
298 v = cmpr_double( kp->v_Frame_moment.addr(), kp->v_Frame_moment.size(),
299 vloc._Frame_moment(), vloc->v_Frame_moment.size());
300 if( v != 0 ) return v;
301 if( kp->v_id >= 0 ) {
302 v = cmpr_int(&kp->v_id, sizeof(kp->v_id),
303 vloc._id(), vloc._id_size());
304 if( v != 0 ) return v;
309 int Video_frameLoc::rkey_Frame_center::
310 cmpr(char *a, char *b)
312 rkey_Frame_center *kp = (rkey_Frame_center *)a;
313 Video_frameLoc &kloc = (Video_frameLoc&)kp->loc;
314 int v = kloc->id, b_id = *(int*)b;
315 if( v == b_id ) return 0;
316 Video_frameLoc vloc(kloc.entity);
317 if( vloc.FindId(b_id) )
318 kloc.err_(Db::errCorrupt);
319 v = cmpr_double( kloc._Frame_moment(), kloc->v_Frame_moment.size(),
320 vloc._Frame_moment(), vloc->v_Frame_moment.size());
321 if( v != 0 ) return v;
322 v = cmpr_int(kloc._id(), kloc._id_size(),
323 vloc._id(), vloc._id_size());
324 if( v != 0 ) return v;
328 int Video_frameLoc::Allocate()
330 if_err( allocate() );
331 if( !addr_wr() ) return err_(Db::errNoMemory);
336 int Video_frameLoc::Construct()
338 if_err( insertProhibit() );
339 if_err( construct() );
341 { rkey_Frame_weight rkey(*this);
342 if_err( entity->index("Frame_weight")->Insert(rkey,&id) ); }
343 { rkey_Frame_center rkey(*this);
344 if_err( entity->index("Frame_center")->Insert(rkey,&id) ); }
345 if_err( insertCascade() );
349 int Video_frameLoc::Destruct()
351 if_err( deleteProhibit() );
352 { rkey_Frame_weight rkey(*this);
353 if_err( entity->index("Frame_weight")->Delete(rkey) ); }
354 { rkey_Frame_center rkey(*this);
355 if_err( entity->index("Frame_center")->Delete(rkey) ); }
356 if_err( destruct() );
357 if_err( deleteCascade() );
361 void Video_frameLoc::Deallocate()
368 int TimelineLoc::ikey_Timelines::
369 cmpr(char *a, char *b)
371 ikey_Timelines *kp = (ikey_Timelines *)a;
373 if( kp->v_id == v ) return 0;
374 TimelineLoc vloc(kp->loc.entity);
376 vloc.err_(Db::errCorrupt);
377 v = cmpr_uint( kp->v_Frame_id.addr(), kp->v_Frame_id.size(),
378 vloc._Frame_id(), vloc->v_Frame_id.size());
379 if( v != 0 ) return v;
380 if( kp->v_id >= 0 ) {
381 v = cmpr_int(&kp->v_id, sizeof(kp->v_id),
382 vloc._id(), vloc._id_size());
383 if( v != 0 ) return v;
388 int TimelineLoc::rkey_Timelines::
389 cmpr(char *a, char *b)
391 rkey_Timelines *kp = (rkey_Timelines *)a;
392 TimelineLoc &kloc = (TimelineLoc&)kp->loc;
393 int v = kloc->id, b_id = *(int*)b;
394 if( v == b_id ) return 0;
395 TimelineLoc vloc(kloc.entity);
396 if( vloc.FindId(b_id) )
397 kloc.err_(Db::errCorrupt);
398 v = cmpr_uint( kloc._Frame_id(), kloc->v_Frame_id.size(),
399 vloc._Frame_id(), vloc->v_Frame_id.size());
400 if( v != 0 ) return v;
401 v = cmpr_int(kloc._id(), kloc._id_size(),
402 vloc._id(), vloc._id_size());
403 if( v != 0 ) return v;
407 int TimelineLoc::ikey_Sequences::
408 cmpr(char *a, char *b)
410 ikey_Sequences *kp = (ikey_Sequences *)a;
412 TimelineLoc vloc(kp->loc.entity);
414 vloc.err_(Db::errCorrupt);
415 v = cmpr_uint( kp->v_Clip_id.addr(), kp->v_Clip_id.size(),
416 vloc._Clip_id(), vloc->v_Clip_id.size());
417 if( v != 0 ) return v;
418 v = cmpr_uint( kp->v_Sequence_no.addr(), kp->v_Sequence_no.size(),
419 vloc._Sequence_no(), vloc->v_Sequence_no.size());
420 if( v != 0 ) return v;
424 int TimelineLoc::rkey_Sequences::
425 cmpr(char *a, char *b)
427 rkey_Sequences *kp = (rkey_Sequences *)a;
428 TimelineLoc &kloc = (TimelineLoc&)kp->loc;
429 int v = kloc->id, b_id = *(int*)b;
430 if( v == b_id ) return 0;
431 TimelineLoc vloc(kloc.entity);
432 if( vloc.FindId(b_id) )
433 kloc.err_(Db::errCorrupt);
434 v = cmpr_uint( kloc._Clip_id(), kloc->v_Clip_id.size(),
435 vloc._Clip_id(), vloc->v_Clip_id.size());
436 if( v != 0 ) return v;
437 v = cmpr_uint( kloc._Sequence_no(), kloc->v_Sequence_no.size(),
438 vloc._Sequence_no(), vloc->v_Sequence_no.size());
439 if( v != 0 ) return v;
443 int TimelineLoc::Allocate()
445 if_err( allocate() );
446 if( !addr_wr() ) return err_(Db::errNoMemory);
450 int TimelineLoc::Construct()
452 if_err( insertProhibit() );
453 if_err( construct() );
455 { rkey_Timelines rkey(*this);
456 if_err( entity->index("Timelines")->Insert(rkey,&id) ); }
457 { rkey_Sequences rkey(*this);
458 if_err( entity->index("Sequences")->Insert(rkey,&id) ); }
459 if_err( insertCascade() );
463 int TimelineLoc::Destruct()
465 if_err( deleteProhibit() );
466 { rkey_Timelines rkey(*this);
467 if_err( entity->index("Timelines")->Delete(rkey) ); }
468 { rkey_Sequences rkey(*this);
469 if_err( entity->index("Sequences")->Delete(rkey) ); }
470 if_err( destruct() );
471 if_err( deleteCascade() );
475 void TimelineLoc::Deallocate()
481 int Clip_setLoc::ikey_Clip_title::
482 cmpr(char *a, char *b)
484 ikey_Clip_title *kp = (ikey_Clip_title *)a;
486 if( kp->v_id == v ) return 0;
487 Clip_setLoc vloc(kp->loc.entity);
489 vloc.err_(Db::errCorrupt);
490 v = cmpr_char( kp->v_Title.addr(), kp->v_Title.size(),
491 vloc._Title(), vloc->v_Title.size());
492 if( v != 0 ) return v;
493 if( kp->v_id >= 0 ) {
494 v = cmpr_int(&kp->v_id, sizeof(kp->v_id),
495 vloc._id(), vloc._id_size());
496 if( v != 0 ) return v;
501 int Clip_setLoc::rkey_Clip_title::
502 cmpr(char *a, char *b)
504 rkey_Clip_title *kp = (rkey_Clip_title *)a;
505 Clip_setLoc &kloc = (Clip_setLoc&)kp->loc;
506 int v = kloc->id, b_id = *(int*)b;
507 if( v == b_id ) return 0;
508 Clip_setLoc vloc(kloc.entity);
509 if( vloc.FindId(b_id) )
510 kloc.err_(Db::errCorrupt);
511 v = cmpr_char( kloc._Title(), kloc->v_Title.size(),
512 vloc._Title(), vloc->v_Title.size());
513 if( v != 0 ) return v;
514 v = cmpr_int(kloc._id(), kloc._id_size(),
515 vloc._id(), vloc._id_size());
516 if( v != 0 ) return v;
520 int Clip_setLoc::ikey_Clip_system_time::
521 cmpr(char *a, char *b)
523 ikey_Clip_system_time *kp = (ikey_Clip_system_time *)a;
525 if( kp->v_id == v ) return 0;
526 Clip_setLoc vloc(kp->loc.entity);
528 vloc.err_(Db::errCorrupt);
529 v = cmpr_long( kp->v_System_time.addr(), kp->v_System_time.size(),
530 vloc._System_time(), vloc->v_System_time.size());
531 if( v != 0 ) return v;
532 if( kp->v_id >= 0 ) {
533 v = cmpr_int(&kp->v_id, sizeof(kp->v_id),
534 vloc._id(), vloc._id_size());
535 if( v != 0 ) return v;
540 int Clip_setLoc::rkey_Clip_system_time::
541 cmpr(char *a, char *b)
543 rkey_Clip_system_time *kp = (rkey_Clip_system_time *)a;
544 Clip_setLoc &kloc = (Clip_setLoc&)kp->loc;
545 int v = kloc->id, b_id = *(int*)b;
546 if( v == b_id ) return 0;
547 Clip_setLoc vloc(kloc.entity);
548 if( vloc.FindId(b_id) )
549 kloc.err_(Db::errCorrupt);
550 v = cmpr_long( kloc._System_time(), kloc->v_System_time.size(),
551 vloc._System_time(), vloc->v_System_time.size());
552 if( v != 0 ) return v;
553 v = cmpr_int(kloc._id(), kloc._id_size(),
554 vloc._id(), vloc._id_size());
555 if( v != 0 ) return v;
559 int Clip_setLoc::ikey_Clip_creation_time::
560 cmpr(char *a, char *b)
562 ikey_Clip_creation_time *kp = (ikey_Clip_creation_time *)a;
564 if( kp->v_id == v ) return 0;
565 Clip_setLoc vloc(kp->loc.entity);
567 vloc.err_(Db::errCorrupt);
568 v = cmpr_long( kp->v_Creation_time.addr(), kp->v_Creation_time.size(),
569 vloc._Creation_time(), vloc->v_Creation_time.size());
570 if( v != 0 ) return v;
571 if( kp->v_id >= 0 ) {
572 v = cmpr_int(&kp->v_id, sizeof(kp->v_id),
573 vloc._id(), vloc._id_size());
574 if( v != 0 ) return v;
579 int Clip_setLoc::rkey_Clip_creation_time::
580 cmpr(char *a, char *b)
582 rkey_Clip_creation_time *kp = (rkey_Clip_creation_time *)a;
583 Clip_setLoc &kloc = (Clip_setLoc&)kp->loc;
584 int v = kloc->id, b_id = *(int*)b;
585 if( v == b_id ) return 0;
586 Clip_setLoc vloc(kloc.entity);
587 if( vloc.FindId(b_id) )
588 kloc.err_(Db::errCorrupt);
589 v = cmpr_long( kloc._Creation_time(), kloc->v_Creation_time.size(),
590 vloc._Creation_time(), vloc->v_Creation_time.size());
591 if( v != 0 ) return v;
592 v = cmpr_int(kloc._id(), kloc._id_size(),
593 vloc._id(), vloc._id_size());
594 if( v != 0 ) return v;
598 int Clip_setLoc::Allocate()
600 if_err( allocate() );
601 if( !addr_wr() ) return err_(Db::errNoMemory);
604 Asset_path((char *)"",0);
608 int Clip_setLoc::Construct()
610 if_err( insertProhibit() );
611 if_err( construct() );
613 { rkey_Clip_title rkey(*this);
614 if_err( entity->index("Clip_title")->Insert(rkey,&id) ); }
615 { rkey_Clip_system_time rkey(*this);
616 if_err( entity->index("Clip_system_time")->Insert(rkey,&id) ); }
617 { rkey_Clip_creation_time rkey(*this);
618 if_err( entity->index("Clip_creation_time")->Insert(rkey,&id) ); }
619 if_err( insertCascade() );
623 int Clip_setLoc::Destruct()
625 if_err( deleteProhibit() );
626 { rkey_Clip_title rkey(*this);
627 if_err( entity->index("Clip_title")->Delete(rkey) ); }
628 { rkey_Clip_system_time rkey(*this);
629 if_err( entity->index("Clip_system_time")->Delete(rkey) ); }
630 { rkey_Clip_creation_time rkey(*this);
631 if_err( entity->index("Clip_creation_time")->Delete(rkey) ); }
632 if_err( destruct() );
633 if_err( deleteCascade() );
637 void Clip_setLoc::Deallocate()
644 int Clip_viewsLoc::ikey_Clip_access::
645 cmpr(char *a, char *b)
647 ikey_Clip_access *kp = (ikey_Clip_access *)a;
649 Clip_viewsLoc vloc(kp->loc.entity);
651 vloc.err_(Db::errCorrupt);
652 v = cmpr_uint( kp->v_Access_clip_id.addr(), kp->v_Access_clip_id.size(),
653 vloc._Access_clip_id(), vloc->v_Access_clip_id.size());
654 if( v != 0 ) return v;
658 int Clip_viewsLoc::rkey_Clip_access::
659 cmpr(char *a, char *b)
661 rkey_Clip_access *kp = (rkey_Clip_access *)a;
662 Clip_viewsLoc &kloc = (Clip_viewsLoc&)kp->loc;
663 int v = kloc->id, b_id = *(int*)b;
664 if( v == b_id ) return 0;
665 Clip_viewsLoc vloc(kloc.entity);
666 if( vloc.FindId(b_id) )
667 kloc.err_(Db::errCorrupt);
668 v = cmpr_uint( kloc._Access_clip_id(), kloc->v_Access_clip_id.size(),
669 vloc._Access_clip_id(), vloc->v_Access_clip_id.size());
670 if( v != 0 ) return v;
674 int Clip_viewsLoc::ikey_Last_view::
675 cmpr(char *a, char *b)
677 ikey_Last_view *kp = (ikey_Last_view *)a;
679 if( kp->v_id == v ) return 0;
680 Clip_viewsLoc vloc(kp->loc.entity);
682 vloc.err_(Db::errCorrupt);
683 v = cmpr_long( kp->v_Access_time.addr(), kp->v_Access_time.size(),
684 vloc._Access_time(), vloc->v_Access_time.size());
685 if( v != 0 ) return v;
686 if( kp->v_id >= 0 ) {
687 v = cmpr_int(&kp->v_id, sizeof(kp->v_id),
688 vloc._id(), vloc._id_size());
689 if( v != 0 ) return v;
694 int Clip_viewsLoc::rkey_Last_view::
695 cmpr(char *a, char *b)
697 rkey_Last_view *kp = (rkey_Last_view *)a;
698 Clip_viewsLoc &kloc = (Clip_viewsLoc&)kp->loc;
699 int v = kloc->id, b_id = *(int*)b;
700 if( v == b_id ) return 0;
701 Clip_viewsLoc vloc(kloc.entity);
702 if( vloc.FindId(b_id) )
703 kloc.err_(Db::errCorrupt);
704 v = cmpr_long( kloc._Access_time(), kloc->v_Access_time.size(),
705 vloc._Access_time(), vloc->v_Access_time.size());
706 if( v != 0 ) return v;
707 v = cmpr_int(kloc._id(), kloc._id_size(),
708 vloc._id(), vloc._id_size());
709 if( v != 0 ) return v;
713 int Clip_viewsLoc::ikey_Total_views::
714 cmpr(char *a, char *b)
716 ikey_Total_views *kp = (ikey_Total_views *)a;
718 if( kp->v_id == v ) return 0;
719 Clip_viewsLoc vloc(kp->loc.entity);
721 vloc.err_(Db::errCorrupt);
722 v = cmpr_uint( kp->v_Access_count.addr(), kp->v_Access_count.size(),
723 vloc._Access_count(), vloc->v_Access_count.size());
724 if( v != 0 ) return v;
725 v = cmpr_uint( kp->v_Access_clip_id.addr(), kp->v_Access_clip_id.size(),
726 vloc._Access_clip_id(), vloc->v_Access_clip_id.size());
727 if( v != 0 ) return v;
728 if( kp->v_id >= 0 ) {
729 v = cmpr_int(&kp->v_id, sizeof(kp->v_id),
730 vloc._id(), vloc._id_size());
731 if( v != 0 ) return v;
736 int Clip_viewsLoc::rkey_Total_views::
737 cmpr(char *a, char *b)
739 rkey_Total_views *kp = (rkey_Total_views *)a;
740 Clip_viewsLoc &kloc = (Clip_viewsLoc&)kp->loc;
741 int v = kloc->id, b_id = *(int*)b;
742 if( v == b_id ) return 0;
743 Clip_viewsLoc vloc(kloc.entity);
744 if( vloc.FindId(b_id) )
745 kloc.err_(Db::errCorrupt);
746 v = cmpr_uint( kloc._Access_count(), kloc->v_Access_count.size(),
747 vloc._Access_count(), vloc->v_Access_count.size());
748 if( v != 0 ) return v;
749 v = cmpr_uint( kloc._Access_clip_id(), kloc->v_Access_clip_id.size(),
750 vloc._Access_clip_id(), vloc->v_Access_clip_id.size());
751 if( v != 0 ) return v;
752 v = cmpr_int(kloc._id(), kloc._id_size(),
753 vloc._id(), vloc._id_size());
754 if( v != 0 ) return v;
758 int Clip_viewsLoc::Allocate()
760 if_err( allocate() );
761 if( !addr_wr() ) return err_(Db::errNoMemory);
765 int Clip_viewsLoc::Construct()
767 if_err( insertProhibit() );
768 if_err( construct() );
770 { rkey_Clip_access rkey(*this);
771 if_err( entity->index("Clip_access")->Insert(rkey,&id) ); }
772 { rkey_Last_view rkey(*this);
773 if_err( entity->index("Last_view")->Insert(rkey,&id) ); }
774 { rkey_Total_views rkey(*this);
775 if_err( entity->index("Total_views")->Insert(rkey,&id) ); }
776 if_err( insertCascade() );
780 int Clip_viewsLoc::Destruct()
782 if_err( deleteProhibit() );
783 { rkey_Clip_access rkey(*this);
784 if_err( entity->index("Clip_access")->Delete(rkey) ); }
785 { rkey_Last_view rkey(*this);
786 if_err( entity->index("Last_view")->Delete(rkey) ); }
787 { rkey_Total_views rkey(*this);
788 if_err( entity->index("Total_views")->Delete(rkey) ); }
789 if_err( destruct() );
790 if_err( deleteCascade() );
794 void Clip_viewsLoc::Deallocate()
799 class theDb : public Db {
806 Entity Video_frame; Video_frameLoc video_frame;
807 Entity Timeline; TimelineLoc timeline;
808 Entity Clip_set; Clip_setLoc clip_set;
809 Entity Clip_views; Clip_viewsLoc clip_views;
811 int create(const char *dfn);
812 int open(const char *dfn, int key=-1);
813 int access(const char *dfn, int key=-1, int rw=0);
815 int attach(int rw=0) { return Db::attach(rw); }
816 int detach() { return Db::detach(); }
819 ~theDb() { finit(objects); }
831 create(const char *dfn)
833 dfd = ::open(dfn,O_RDWR+O_CREAT+O_TRUNC+O_NOATIME,0666);
834 if( dfd < 0 ) { perror(dfn); return -1; }
835 int ret = db_create();
843 if_ret( Db::make(dfd) );
844 if_ret( Video_frame.new_entity("Video_frame", sizeof(Video_frameObj)) );
845 if_ret( Video_frame.add_kindex("Frame_weight") );
846 if_ret( Video_frame.add_kindex("Frame_center") );
848 if_ret( Timeline.new_entity("Timeline", sizeof(TimelineObj)) );
849 if_ret( Timeline.add_kindex("Timelines") );
850 if_ret( Timeline.add_kindex("Sequences") );
852 if_ret( Clip_set.new_entity("Clip_set", sizeof(Clip_setObj)) );
853 if_ret( Clip_set.add_kindex("Clip_title") );
854 if_ret( Clip_set.add_kindex("Clip_system_time") );
855 if_ret( Clip_set.add_kindex("Clip_creation_time") );
857 if_ret( Clip_views.new_entity("Clip_views", sizeof(Clip_viewsObj)) );
858 if_ret( Clip_views.add_kindex("Clip_access") );
859 if_ret( Clip_views.add_kindex("Last_view") );
860 if_ret( Clip_views.add_kindex("Total_views") );
862 if_ret( Db::commit(1) );
868 : dfd(-1), dkey(-1), objects(0),
869 Video_frame(this), video_frame(Video_frame),
870 Timeline(this), timeline(Timeline),
871 Clip_set(this), clip_set(Clip_set),
872 Clip_views(this), clip_views(Clip_views)
874 objects = new ObjectList(objects, video_frame);
875 objects = new ObjectList(objects, timeline);
876 objects = new ObjectList(objects, clip_set);
877 objects = new ObjectList(objects, clip_views);
878 Video_frame.add_vref((vRef)&Video_frameObj::v_Frame_data);
879 Clip_set.add_vref((vRef)&Clip_setObj::v_Title);
880 Clip_set.add_vref((vRef)&Clip_setObj::v_Asset_path);
881 Clip_set.add_vref((vRef)&Clip_setObj::v_Weights);
885 open(const char *dfn, int key)
887 dfd = ::open(dfn,O_RDWR+O_NOATIME);
888 if( dfd < 0 ) { perror(dfn); return errNotFound; }
889 if( (dkey=key) >= 0 ) Db::use_shm(1);
890 int ret = Db::open(dfd, dkey);
891 if( !ret ) ret = db_open();
899 if_ret( Video_frame.get_entity("Video_frame") );
900 if_ret( Video_frame.key_index("Frame_weight") );
901 if_ret( Video_frame.key_index("Frame_center") );
903 if_ret( Timeline.get_entity("Timeline") );
904 if_ret( Timeline.key_index("Timelines") );
905 if_ret( Timeline.key_index("Sequences") );
907 if_ret( Clip_set.get_entity("Clip_set") );
908 if_ret( Clip_set.key_index("Clip_title") );
909 if_ret( Clip_set.key_index("Clip_system_time") );
910 if_ret( Clip_set.key_index("Clip_creation_time") );
912 if_ret( Clip_views.get_entity("Clip_views") );
913 if_ret( Clip_views.key_index("Clip_access") );
914 if_ret( Clip_views.key_index("Last_view") );
915 if_ret( Clip_views.key_index("Total_views") );
917 if_ret( Db::start_transaction() );
925 if( dfd >= 0 ) { ::close(dfd); dfd = -1; }
929 access(const char *dfn, int key, int rw)
931 if( key < 0 ) return Db::errInvalid;
932 dfd = ::open(dfn,O_RDWR+O_NOATIME);
933 if( dfd < 0 ) { perror(dfn); return Db::errNotFound; }
934 dkey = key; Db::use_shm(1);
935 int ret = Db::attach(dfd, dkey, rw);
936 if( !ret ) ret = db_access();
937 else if( ret == errNotFound ) {
938 ret = Db::open(dfd, dkey);
939 if( !ret ) ret = db_open();
940 if( !ret ) ret = Db::attach(rw);
949 if_ret( Video_frame.get_entity("Video_frame") );
950 if_ret( Timeline.get_entity("Timeline") );
951 if_ret( Clip_set.get_entity("Clip_set") );
952 if_ret( Clip_views.get_entity("Clip_views") );