Git Product home page Git Product logo

bsdpatch's Introduction

BSDPatch

####OVERVIEW The basic unit of BSDPatch is the BSDObject class, which is subclassed to perform a specific calculation. Instances of BSDObject subclasses can be used individually, or can be 'chained' by connecting the 'outlet' of an instance to the 'inlet' of one or many other instances. It is helpful to think of this configuration as a signal processing chain -- data flows into an object, the object does something with that data, then sends it downstream to any objects to which it is connected. Data flow is generally unidirectional, i.e. input->output, though you may incorporate feedback loops by connecting downstream outlets to upstream inlets within a chain.

To subclass BSDObject, you must override the -calculateOutputValue method. Optionally you may override the -setupWithArguments: method to configure your subclass. Keep in mind that as in signal processing, the order of operations is very important, so think carefully about how you construct this method in your subclass.

By default, each instance of BSDObject is configured with 1 'hot' inlet, 1 'cold' inlet, and a main outlet. Setting the hot inlet value causes the instance to immediately perform its -calculateOutputValue method and send the result to the main outlet. Setting the cold inlet value simply stores the value for use when the hot inlet value changes. Additional inlets and outlets (ports) can be added by overriding the -setupWithArguments: method. Additional ports are added to the appropriate collections (instances of NSMutableDictionary), so you must specify a name for the port when you add it.

One of my favorite features of the patching idiom is the ability to build more complex objects out of more simple ones. See BSDStdDev as an example.

####USAGE Import the BSDPatch folder into your XCode project. Import "BSDPatch.h" to classes where you'd like to use it. If you'd like to use the convenience intializer BSDCreate for your custom subclasses, import your header file to "BSDObjects.h" and add an appropriate class method to BSDCreate.

####EXAMPLE PROJECT The BSDPatchExample XCode project demonstrates the use of the BSDDistance class to calculate the distance (in points) between arbitrary coordinates in a view. In this example, we use the center of the screen as a reference point (x0,y0) and measure the distance to a user-provided touch (xf,yf) on the screen. The distance value is routed into an instance of BSDPTest (and its instances of BSDAverage and BSDStdDev) to show how these objects can be used to analyze input streams. Take a peek at BSDDistance.m or BSDStdDev.m to get an idea of how to build a subclass by chaining instances of BSDObject subclasses to perform calculations within the -calculateOutputValue method.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.