A presentation made for the AngularJS-IL meetup group that took place in oct 2014 at Google TLV Campus (http://www.meetup.com/AngularJS-IL/events/207559572/)
its an overview of how to use services in your app. this slideshow contain a link for a reference code on github.
(link in the last slide)
This document provides an overview and plan for learning JavaScript. It covers introductory topics like variables, operators, functions, loops, and events. It also explains why JavaScript is important for web development as one of the three main languages, along with HTML and CSS. The document outlines how to integrate JavaScript into HTML pages and defines common JavaScript concepts.
This document discusses methods in C#, including how they are declared, invoked, and used. It covers key concepts like the main method, passing parameters by value and reference, output parameters, variable argument lists, and method overloading. Methods are declared inside classes and give objects their behavioral characteristics by allowing processing of data and responses to messages from other objects. The main method is the starting point of all C# programs and must be static. Parameters can be passed by value or reference, and output parameters pass results back using the out keyword. Variable argument lists use params arrays, and overloading methods have the same name but different parameters.
Presentation provides introduction and detailed explanation of the Java 8 Lambda and Streams. Lambda covers with Method references, default methods and Streams covers with stream operations,types of streams, collectors. Also streams are elaborated with parallel streams and benchmarking comparison of sequential and parallel streams.
Additional slides are covered with Optional, Splitators, certain projects based on lambda and streams
WebGL uses ArrayBuffers and typed arrays to transfer data to the GPU. ArrayBuffers represent unstructured binary data that can be modified by typed array views of the buffer, such as Int8Array or Float32Array views. Views can reference the whole buffer or a subset of it, and methods like set() are used to populate the views and transfer data to WebGL buffers.
The document discusses different approaches to object-oriented programming in JavaScript, including classical and prototypal inheritance, constructor functions, and the prototype property. It explains how prototypal inheritance works by linking objects together through their internal prototype properties. Constructor functions and the new operator allow simulating classical inheritance by establishing prototype links. Various design patterns are also covered, such as public/privileged methods, singletons, modules, and parasitic inheritance.
Inheritance allows one class to inherit properties and behaviors from another base class. There are two main types of inheritance: implementation inheritance, where a derived class takes on all members of the base class; and interface inheritance, where a derived class inherits only function signatures without implementations. Key aspects of inheritance in C# include defining virtual methods that can be overridden, using modifiers like sealed to restrict inheritance, and implementing interfaces that define common behaviors without implementations.
O documento discute a criação de interfaces gráficas em Java usando a biblioteca Swing. Ele explica como criar janelas, painéis, componentes gráficos como rótulos, caixas de texto e botões e como conectá-los. Além disso, apresenta outros objetos gráficos como áreas de texto e métodos importantes para manipular esses objetos. Por fim, sugere como criar uma classe que herda de JFrame para encapsular a janela e seus componentes.
A presentation made for the AngularJS-IL meetup group that took place in oct 2014 at Google TLV Campus (http://www.meetup.com/AngularJS-IL/events/207559572/)
its an overview of how to use services in your app. this slideshow contain a link for a reference code on github.
(link in the last slide)
This document provides an overview and plan for learning JavaScript. It covers introductory topics like variables, operators, functions, loops, and events. It also explains why JavaScript is important for web development as one of the three main languages, along with HTML and CSS. The document outlines how to integrate JavaScript into HTML pages and defines common JavaScript concepts.
This document discusses methods in C#, including how they are declared, invoked, and used. It covers key concepts like the main method, passing parameters by value and reference, output parameters, variable argument lists, and method overloading. Methods are declared inside classes and give objects their behavioral characteristics by allowing processing of data and responses to messages from other objects. The main method is the starting point of all C# programs and must be static. Parameters can be passed by value or reference, and output parameters pass results back using the out keyword. Variable argument lists use params arrays, and overloading methods have the same name but different parameters.
Presentation provides introduction and detailed explanation of the Java 8 Lambda and Streams. Lambda covers with Method references, default methods and Streams covers with stream operations,types of streams, collectors. Also streams are elaborated with parallel streams and benchmarking comparison of sequential and parallel streams.
Additional slides are covered with Optional, Splitators, certain projects based on lambda and streams
WebGL uses ArrayBuffers and typed arrays to transfer data to the GPU. ArrayBuffers represent unstructured binary data that can be modified by typed array views of the buffer, such as Int8Array or Float32Array views. Views can reference the whole buffer or a subset of it, and methods like set() are used to populate the views and transfer data to WebGL buffers.
The document discusses different approaches to object-oriented programming in JavaScript, including classical and prototypal inheritance, constructor functions, and the prototype property. It explains how prototypal inheritance works by linking objects together through their internal prototype properties. Constructor functions and the new operator allow simulating classical inheritance by establishing prototype links. Various design patterns are also covered, such as public/privileged methods, singletons, modules, and parasitic inheritance.
Inheritance allows one class to inherit properties and behaviors from another base class. There are two main types of inheritance: implementation inheritance, where a derived class takes on all members of the base class; and interface inheritance, where a derived class inherits only function signatures without implementations. Key aspects of inheritance in C# include defining virtual methods that can be overridden, using modifiers like sealed to restrict inheritance, and implementing interfaces that define common behaviors without implementations.
O documento discute a criação de interfaces gráficas em Java usando a biblioteca Swing. Ele explica como criar janelas, painéis, componentes gráficos como rótulos, caixas de texto e botões e como conectá-los. Além disso, apresenta outros objetos gráficos como áreas de texto e métodos importantes para manipular esses objetos. Por fim, sugere como criar uma classe que herda de JFrame para encapsular a janela e seus componentes.
This document discusses packages in Java. It defines a package as a mechanism to encapsulate a group of classes, subpackages, and interfaces. Packages are used to prevent naming conflicts, make classes and interfaces easier to locate and use, and provide access control. Package names are related to directory structure, and packages can be considered a form of data encapsulation. The document also discusses built-in packages that are part of the Java API, as well as how to define and use user-defined packages through directory structure and import statements.
The document provides an overview of JavaScript design patterns including creational, structural, and behavioral patterns. It discusses common patterns like the module pattern, prototype pattern, factory pattern, decorator pattern, observer pattern, and more. Code examples are provided to demonstrate how each pattern works in JavaScript.
Padrões de projeto - Adapter, Proxy, Composite e BridgeLorran Pegoretti
O documento discute padrões de projeto de software, abordando especificamente os padrões Adapter, Proxy e Composite. O Adapter permite que classes com interfaces incompatíveis trabalhem juntas, o Proxy controla o acesso a um objeto e o Composite trata objetos compostos e individuais de forma uniforme.
C# is similar to C++ but easier to use, as it does not support pointers, multiple inheritance, header files or global variables. Everything must live within a class or struct. The basic syntax will be familiar to C++ programmers. Key features include properties, interfaces, foreach loops, and delegates for event handling. Properties allow custom getter and setter logic and are preferred over public fields. Delegates provide a type-safe way to link methods, and events build on this to prevent issues with multicast delegates. Generics and assemblies are analogous to C++ templates and deployment units.
O documento discute o conceito de herança em programação orientada a objetos. Explica que a herança permite a reutilização de código através da criação de novas subclasses que herdam atributos e métodos de classes existentes (superclasses), permitindo economia de tempo no desenvolvimento de software. Detalha os conceitos de superclasse, subclasses, hierarquia de classes e relacionamentos entre classes, como herança simples e múltipla.
The document discusses reflection in C# and .NET. Reflection allows a program to obtain metadata about types defined in assemblies to access type information at runtime. It enables examining assemblies, modules, types and their members. The System.Reflection namespace contains classes like Type and Assembly that provide metadata about types, assemblies and members. Reflection allows dynamically loading assemblies, late binding without compile-time type knowledge, and examining/invoking members by name.
O documento apresenta exemplos de manipulação de datas em Java utilizando as classes Date e Calendar. São mostrados exemplos de como pegar a data atual, definir datas explicitamente, comparar datas, converter entre Date e String em diferentes formatos e recuperar partes específicas como dia, mês e ano.
As wrapper classes no Java encapsulam tipos primitivos em objetos, permitindo que esses tipos sejam usados em coleções e outros contextos que requerem objetos. Cada tipo primitivo tem uma classe wrapper correspondente, como Integer para int e Float para float. As classes wrapper também fornecem métodos para conversão entre tipos primitivos e strings.
Previously we had begin with Java Tutorial beginners guide featuring – What is Java , features of Java Programming Language , Java editors and different Java editions and Java Application Types . Now on Java tutorial we begin with the section 2 that is about JVM – Java Virtual Machine . And also about the difference between JDK Vs JRE Vs JVM including other aspects of Java Virtual Machine .
https://maccablo.com/java-virtual-machine-jdk-jre-jvm/
The document discusses JavaScript events and event handling. It covers the different phases of events, how to define event handlers, the event object, and how to cancel bubbling and override default browser actions. It also provides examples of handling mouse and keyboard events, such as changing an element's style on mouseover and logging key events.
Slide 1
TypeScript
* This presentation is to show TypeScript's major feature and the benefit that it brings to your JavaScript projects.
* Our main objective is just to spark interest especially to those not familiar with the tool.
Slide 2
- What is TypeScript
* go to next slide
Slide 3
- Is a superset of JavaScript
* it simply means an extension to JavaScript
- Use JavaScript code on TypeScript
* JS code naturally works on TypeScript
* Which also means your beloved JavaScript libraries such as JQuery, or your fancy interacive plugins would work as well.
- TypeScript compiles to plain old JavaScript
* TS code compiles to simple and clean JS.
Slide 4
- Screenshot of TS compiled to JS
* In this example, compiling a TS class code would result to a JS version, and a regular JavaScript function when compiled is basically untouched.
Slide 5
- TypeScript's Main Feature
* So what does TS provide us with? What does it actually do?
Slide 6
- Static Type Checking
* TypeScript allows us to enable type checking by defining data types to your for ex. variables, function parameters and return types.
Slide 7
- Screenshot of basic Static Type Checking
* In this example…
* What I've done here was to assign supposedly wrong values for what the variables or parameters were meant to hold
* As JavaScript is a dynamic and untyped language these expressions would either fail or be okay when you run it on your browser.
* In TypeScript by enabling static type checking these potential errors are caught earlier (see the red marks on the expressions) and wouldn't even allow you to compile unless these are resolved.
* In addition you can also type arrays and object literals
Slide 8
- Effects of Static Type Checking
* As TS code is statically type-checked a side effect of such...
- Allows IDEs to perform live error checks
- Exposes auto-completion and code hinting
Slide 9
- Screenshot of code hinting
* Say I was coding JQuery on regular JavaScript code there would be no natural way to help me identify its class properties, methods and parameters... except through reading the API documentation or a separate plugin.
* As a result of static type checking this allows IDE's to access these class members as code hints
* So if this was a 3rd party library how much more if you are just referencing your own JavaScript/TypeScript files within your project.
Slide 10
- A few of the other cool features
* That was only the basic feature of TypeScript
* A few of the other cool features are...
Slide 11
- End
Desenvolvendo aplicações com Angular e Laravel no Back-endGiovanny Valente
O documento apresenta Angular e Laravel, abordando: (1) Angular como plataforma para desenvolvimento de interfaces utilizando HTML, CSS e JS; (2) Elementos fundamentais do Angular como templates e componentes; (3) Como Laravel é um framework MVC para PHP que facilita a construção de aplicações; (4) Desenvolvimento de uma aplicação simples utilizando Angular e Laravel integrados.
This document discusses TypeScript, a superset of JavaScript that adds optional static typing and class-based object-oriented programming. It allows developers to gradually introduce typing into JavaScript code for improved productivity and catch errors early. The document covers TypeScript features like interfaces, classes, modules, type definitions, and comparisons to alternatives like CoffeeScript and Dart. It concludes that TypeScript allows gradual adoption of typing while following the future ECMAScript standard.
The document discusses the module pattern, a design pattern for creating reusable components in JavaScript. It describes how the module pattern allows simulating privacy by wrapping code in immediately invoked function expressions (IIFEs) and returning objects instead of functions. This creates a private scope that is not accessible globally while exposing public APIs. Several examples are given of how different libraries like Dojo, jQuery, YUI, and ExtJS implement the module pattern.
A class is a template / blue print is used to create an object. In JavaScript class is a special kind of function. In JavaScript there are two ways to create class one is the class declaration and the second one is class expressions.
This document provides an introduction to JavaScript and its uses for web programming. It explains that JavaScript is a client-side scripting language that allows web pages to become interactive. Some key points covered include:
- JavaScript can change HTML content, styles, validate data, and make calculations.
- Functions are blocks of code that perform tasks when invoked by events or called in code.
- Events like clicks or keyboard presses trigger JavaScript code.
- The DOM (Document Object Model) represents an HTML document that JavaScript can access and modify.
- Forms and user input can be accessed and processed using the DOM.
- Programming flow can be controlled with conditional and loop statements.
-
Pipes and FIFOs allow communication between related processes. Pipes are unidirectional byte streams used to connect the standard output of one process to the standard input of another. FIFOs allow communication between any processes and have names in the file system. Both pipes and FIFOs can experience blocking and deadlocks if processes attempt to read empty or write to full connections. Nonblocking I/O helps prevent these issues.
Tlpi chapter 38 writing secure privileged programsShu-Yu Fu
This document discusses guidelines for securely writing privileged programs. It recommends operating with least privilege by dropping privileges when they are not needed and reacquiring them only as required. It also recommends confining the process using capabilities or chroot jails, being careful of signals and race conditions, avoiding buffer overflows, and checking return values of system calls. The overall aim is to minimize the chances of a privileged program being subverted and to minimize potential damage if subversion occurs.
This document discusses packages in Java. It defines a package as a mechanism to encapsulate a group of classes, subpackages, and interfaces. Packages are used to prevent naming conflicts, make classes and interfaces easier to locate and use, and provide access control. Package names are related to directory structure, and packages can be considered a form of data encapsulation. The document also discusses built-in packages that are part of the Java API, as well as how to define and use user-defined packages through directory structure and import statements.
The document provides an overview of JavaScript design patterns including creational, structural, and behavioral patterns. It discusses common patterns like the module pattern, prototype pattern, factory pattern, decorator pattern, observer pattern, and more. Code examples are provided to demonstrate how each pattern works in JavaScript.
Padrões de projeto - Adapter, Proxy, Composite e BridgeLorran Pegoretti
O documento discute padrões de projeto de software, abordando especificamente os padrões Adapter, Proxy e Composite. O Adapter permite que classes com interfaces incompatíveis trabalhem juntas, o Proxy controla o acesso a um objeto e o Composite trata objetos compostos e individuais de forma uniforme.
C# is similar to C++ but easier to use, as it does not support pointers, multiple inheritance, header files or global variables. Everything must live within a class or struct. The basic syntax will be familiar to C++ programmers. Key features include properties, interfaces, foreach loops, and delegates for event handling. Properties allow custom getter and setter logic and are preferred over public fields. Delegates provide a type-safe way to link methods, and events build on this to prevent issues with multicast delegates. Generics and assemblies are analogous to C++ templates and deployment units.
O documento discute o conceito de herança em programação orientada a objetos. Explica que a herança permite a reutilização de código através da criação de novas subclasses que herdam atributos e métodos de classes existentes (superclasses), permitindo economia de tempo no desenvolvimento de software. Detalha os conceitos de superclasse, subclasses, hierarquia de classes e relacionamentos entre classes, como herança simples e múltipla.
The document discusses reflection in C# and .NET. Reflection allows a program to obtain metadata about types defined in assemblies to access type information at runtime. It enables examining assemblies, modules, types and their members. The System.Reflection namespace contains classes like Type and Assembly that provide metadata about types, assemblies and members. Reflection allows dynamically loading assemblies, late binding without compile-time type knowledge, and examining/invoking members by name.
O documento apresenta exemplos de manipulação de datas em Java utilizando as classes Date e Calendar. São mostrados exemplos de como pegar a data atual, definir datas explicitamente, comparar datas, converter entre Date e String em diferentes formatos e recuperar partes específicas como dia, mês e ano.
As wrapper classes no Java encapsulam tipos primitivos em objetos, permitindo que esses tipos sejam usados em coleções e outros contextos que requerem objetos. Cada tipo primitivo tem uma classe wrapper correspondente, como Integer para int e Float para float. As classes wrapper também fornecem métodos para conversão entre tipos primitivos e strings.
Previously we had begin with Java Tutorial beginners guide featuring – What is Java , features of Java Programming Language , Java editors and different Java editions and Java Application Types . Now on Java tutorial we begin with the section 2 that is about JVM – Java Virtual Machine . And also about the difference between JDK Vs JRE Vs JVM including other aspects of Java Virtual Machine .
https://maccablo.com/java-virtual-machine-jdk-jre-jvm/
The document discusses JavaScript events and event handling. It covers the different phases of events, how to define event handlers, the event object, and how to cancel bubbling and override default browser actions. It also provides examples of handling mouse and keyboard events, such as changing an element's style on mouseover and logging key events.
Slide 1
TypeScript
* This presentation is to show TypeScript's major feature and the benefit that it brings to your JavaScript projects.
* Our main objective is just to spark interest especially to those not familiar with the tool.
Slide 2
- What is TypeScript
* go to next slide
Slide 3
- Is a superset of JavaScript
* it simply means an extension to JavaScript
- Use JavaScript code on TypeScript
* JS code naturally works on TypeScript
* Which also means your beloved JavaScript libraries such as JQuery, or your fancy interacive plugins would work as well.
- TypeScript compiles to plain old JavaScript
* TS code compiles to simple and clean JS.
Slide 4
- Screenshot of TS compiled to JS
* In this example, compiling a TS class code would result to a JS version, and a regular JavaScript function when compiled is basically untouched.
Slide 5
- TypeScript's Main Feature
* So what does TS provide us with? What does it actually do?
Slide 6
- Static Type Checking
* TypeScript allows us to enable type checking by defining data types to your for ex. variables, function parameters and return types.
Slide 7
- Screenshot of basic Static Type Checking
* In this example…
* What I've done here was to assign supposedly wrong values for what the variables or parameters were meant to hold
* As JavaScript is a dynamic and untyped language these expressions would either fail or be okay when you run it on your browser.
* In TypeScript by enabling static type checking these potential errors are caught earlier (see the red marks on the expressions) and wouldn't even allow you to compile unless these are resolved.
* In addition you can also type arrays and object literals
Slide 8
- Effects of Static Type Checking
* As TS code is statically type-checked a side effect of such...
- Allows IDEs to perform live error checks
- Exposes auto-completion and code hinting
Slide 9
- Screenshot of code hinting
* Say I was coding JQuery on regular JavaScript code there would be no natural way to help me identify its class properties, methods and parameters... except through reading the API documentation or a separate plugin.
* As a result of static type checking this allows IDE's to access these class members as code hints
* So if this was a 3rd party library how much more if you are just referencing your own JavaScript/TypeScript files within your project.
Slide 10
- A few of the other cool features
* That was only the basic feature of TypeScript
* A few of the other cool features are...
Slide 11
- End
Desenvolvendo aplicações com Angular e Laravel no Back-endGiovanny Valente
O documento apresenta Angular e Laravel, abordando: (1) Angular como plataforma para desenvolvimento de interfaces utilizando HTML, CSS e JS; (2) Elementos fundamentais do Angular como templates e componentes; (3) Como Laravel é um framework MVC para PHP que facilita a construção de aplicações; (4) Desenvolvimento de uma aplicação simples utilizando Angular e Laravel integrados.
This document discusses TypeScript, a superset of JavaScript that adds optional static typing and class-based object-oriented programming. It allows developers to gradually introduce typing into JavaScript code for improved productivity and catch errors early. The document covers TypeScript features like interfaces, classes, modules, type definitions, and comparisons to alternatives like CoffeeScript and Dart. It concludes that TypeScript allows gradual adoption of typing while following the future ECMAScript standard.
The document discusses the module pattern, a design pattern for creating reusable components in JavaScript. It describes how the module pattern allows simulating privacy by wrapping code in immediately invoked function expressions (IIFEs) and returning objects instead of functions. This creates a private scope that is not accessible globally while exposing public APIs. Several examples are given of how different libraries like Dojo, jQuery, YUI, and ExtJS implement the module pattern.
A class is a template / blue print is used to create an object. In JavaScript class is a special kind of function. In JavaScript there are two ways to create class one is the class declaration and the second one is class expressions.
This document provides an introduction to JavaScript and its uses for web programming. It explains that JavaScript is a client-side scripting language that allows web pages to become interactive. Some key points covered include:
- JavaScript can change HTML content, styles, validate data, and make calculations.
- Functions are blocks of code that perform tasks when invoked by events or called in code.
- Events like clicks or keyboard presses trigger JavaScript code.
- The DOM (Document Object Model) represents an HTML document that JavaScript can access and modify.
- Forms and user input can be accessed and processed using the DOM.
- Programming flow can be controlled with conditional and loop statements.
-
Pipes and FIFOs allow communication between related processes. Pipes are unidirectional byte streams used to connect the standard output of one process to the standard input of another. FIFOs allow communication between any processes and have names in the file system. Both pipes and FIFOs can experience blocking and deadlocks if processes attempt to read empty or write to full connections. Nonblocking I/O helps prevent these issues.
Tlpi chapter 38 writing secure privileged programsShu-Yu Fu
This document discusses guidelines for securely writing privileged programs. It recommends operating with least privilege by dropping privileges when they are not needed and reacquiring them only as required. It also recommends confining the process using capabilities or chroot jails, being careful of signals and race conditions, avoiding buffer overflows, and checking return values of system calls. The overall aim is to minimize the chances of a privileged program being subverted and to minimize potential damage if subversion occurs.
This document summarizes key concepts about file systems in Linux:
1. It describes the structure of file systems including superblocks, inodes, and data blocks. Inodes contain metadata about files and pointers to data blocks.
2. It discusses device files that correspond to devices in the system and are represented in the /dev directory. Each device has a major and minor ID.
3. Journaling file systems like ext4 are described which eliminate the need for lengthy consistency checks after crashes by journaling file system updates.
4. The concept of mounting other file systems at mount points under the single directory hierarchy rooted at / is summarized along with the mount() and umount() system calls.
This chapter describes functions for allocating memory on the heap or stack in C. It discusses brk(), sbrk(), malloc(), and free() for allocating memory on the heap by adjusting the program break and using memory pools. It also covers calloc(), realloc(), memalign(), and alloca() for specialized memory allocation needs, like initializing to zero, resizing blocks, aligned blocks, and stack allocation. Tools for debugging memory allocation like mtrace(), mcheck(), and MALLOC_CHECK are also outlined.
Each process has a unique process ID and maintains its parent's ID. A process's virtual memory is divided into segments like the stack and heap. When a program runs, its command-line arguments and environment are passed via argc/argv and the environ list. The setjmp() and longjmp() functions allow non-local jumps between functions, but their use should be avoided due to restrictions and compiler optimizations that can affect variable values.
The document discusses the PE/COFF file format used in Windows. It explains that PE/COFF is based on the older COFF format, with a PE header added. It describes the different sections contained in a PE/COFF file like .text, .data, .rdata, and debug sections. It also explains the image headers, section tables, and symbol tables contained in the COFF and PE parts of the file format.
15. 頁首在這裡
GObject進階課程
在進階課程裡,我們會瞭解GObject建構和解構的順序,和GObject中的訊號.
類別的建構與解構
在[2]裡有兩張表在解釋GObjec和GObject Interfacet的建構和解構.我們這邊簡單的在這邊再出現一次.
GObject的解構和解構
Invocation time Function Invoked Function's parameters
First call type's base_init function On the inheritance tree of
tog_type_create_instancefor classes from fundamental
target type type to target type. base_init
is invoked once for each class
structure.
target type's class_init function On target type's class structure
interface initialization, see
the section called “Interface
Initialization”
Each call target type's instance_init On object's instance
tog_type_create_instancefor function
target type
Last call interface destruction, see
tog_type_free_instance for the section called “Interface
target type Destruction”
target type's class_finalize On target type's class structure
function
type's base_finalize function On the inheritance tree of
classes from fundamental type
to target type. base_finalize is
invoked once for each class
structure.
GObject Interface的建構
Invocation time Function Invoked Function's parameters Remark
First call interface' base_init On interface' vtable Register interface'
頁尾在這裡
16. 頁首在這裡
tog_type_create_ function signals here (use a
instance for type local static boolean
implementing interface variable as described
above to make sure
not to register them
twice.).
interface' interface_init On interface' vtable Initialize interface'
function implementation.
That is, initialize the
interface method
pointers in the
interface structure
to the function's
implementation.
GObject Interface的解構
Invocation time Function Invoked Function's parameters
Last call to interface' interface_finalize On interface' vtable
g_type_free_instance for type function
implementing interface
interface' base_finalize function On interface' vtable
訊號
在GObject提供了訊號(Signal)這個機制,讓物件操作者可以透過callback函式得知物件狀態改變了,更簡單
的說,訊號是GObject中的觀察者模式(Observer Pattern).
GObject必需在class_init函式裡使用g_signal_new註冊要提供外界觀察的訊號,之後物件操作者才能註冊
callback函式.首先我們在類別結構裡宣告預設的訊號處理函式和一個變數儲存訊號的ID(第27~28行),然後在
class_init函式裡先指定訊號處理函式的位置(第100行)然後再註冊一個訊號(第115~127行),比較特殊的
是,除了訊號處理函式,我們還額外註冊了一個accumulator函式(第120行),緊接著每一次的訊號calback函
式之後accumulator函式就會接著被呼叫一次.
1. /* maman-bar.h */
2. #ifndef __MAMAN_BAR_H__
3. #define __MAMAN_BAR_H__
4. #include <glib-object.h>
5. G_BEGIN_DECLS
6. #define MAMAN_TYPE_BAR (maman_bar_get_type ())
7. #define MAMAN_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAMAN_TYPE_BAR, MamanBar))
8. #define MAMAN_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MAMAN_TYPE_BAR, MamanBarClass))
9. #define MAMAN_IS_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAMAN_TYPE_BAR))
頁尾在這裡