=?gb2312?q?=BB=D8=B8=B4=A3=BA=20Re:=20[mythtv-users]=20Think=20table=20as?= =?gb2312?q?=20Class=20and=20record=20as=20Object?=

YanJun Lu mythtv_sybaselu at yahoo.com.cn
Mon Jan 16 06:43:40 UTC 2006


Thanks for your deep explaintation. It's well known that  MythTV's architecture  
with OOP thinking, It's programming  with Class of Application or Interface(my English is poor ,Maybe I can explain what I am thinking), For example, There are a lots  of Class of  Application or  Interface in  ../libmythtv:
           tv_play.h/tv_rec.h/channelbase.h/channel.h/recordedbase.h/dtvrecorder.h/
  and so on. recoderbase is base Class, it was derived by DVBRecorder/HDTVRecorder/FireWareRecorder. channelbase is base class ,it also was derived by others. So I thinks Tables as Class and Record as Object is very different from MythTV's architecture. There are only four core tables for handle  Channel/Program(i.e channel/program/record/recorded), These tables are  dependent in OS/Application/Hardware, So I define these tables as follow:
 Class ChannelInfo
 {
        public:
                 ...
            void getChannelInfo();
            void setChannelInfo();
            
            void ChangeContrast();
            void ChangeHue();
            void ChangeBrightness();
  
            void ChannelUp();
            void ChannelDown();
            
            void CheckChannelSignal();
            ...
            datatype chanid;
            datatype channum;
            datatype callsign;
            ...
 }
 Class ProgramInfo
 {
        public:
           ...
           void getProgramInfo();
           void setProgramInfo();
           
            ...
            datatype chanid;  //pk(chanid)
            datatype starttime; //pk(starttime)
            ...
 }
 Class RecordInfo
 {
        public:
           ...
           void getRecordInfo();
           void setRecordInfo();
           ...
           void getRecType();
           void getRecStatus();
           void getRecPrority();
           ...
           void isTimeslot();
           void isSameProgram();
           void isConflicting();
 }
 My question is how can I to define the methond of Class, That is my assume on above NOT ture for really. 
 Thanks 
David Rudder <drig at noses.org> дµÀ£º I think this is a good idea, but it's not as easy as all that. This is a 
fairly standard programming problem. The problem with simply modeling 
each table as a class is that it doesn't take into account foreign 
relationships. For instance, with the CardInput class, you'd want to be 
able to store a reference to the CaptureCard class, not just an integer 
CardID. So, you can say "CaptureCard card = cardInput.getCaptureCard()" 
and it will return a CaptureCard. Rather than having to say "CaptureCard 
card = database.loadCaptureCard(cardInput.getCaptureCard())".

I guess what I'm saying is that I think you have a good beginning here 
to make some very useful automation code, but you have to be careful 
that your classes match the data model, or it'll end up being difficult 
to use.

There's a Java project called Druid (available in Sourceforge. Search 
google for it). It'll automatically generate C, C++ or Java code for 
representing the data. It should help you get started.

Feel free to email me off line at
drig at noses dot org

-Dave

P.S. I also have 45 tables.
P.P.S. Once you have the database modeled in code, what are you going to 
do with it? Any cool tools?

YanJun Lu wrote:

> Hi All
> How many tables in your database of MythTV,As for me, There are 45 
> tables in my MySQL. I have a idea for that create Class for every 
> tables, Well, I mean that we can think table as an Class and record of 
> table as Object, So do my idea is good?
>
> ------------------------------------------------------------------------
> ÑÅ»¢1GÃâ·ÑÓÊÏä°Ù·Ö°Ù·ÀÀ¬»øÐÅ 
> ÑÅ»¢ÖúÊÖ-ËÑË÷¡¢É±¶¾¡¢·ÀɧÈÅ 
>
>------------------------------------------------------------------------
>
>_______________________________________________
>mythtv-users mailing list
>mythtv-users at mythtv.org
>http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
>  
>


_______________________________________________
mythtv-users mailing list
mythtv-users at mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users



__________________________________________________
¸Ï¿ì×¢²áÑÅ»¢³¬´óÈÝÁ¿Ãâ·ÑÓÊÏä?
http://cn.mail.yahoo.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mythtv.org/pipermail/mythtv-users/attachments/20060116/e5dbb023/attachment.htm


More information about the mythtv-users mailing list