├── dialyzer_unhandled_warnings ├── rebar ├── rebar3 ├── dialyzer.ignore-warnings ├── relx.config ├── dialyzer_warnings ├── README.md ├── .travis.yml ├── .gitignore ├── rebar.config ├── src ├── gen_flow.app.src ├── gen_flow_example.erl └── gen_flow.erl ├── Makefile ├── tools.mk └── LICENSE /dialyzer_unhandled_warnings: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /rebar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lasp-lang/gen_flow/HEAD/rebar -------------------------------------------------------------------------------- /rebar3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lasp-lang/gen_flow/HEAD/rebar3 -------------------------------------------------------------------------------- /dialyzer.ignore-warnings: -------------------------------------------------------------------------------- 1 | gen_flow.erl:143: Function system_terminate/4 only terminates with explicit exception 2 | -------------------------------------------------------------------------------- /relx.config: -------------------------------------------------------------------------------- 1 | {release, {gen_flow, "0.0.1"}, [gen_flow]}. 2 | {extended_start_script, true}. 3 | {overlay, [{mkdir, "data"}]}. 4 | -------------------------------------------------------------------------------- /dialyzer_warnings: -------------------------------------------------------------------------------- 1 | Checking whether the PLT /Users/cmeiklejohn/.combo_dialyzer_plt is up-to-date... yes 2 | Proceeding with analysis... done in 0m2.76s 3 | done (passed successfully) 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Generic Flow Abstraction 2 | ======================================================= 3 | 4 | [![Build Status](https://travis-ci.org/lasp-lang/gen_flow.svg?branch=master)](https://travis-ci.org/lasp-lang/gen_flow) 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: erlang 2 | otp_release: 3 | - 18.1 4 | script: 5 | - make dialyzer 6 | - make xref 7 | - make 8 | - make test 9 | notifications: 10 | email: christopher.meiklejohn@gmail.com 11 | sudo: false 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .rebar3 2 | _* 3 | .eunit 4 | *.o 5 | *.beam 6 | *.plt 7 | *.swp 8 | *.swo 9 | .erlang.cookie 10 | ebin 11 | log 12 | erl_crash.dump 13 | .rebar 14 | _rel 15 | _deps 16 | _plugins 17 | _build 18 | _tdeps 19 | logs 20 | erln8.config 21 | .local_dialyzer_plt 22 | deps/* 23 | -------------------------------------------------------------------------------- /rebar.config: -------------------------------------------------------------------------------- 1 | {dialyzer_base_plt_apps, [kernel, stdlib, erts, sasl, eunit, syntax_tools, compiler, crypto]}. 2 | {xref_checks, [undefined_function_calls]}. 3 | {erl_opts, [debug_info, 4 | warnings_as_errors, 5 | {platform_define, "^[0-9]+", namespaced_types}]}. 6 | {cover_enabled, false}. 7 | {eunit_opts, [verbose, {report,{eunit_surefire,[{dir,"."}]}}]}. 8 | {edoc_opts, [{preprocess, true}]}. 9 | -------------------------------------------------------------------------------- /src/gen_flow.app.src: -------------------------------------------------------------------------------- 1 | {application,gen_flow, 2 | [{description,"Generic abstraction for building dataflow computations."}, 3 | {vsn,"0.0.5"}, 4 | {registered,[]}, 5 | {applications,[kernel,stdlib]}, 6 | {modules,[]}, 7 | {env,[]}, 8 | {maintainers,["Chris Meiklejohn","Borja o'Cook"]}, 9 | {licenses,["Apache 2.0"]}, 10 | {links,[{"Github","https://github.com/lasp-lang/gen_flow"}]}]}. 11 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | REBAR = $(shell pwd)/rebar 2 | .PHONY: deps compile rel 3 | 4 | DIALYZER_APPS = kernel stdlib erts sasl eunit syntax_tools compiler crypto 5 | DEP_DIR="_build/lib" 6 | 7 | all: compile 8 | 9 | test: common_test 10 | 11 | deps: 12 | $(REBAR) get-deps 13 | 14 | clean: 15 | $(REBAR) clean 16 | 17 | common_test: 18 | $(REBAR) ct 19 | 20 | compile: deps 21 | $(REBAR) compile 22 | 23 | rel: 24 | $(REBAR) release 25 | 26 | stage: 27 | $(REBAR) release -d 28 | 29 | DIALYZER_APPS = kernel stdlib sasl erts ssl tools os_mon runtime_tools crypto inets \ 30 | xmerl webtool eunit syntax_tools compiler mnesia public_key snmp 31 | 32 | include tools.mk 33 | 34 | typer: 35 | typer --annotate -I ../ --plt $(PLT) -r src 36 | -------------------------------------------------------------------------------- /tools.mk: -------------------------------------------------------------------------------- 1 | REBAR ?= ./rebar 2 | 3 | test: compile 4 | ${REBAR} eunit skip_deps=true 5 | 6 | docs: 7 | ${REBAR} doc skip_deps=true 8 | 9 | xref: compile 10 | ${REBAR} xref skip_deps=true 11 | 12 | PLT ?= $(HOME)/.combo_dialyzer_plt 13 | LOCAL_PLT = .local_dialyzer_plt 14 | DIALYZER_FLAGS ?= -Wunmatched_returns -Werror_handling -Wrace_conditions -Wunderspecs 15 | 16 | ${PLT}: compile 17 | @if [ -f $(PLT) ]; then \ 18 | dialyzer --check_plt --plt $(PLT) --apps $(DIALYZER_APPS) && \ 19 | dialyzer --add_to_plt --plt $(PLT) --output_plt $(PLT) --apps $(DIALYZER_APPS) ; test $$? -ne 1; \ 20 | else \ 21 | dialyzer --build_plt --output_plt $(PLT) --apps $(DIALYZER_APPS); test $$? -ne 1; \ 22 | fi 23 | 24 | ${LOCAL_PLT}: compile 25 | @if [ -d deps ]; then \ 26 | if [ -f $(LOCAL_PLT) ]; then \ 27 | dialyzer --check_plt --plt $(LOCAL_PLT) deps/*/ebin && \ 28 | dialyzer --add_to_plt --plt $(LOCAL_PLT) --output_plt $(LOCAL_PLT) deps/*/ebin ; test $$? -ne 1; \ 29 | else \ 30 | dialyzer --build_plt --output_plt $(LOCAL_PLT) deps/*/ebin ; test $$? -ne 1; \ 31 | fi \ 32 | fi 33 | 34 | dialyzer: ${PLT} ${LOCAL_PLT} 35 | @echo "==> $(shell basename $(shell pwd)) (dialyzer)" 36 | @if [ -f $(LOCAL_PLT) ]; then \ 37 | PLTS="$(PLT) $(LOCAL_PLT)"; \ 38 | else \ 39 | PLTS=$(PLT); \ 40 | fi; \ 41 | if [ -f dialyzer.ignore-warnings ]; then \ 42 | if [ $$(grep -cvE '[^[:space:]]' dialyzer.ignore-warnings) -ne 0 ]; then \ 43 | echo "ERROR: dialyzer.ignore-warnings contains a blank/empty line, this will match all messages!"; \ 44 | exit 1; \ 45 | fi; \ 46 | dialyzer $(DIALYZER_FLAGS) --plts $${PLTS} -c ebin > dialyzer_warnings ; \ 47 | egrep -v "^[[:space:]]*(done|Checking|Proceeding|Compiling)" dialyzer_warnings | grep -F -f dialyzer.ignore-warnings -v > dialyzer_unhandled_warnings ; \ 48 | cat dialyzer_unhandled_warnings ; \ 49 | [ $$(cat dialyzer_unhandled_warnings | wc -l) -eq 0 ] ; \ 50 | else \ 51 | dialyzer $(DIALYZER_FLAGS) --plts $${PLTS} -c ebin; \ 52 | fi 53 | 54 | cleanplt: 55 | @echo 56 | @echo "Are you sure? It takes several minutes to re-build." 57 | @echo Deleting $(PLT) and $(LOCAL_PLT) in 5 seconds. 58 | @echo 59 | sleep 5 60 | rm $(PLT) 61 | rm $(LOCAL_PLT) 62 | 63 | -------------------------------------------------------------------------------- /src/gen_flow_example.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2014 SyncFree Consortium. All Rights Reserved. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(gen_flow_example). 22 | -author('Christopher Meiklejohn '). 23 | 24 | -behaviour(gen_flow). 25 | 26 | -ifdef(TEST). 27 | -include_lib("eunit/include/eunit.hrl"). 28 | -endif. 29 | 30 | %% API 31 | -export([start_link/1, start_link/2]). 32 | 33 | %% Callbacks 34 | -export([init/1, read/1, process/2]). 35 | 36 | %% Records 37 | -record(state, {source}). 38 | 39 | %%%=================================================================== 40 | %%% API 41 | %%%=================================================================== 42 | 43 | start_link(Args) -> 44 | gen_flow:start_link(?MODULE, Args). 45 | 46 | start_link(Events, Args) -> 47 | gen_flow:start_link(?MODULE, Events, Args). 48 | 49 | %%%=================================================================== 50 | %%% Callbacks 51 | %%%=================================================================== 52 | 53 | %% @doc Initialize state. 54 | init([Source]) -> 55 | {ok, #state{source=Source}}. 56 | 57 | %% @doc Return list of read functions. 58 | read(State) -> 59 | ReadFuns = [fun(_) -> sets:from_list([1,2,3]) end, 60 | fun(_) -> sets:from_list([3,4,5]) end], 61 | {ok, ReadFuns, State}. 62 | 63 | %% @doc Computation to execute when inputs change. 64 | process(Args, #state{source=Source}=State) -> 65 | Processed = case Args of 66 | [undefined, _] -> 67 | false; 68 | [_, undefined] -> 69 | false; 70 | [X, Y] -> 71 | Set = sets:intersection(X, Y), 72 | Source ! {ok, sets:to_list(Set)}, 73 | true 74 | end, 75 | {ok, {Processed, State}}. 76 | 77 | -ifdef(TEST). 78 | 79 | gen_flow_test() -> 80 | gen_flow:start_link(gen_flow_example, [self()]), 81 | 82 | Response = receive 83 | ok -> 84 | ok; 85 | {ok, X} -> 86 | X 87 | end, 88 | 89 | ?assertEqual([3], Response). 90 | 91 | -endif. 92 | -------------------------------------------------------------------------------- /src/gen_flow.erl: -------------------------------------------------------------------------------- 1 | %% ------------------------------------------------------------------- 2 | %% 3 | %% Copyright (c) 2014 SyncFree Consortium. All Rights Reserved. 4 | %% 5 | %% This file is provided to you under the Apache License, 6 | %% Version 2.0 (the "License"); you may not use this file 7 | %% except in compliance with the License. You may obtain 8 | %% a copy of the License at 9 | %% 10 | %% http://www.apache.org/licenses/LICENSE-2.0 11 | %% 12 | %% Unless required by applicable law or agreed to in writing, 13 | %% software distributed under the License is distributed on an 14 | %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | %% KIND, either express or implied. See the License for the 16 | %% specific language governing permissions and limitations 17 | %% under the License. 18 | %% 19 | %% ------------------------------------------------------------------- 20 | 21 | -module(gen_flow). 22 | -author('Christopher Meiklejohn '). 23 | 24 | %% API 25 | -export([start_link/2, 26 | start_link/3, 27 | loop/3]). 28 | 29 | %% System message callbacks 30 | -export([system_continue/3, 31 | system_terminate/4, 32 | system_get_state/1, 33 | system_replace_state/2]). 34 | 35 | %% Callbacks 36 | -export([init/4]). 37 | 38 | %% Ignore explicit termination warning. 39 | -dialyzer([{nowarn_function, [system_terminate/4]}]). 40 | 41 | %%%=================================================================== 42 | %%% Behaviour 43 | %%%=================================================================== 44 | 45 | -type state() :: state(). 46 | 47 | -record(state, {pids :: [pid()], 48 | module :: atom(), 49 | module_state :: term(), 50 | cache :: orddict:orddict(), 51 | max_events :: non_neg_integer() | undefined}). 52 | 53 | -callback init(list(term())) -> {ok, state()}. 54 | -callback read(state()) -> {ok, [function()], state()}. 55 | -callback process(list(term()), state()) -> {ok, {boolean(), state()}}. 56 | 57 | %%%=================================================================== 58 | %%% API 59 | %%%=================================================================== 60 | 61 | start_link(Module, Args) -> 62 | proc_lib:start_link(?MODULE, init, [self(), Module, Args, undefined]). 63 | 64 | start_link(Module, MaxEvents, Args) -> 65 | proc_lib:start_link(?MODULE, init, [self(), Module, Args, MaxEvents]). 66 | 67 | %%%=================================================================== 68 | %%% Callbacks 69 | %%%=================================================================== 70 | 71 | %% @doc TODO 72 | init(Parent, Module, Args, MaxEvents) -> 73 | %% Trap exits from children. 74 | process_flag(trap_exit, true), 75 | 76 | %% Initialize state. 77 | {ok, ModuleState} = case Module:init(Args) of 78 | {ok, InitState} -> 79 | proc_lib:init_ack(Parent, {ok, self()}), 80 | {ok, InitState}; 81 | {error, Reason} -> 82 | exit(Reason) 83 | end, 84 | 85 | %% Create debugging structure. 86 | Debug = sys:debug_options([]), 87 | 88 | %% Initialize state. 89 | State = #state{pids=[], 90 | module=Module, 91 | module_state=ModuleState, 92 | cache=orddict:new(), 93 | max_events=MaxEvents}, 94 | 95 | loop(Parent, Debug, State). 96 | 97 | % If we have reached the max number of events, stop the process 98 | loop(_, _, #state{pids=Pids, max_events=0}) -> terminate(Pids), ok; 99 | 100 | %% @doc TODO 101 | loop(Parent, Debug, #state{pids=Pids0, 102 | cache=Cache0, 103 | module=Module, 104 | max_events=MaxEvents, 105 | module_state=ModuleState0}=State) -> 106 | 107 | %% Terminate pids that might still be running. 108 | terminate(Pids0), 109 | 110 | %% Clear EXIT messages from previous pids 111 | clear_exit_inbox(Parent), 112 | 113 | %% Get self. 114 | Self = self(), 115 | 116 | %% Gather the read functions. 117 | {ok, ReadFuns, ReadState} = Module:read(ModuleState0), 118 | 119 | %% Initialize bottom values in orddict. 120 | DefaultedCache = lists:foldl(fun(X, C) -> 121 | case orddict:find(X, C) of 122 | error -> 123 | orddict:store(X, undefined, C); 124 | {ok, _} -> 125 | C 126 | end 127 | end, Cache0, lists:seq(1, length(ReadFuns))), 128 | 129 | %% For each readfun, spawn a linked process to request values. 130 | Pids = lists:map(fun(X) -> 131 | ReadFun = lists:nth(X, ReadFuns), 132 | CachedValue = orddict:fetch(X, DefaultedCache), 133 | Pid = spawn_link(fun() -> 134 | Value = ReadFun(CachedValue), 135 | Self ! {ok, X, Value} 136 | end), 137 | Pid 138 | end, lists:seq(1, length(ReadFuns))), 139 | 140 | %% Wait for responses. 141 | receive 142 | hibernate -> 143 | %% Terminate pids. 144 | terminate(Pids), 145 | %% Clear the inbox so we don't wake up immediately 146 | clear_inbox(), 147 | 148 | %% Hibernate 149 | proc_lib:hibernate(?MODULE, 150 | loop, 151 | [Parent, 152 | Debug, 153 | State#state{module_state=ModuleState0, 154 | cache=Cache0, 155 | pids=[]}]); 156 | {system, From, Request} -> 157 | sys:handle_system_msg(Request, From, Parent, ?MODULE, Debug, State), 158 | loop(Parent, Debug, State#state{module_state=ModuleState0, cache=Cache0, pids=Pids}); 159 | 160 | {ok, X, V} -> 161 | %% Log result. 162 | Debug1 = sys:handle_debug(Debug, 163 | fun write_debug/3, 164 | ?MODULE, 165 | {ok, X, V}), 166 | 167 | %% Update cache. 168 | Cache = orddict:store(X, V, DefaultedCache), 169 | 170 | %% Get current values from cache. 171 | RealizedCache = [Value || {_, Value} <- orddict:to_list(Cache)], 172 | 173 | %% Call process function. 174 | {ok, {Processed, ModuleState}} = Module:process(RealizedCache, ReadState), 175 | 176 | %% If a maximum number of events was given, update the count. 177 | case MaxEvents of 178 | undefined -> 179 | loop(Parent, Debug1, State#state{pids=Pids, 180 | cache=Cache, 181 | module_state=ModuleState}); 182 | _ -> 183 | Events = case Processed of 184 | true -> MaxEvents - 1; 185 | _ -> MaxEvents 186 | end, 187 | loop(Parent, Debug1, State#state{pids=Pids, 188 | cache=Cache, 189 | max_events=Events, 190 | module_state=ModuleState}) 191 | end; 192 | 193 | {'EXIT', Parent, Reason} -> 194 | exit(Reason) 195 | 196 | after 197 | 60000 -> 198 | %% If 60 seconds go by, relaunch. 199 | loop(Parent, Debug, State#state{module_state=ModuleState0, cache=Cache0, pids=Pids}) 200 | end. 201 | 202 | %% @private 203 | write_debug(Dev, Event, Name) -> 204 | io:format(Dev, "~p event = ~p~n", [Name, Event]). 205 | 206 | %% @private 207 | system_continue(Parent, Debug, State) -> 208 | loop(Parent, Debug, State). 209 | 210 | %% @private 211 | system_terminate(Reason, _Parent, _Debug, _State) -> 212 | exit(Reason). 213 | 214 | %% @private 215 | system_get_state(State) -> 216 | {ok, State, State}. 217 | 218 | %% @private 219 | system_replace_state(StateFun, State) -> 220 | NewState = StateFun(State), 221 | {ok, NewState, NewState}. 222 | 223 | %% @private 224 | clear_inbox() -> 225 | receive 226 | _ -> clear_inbox() 227 | after 228 | 0 -> ok 229 | end. 230 | 231 | %% @private 232 | clear_exit_inbox(Parent) -> 233 | receive 234 | {'EXIT', Parent, Reason} -> exit(Reason); 235 | {'EXIT', _, _} -> clear_exit_inbox(Parent) 236 | after 237 | 0 -> ok 238 | end. 239 | 240 | %% @private 241 | terminate(Pids) -> 242 | %% Terminate pids that might still be running. 243 | TerminateFun = fun(Pid) -> 244 | exit(Pid, kill) 245 | end, 246 | _ = [TerminateFun(Pid) || Pid <- Pids], 247 | ok. 248 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Christopher Meiklejohn 2 | All rights reserved. 3 | 4 | 5 | Apache License 6 | Version 2.0, January 2004 7 | http://www.apache.org/licenses/ 8 | 9 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 10 | 11 | 1. Definitions. 12 | 13 | "License" shall mean the terms and conditions for use, reproduction, 14 | and distribution as defined by Sections 1 through 9 of this document. 15 | 16 | "Licensor" shall mean the copyright owner or entity authorized by 17 | the copyright owner that is granting the License. 18 | 19 | "Legal Entity" shall mean the union of the acting entity and all 20 | other entities that control, are controlled by, or are under common 21 | control with that entity. For the purposes of this definition, 22 | "control" means (i) the power, direct or indirect, to cause the 23 | direction or management of such entity, whether by contract or 24 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 25 | outstanding shares, or (iii) beneficial ownership of such entity. 26 | 27 | "You" (or "Your") shall mean an individual or Legal Entity 28 | exercising permissions granted by this License. 29 | 30 | "Source" form shall mean the preferred form for making modifications, 31 | including but not limited to software source code, documentation 32 | source, and configuration files. 33 | 34 | "Object" form shall mean any form resulting from mechanical 35 | transformation or translation of a Source form, including but 36 | not limited to compiled object code, generated documentation, 37 | and conversions to other media types. 38 | 39 | "Work" shall mean the work of authorship, whether in Source or 40 | Object form, made available under the License, as indicated by a 41 | copyright notice that is included in or attached to the work 42 | (an example is provided in the Appendix below). 43 | 44 | "Derivative Works" shall mean any work, whether in Source or Object 45 | form, that is based on (or derived from) the Work and for which the 46 | editorial revisions, annotations, elaborations, or other modifications 47 | represent, as a whole, an original work of authorship. For the purposes 48 | of this License, Derivative Works shall not include works that remain 49 | separable from, or merely link (or bind by name) to the interfaces of, 50 | the Work and Derivative Works thereof. 51 | 52 | "Contribution" shall mean any work of authorship, including 53 | the original version of the Work and any modifications or additions 54 | to that Work or Derivative Works thereof, that is intentionally 55 | submitted to Licensor for inclusion in the Work by the copyright owner 56 | or by an individual or Legal Entity authorized to submit on behalf of 57 | the copyright owner. For the purposes of this definition, "submitted" 58 | means any form of electronic, verbal, or written communication sent 59 | to the Licensor or its representatives, including but not limited to 60 | communication on electronic mailing lists, source code control systems, 61 | and issue tracking systems that are managed by, or on behalf of, the 62 | Licensor for the purpose of discussing and improving the Work, but 63 | excluding communication that is conspicuously marked or otherwise 64 | designated in writing by the copyright owner as "Not a Contribution." 65 | 66 | "Contributor" shall mean Licensor and any individual or Legal Entity 67 | on behalf of whom a Contribution has been received by Licensor and 68 | subsequently incorporated within the Work. 69 | 70 | 2. Grant of Copyright License. Subject to the terms and conditions of 71 | this License, each Contributor hereby grants to You a perpetual, 72 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 73 | copyright license to reproduce, prepare Derivative Works of, 74 | publicly display, publicly perform, sublicense, and distribute the 75 | Work and such Derivative Works in Source or Object form. 76 | 77 | 3. Grant of Patent License. Subject to the terms and conditions of 78 | this License, each Contributor hereby grants to You a perpetual, 79 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 80 | (except as stated in this section) patent license to make, have made, 81 | use, offer to sell, sell, import, and otherwise transfer the Work, 82 | where such license applies only to those patent claims licensable 83 | by such Contributor that are necessarily infringed by their 84 | Contribution(s) alone or by combination of their Contribution(s) 85 | with the Work to which such Contribution(s) was submitted. If You 86 | institute patent litigation against any entity (including a 87 | cross-claim or counterclaim in a lawsuit) alleging that the Work 88 | or a Contribution incorporated within the Work constitutes direct 89 | or contributory patent infringement, then any patent licenses 90 | granted to You under this License for that Work shall terminate 91 | as of the date such litigation is filed. 92 | 93 | 4. Redistribution. You may reproduce and distribute copies of the 94 | Work or Derivative Works thereof in any medium, with or without 95 | modifications, and in Source or Object form, provided that You 96 | meet the following conditions: 97 | 98 | (a) You must give any other recipients of the Work or 99 | Derivative Works a copy of this License; and 100 | 101 | (b) You must cause any modified files to carry prominent notices 102 | stating that You changed the files; and 103 | 104 | (c) You must retain, in the Source form of any Derivative Works 105 | that You distribute, all copyright, patent, trademark, and 106 | attribution notices from the Source form of the Work, 107 | excluding those notices that do not pertain to any part of 108 | the Derivative Works; and 109 | 110 | (d) If the Work includes a "NOTICE" text file as part of its 111 | distribution, then any Derivative Works that You distribute must 112 | include a readable copy of the attribution notices contained 113 | within such NOTICE file, excluding those notices that do not 114 | pertain to any part of the Derivative Works, in at least one 115 | of the following places: within a NOTICE text file distributed 116 | as part of the Derivative Works; within the Source form or 117 | documentation, if provided along with the Derivative Works; or, 118 | within a display generated by the Derivative Works, if and 119 | wherever such third-party notices normally appear. The contents 120 | of the NOTICE file are for informational purposes only and 121 | do not modify the License. You may add Your own attribution 122 | notices within Derivative Works that You distribute, alongside 123 | or as an addendum to the NOTICE text from the Work, provided 124 | that such additional attribution notices cannot be construed 125 | as modifying the License. 126 | 127 | You may add Your own copyright statement to Your modifications and 128 | may provide additional or different license terms and conditions 129 | for use, reproduction, or distribution of Your modifications, or 130 | for any such Derivative Works as a whole, provided Your use, 131 | reproduction, and distribution of the Work otherwise complies with 132 | the conditions stated in this License. 133 | 134 | 5. Submission of Contributions. Unless You explicitly state otherwise, 135 | any Contribution intentionally submitted for inclusion in the Work 136 | by You to the Licensor shall be under the terms and conditions of 137 | this License, without any additional terms or conditions. 138 | Notwithstanding the above, nothing herein shall supersede or modify 139 | the terms of any separate license agreement you may have executed 140 | with Licensor regarding such Contributions. 141 | 142 | 6. Trademarks. This License does not grant permission to use the trade 143 | names, trademarks, service marks, or product names of the Licensor, 144 | except as required for reasonable and customary use in describing the 145 | origin of the Work and reproducing the content of the NOTICE file. 146 | 147 | 7. Disclaimer of Warranty. Unless required by applicable law or 148 | agreed to in writing, Licensor provides the Work (and each 149 | Contributor provides its Contributions) on an "AS IS" BASIS, 150 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 151 | implied, including, without limitation, any warranties or conditions 152 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 153 | PARTICULAR PURPOSE. You are solely responsible for determining the 154 | appropriateness of using or redistributing the Work and assume any 155 | risks associated with Your exercise of permissions under this License. 156 | 157 | 8. Limitation of Liability. In no event and under no legal theory, 158 | whether in tort (including negligence), contract, or otherwise, 159 | unless required by applicable law (such as deliberate and grossly 160 | negligent acts) or agreed to in writing, shall any Contributor be 161 | liable to You for damages, including any direct, indirect, special, 162 | incidental, or consequential damages of any character arising as a 163 | result of this License or out of the use or inability to use the 164 | Work (including but not limited to damages for loss of goodwill, 165 | work stoppage, computer failure or malfunction, or any and all 166 | other commercial damages or losses), even if such Contributor 167 | has been advised of the possibility of such damages. 168 | 169 | 9. Accepting Warranty or Additional Liability. While redistributing 170 | the Work or Derivative Works thereof, You may choose to offer, 171 | and charge a fee for, acceptance of support, warranty, indemnity, 172 | or other liability obligations and/or rights consistent with this 173 | License. However, in accepting such obligations, You may act only 174 | on Your own behalf and on Your sole responsibility, not on behalf 175 | of any other Contributor, and only if You agree to indemnify, 176 | defend, and hold each Contributor harmless for any liability 177 | incurred by, or claims asserted against, such Contributor by reason 178 | of your accepting any such warranty or additional liability. 179 | 180 | END OF TERMS AND CONDITIONS 181 | 182 | --------------------------------------------------------------------------------