The open-source movement has sparked an explosion of new software and code, all freely available to developers. Companies that were once locked into costly licenses can now access the source code for everything from compilers, editors, and scripting interpreters to packages like MySQL and Linux. This is great for businesses that would rather extend existing code than reinvent the wheelbut there's a catch. If you rerelease the original code, most open-source licenses (with the notable exception of BSD-style licenses) require that you also give away the code to any improvements you've made. And a number of open-source licenses state that you may not use the code in commercial software you plan to license restrictively on a per-copy basis.
January 01, 2002
URL:http://drdobbs.com/can-corba-sidestep-open-source-licensing/184413466
Figure 1
Using CORBA wrappers to leverage open-source code.
/* TaxExpert.h */ /************************/ /* Open Source Software */ /************************/ class TaxExpert { public: double getTax( double amount ); };
# Makefile.cpp include stdmk_nt EXE = CashRegister.exe TaxExpertServer.exe all: $(EXE) clean: del *.obj del *_c.cpp del *_s.cpp del *.hh del *.exe del *.ior # # "TaxExpert" specific make rules # taxes_c.cpp: taxes.idl $(ORBCC) -no_tie taxes.idl taxes_s.cpp: taxes.idl $(ORBCC) -no_tie taxes.idl CashRegister.exe: taxes_c.obj ClientBasic.obj CashRegister.obj $(LINK_EXE) /out:CashRegister.exe CashRegister.obj \ taxes_c.obj ClientBasic.obj $(LIBORB) $(STDCC_LIBS) TaxExpertServer.exe: taxes_s.obj taxes_c.obj TaxExpertServer.obj\ ServerBasic.obj TaxExpert.obj $(LINK_EXE) /out:TaxExpertServer.exe TaxExpertServer.obj \ ServerBasic.obj TaxExpert.obj \ taxes_s.obj taxes_c.obj $(LIBORB) $(STDCC_LIBS)
/* TaxExpert.cpp */ /************************/ /* Open Source Software */ /************************/ # include <math.h> # include <stdlib.h> # include "TaxExpert.h" double TaxExpert::getTax(double amount) { return amount * .05; }
// OrigCashRegister.cpp /*****************************************************/ /**** RESTRICTED SOFTWARE - MAY NOT BE USED ******/ /**** WITHOUT A LICENSE ******/ /*****************************************************/ # include <stdio.h> # include <stdlib.h> # include "TaxExpert.h" void main(int ac, char **av) { double amount = 100.0; double tax = 0.0; TaxExpert expert = new TaxExpert(); if (ac > 1) amount = atof(av[1]); tax = expert->getTax(amount); printf("The tax on %f is %f\n", amount, tax); }
// taxes.idl module Taxes { interface TaxExpert { double getTax(in double amount); }; };
//CashRegister.cpp /******************************************************/ /**** RESTRICTED SOFTWARE - MAY NOT BE USED ******/ /**** WITHOUT A LICENSE ******/ /******************************************************/ # include "ClientBasic.h" # include "taxes_c.hh" # include "corba.h" # include <stdio.h> # include <stdlib.h> void main(int ac, char** av) { double amount = 100.0; double tax = 0.0; CORBA::Object_var object = getObject("tax.ior"); Taxes::TaxExpert_var taxExpert = Taxes::TaxExpert::_narrow(object); if (ac > 1) amount = atof(av[1]); tax = (double) taxExpert->getTax( (CORBA::Double) amount); printf("The tax on %f is %f\n", amount, tax); }
/* ClienBasic.h */ /******************************************************/ /**** RESTRICTED SOFTWARE - MAY NOT BE USED ******/ /**** WITHOUT A LICENSE ******/ /******************************************************/ # include "corba.h" CORBA::Object_var getObject(char *iorFile);
/* ClientBasic.cpp */ # include "ClientBasic.h" # include <fstream.h> CORBA::Object_var getObject(char *iorFile) { static CORBA::ORB_var orb = 0; CORBA::Object_var object = 0; if (orb == 0) orb = CORBA::ORB_init(); // Read object reference from file ifstream in(iorFile); const int MAXBUF = 1024; char ior[MAXBUF]; in.getline(ior, MAXBUF); in.close(); // convert the stringified IOR to an object reference object = orb->string_to_object(ior); return object; }
/* TaxCorba.h */ /************************/ /* Open Source Software */ /************************/ # include "taxes_s.hh" # include "TaxExpert.h" class TaxExpertImpl : public virtual POA_Taxes::TaxExpert, public virtual PortableServer::RefCountServantBase { public: TaxExpertImpl() { theTax = new TaxExpert(); } CORBA::Double getTax(CORBA::Double amount) { return (CORBA::Double) theTax->getTax( (double)amount); } private: TaxExpert* theTax; };
Terms of Service | Privacy Statement | Copyright © 2024 UBM Tech, All rights reserved.