Changeset 3441 in Sophya for trunk/SophyaLib/Manual


Ignore:
Timestamp:
Dec 13, 2007, 4:12:03 PM (18 years ago)
Author:
ansari
Message:

fin(?) des modifications de la documentation pour V=2.1, Reza 13/12/2007

Location:
trunk/SophyaLib/Manual
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/Manual/piapp.tex

    r3439 r3441  
    132132
    133133We thank also the persons who have helped us by useful suggestions, among others : \\
    134 S. Bargot, S. Du, S. Plasczczynski, C. Renault and D. Yvon.
     134S. Bargot, S. Plasczczynski, C. Renault and D. Yvon.
    135135
    136136%%%
     
    15011501\section{On the fly C++ execution}
    15021502\label{flycplusplus}
    1503 and the option window activated by the menu:
    1504 {\bf Special/CxxExecOption}.
     1503Piapp operates on the underlying SOPHYA class library objects.
     1504Obviously, only a small fraction of functionalities in the libraries
     1505are directly available through the commands. On the fly C++ compilation
     1506and execution in piapp provides an easy access to the whole class library.
     1507
     1508The {\bf NamedObjMgr} class handles most of the communication between different
     1509component of the application, including user c++ code.
     1510The NamedObjMgr class implements a singleton scheme, where all instances of the
     1511class operate on the same data.
     1512Most operations, in particular directory and object management are thread-safe.
     1513The most usefull NamedObjMgr methods in user code are:
     1514\begin{itemize}
     1515\item Adding an object using its pointer. The object should be created using new. \\
     1516{\tt \small bool NamedObjMgr::AddObj(AnyDataObj* obj, string \& nom, bool crd=false) }
     1517\item Adding an object using its reference. The Object Adapter is used to Clone
     1518the object. For classes like TArray or Spherical maps, implementing reference sharing,
     1519the cloned object shares its data with the original object.
     1520The Cloned object is then added to the list. \\
     1521{\tt \small bool NamedObjMgr::AddObj(AnyDataObj\& obj, string \& nom, bool crd=false)}
     1522\item Object display methods : \\
     1523{\tt \small NamedObjMgr::DisplayObj(string \& nom, string dopt="")  \\
     1524NamedObjMgr::DisplayImage(string \& nom, \ldots ) \\
     1525NamedObjMgr::DisplayNT(string \& nom, \ldots )} \\
     1526\ldots
     1527\item Access to other parts of the piapp application : \\
     1528{\tt \small PIStdImgApp* NamedObjMgr::GetImgApp() \\
     1529PIACmd* PIStdImgApp::CmdInterpreter() }
     1530\end{itemize}
     1531
     1532\subsection{How does it work ?}
     1533When one the {\bf CxxExecutorCmd} \myppageref{CxxExecutorCmd} commands
     1534({\tt c++exec} or {\tt c++execfrf}) is invoked, piapp performs the
     1535following operations:
     1536\begin{itemize}
     1537\item Create a c++ file, and includes the usual libstc++ and SOPHYA header files
     1538(file named PIATmp\_xxx/cxx\_spiapp.cc)
     1539\item The user code is put in a c++ function: \\
     1540{\small \tt  int usercxx( vector<string> \& args ) }
     1541\item References to all objects present in the current working NamedObjMgr directory
     1542(default=/home) are declared and initialized. Objects in the current directory can
     1543thus be easily accessed through variables bearing the corresponding object name
     1544in piapp.
     1545\item The c++ source file is compiled and linked with SOPHYA libraries,
     1546and any additional library, specified through {\tt c++mylibs} \myppageref{cZZmylibs}).
     1547The compilation and link steps are carried by the SOPHYA class {\b CxxCompilerLinker}.
     1548\item The resulting shared object is loaded by piapp and the function
     1549{\tt usercxx()} is called.
     1550\end{itemize}
     1551
     1552To facilitate communication with piapp/NamedObjMgr, two CPP macros are defined:
     1553\begin{itemize}
     1554\item[\rond] {\bf KeepObj(VarName) } where VarName is a user declared
     1555c++ variable, corresponding to an object inheriting from AnyDataObj.
     1556When this macro is called, the corresponding object is cloned by the object
     1557Adapter and added to the list managed by NamedObjMgr,
     1558with VarName as the object name.
     1559\item[\rond] {\bf DisplayObj(VarName, graphic\_att) } adds the object and
     1560request its display. 
     1561\end{itemize}
     1562
     1563\subsection{Examples}
     1564
     1565\begin{enumerate}
     1566\item Computation using TimeStamp object. \\[1mm]
     1567%%
     1568$\longrightarrow$ File compdate.cc :
     1569\begin{verbatim}
     1570  TimeStamp now;     // Current date
     1571  TimeStamp y2000(2000,1,1,12,0,0.);  // 1 jan 2000, 12:00
     1572  cout << " Y2000=" << y2000 << " --> Now: " << now << endl;
     1573  cout << " From Y2000 to Now= " << now.ToDays() - y2000.ToDays() << " days" << endl;
     1574\end{verbatim}
     1575$\longrightarrow$ piapp commands : \\
     1576{\tt piapp> c++execfrf compdate.cc} \\
     1577$\longrightarrow$ The result : \\
     1578\begin{verbatim}
     1579PIABaseExecutor: Call usercxx( ... )                               
     1580 Y2000= 01/01/2000 12:00:0.0 UT  --> Now:  13/12/2007 14:20:50.0 UT
     1581 From Y2000 to Now= 2903.1 days                                 
     1582\end{verbatim}
     1583%%%%
     1584\item Working with objects in piapp: \\[1mm]
     1585\begin{verbatim}
     1586#  We create three vectors
     1587newvec va 256 sin(x/5.)
     1588newvec vb 256 cos(x/18.)*exp(-x/150.)
     1589newvec vc 256
     1590#  We call c++exec to make an operation on these vectors
     1591c++exec vc=va+3.*vb;
     1592#  Display the resulting vector
     1593disp vc
     1594\end{verbatim}
     1595%%%
     1596\item Creating and adding new objects \\[1mm]
     1597$\longrightarrow$ File myf\_fft.h :
     1598\begin{verbatim}
     1599inline double myf(double x)
     1600{
     1601return(3*sin(0.2*x)+4*cos(x)+5*sin(4*x+0.25)
     1602       +3.5*cos(9*x+0.45) + 0.05*x);
     1603}
     1604\end{verbatim}
     1605$\longrightarrow$ File myf\_fft.h :
     1606\begin{verbatim}
     1607TVector<r_8> in(4048);
     1608TVector<r_8> noise(4048);
     1609TVector< complex<r_8> > out;
     1610in = RegularSequence(0., 0.05);
     1611noise = RandomSequence(RandomSequence::Gaussian, 0., 4.);
     1612MathArray<r_8> ma;
     1613ma.ApplyFunctionInPlace(in, myf);
     1614in += noise;
     1615FFTPackServer FFTServ;
     1616cout << " Calling FFT " << endl;
     1617FFTServ.FFTForward(in, out);
     1618DisplayObj(in, "");
     1619DisplayObj(out, "red");
     1620\end{verbatim}
     1621$\longrightarrow$ piapp commands :
     1622\begin{verbatim}
     1623# Remove existing in/out objects
     1624rm in out
     1625# Divide then graphic window in two regions
     1626zone 1 2
     1627#  Compile and execute the c++ code
     1628c++execfrf fft.icc myf_fft.h
     1629listobjs
     1630\end{verbatim}
     1631\end{enumerate}
     1632
     1633\subsection{Include files, libraries \ldots}
     1634\begin{itemize}
     1635\item[\rond] The different steps of c++exec or c++execfrf
     1636can be performed by the following commands: {\tt c++create , c++createfrf,
     1637c++compile, c++link, call}. This is useful when the same code
     1638has to be executed multiple times.
     1639\item[\rond] An interactive editing / c++ execution window can be
     1640displayed through the menu-bar, \menubar{Tools/CxxExecutorWindow}
     1641\item[\rond] The {\tt c++import} \myppageref{cZZimport}
     1642activate inclusion of header files for additional SOPHYA modules,
     1643such as Samba SkyMap SkyT FitsIOServe \ldots.
     1644\item[\rond] The inclusion of additional header files and libraries
     1645can be specified using the {\tt c++include} \myppageref{cZZinclude}
     1646and  {\tt c++mylibs} \myppageref{cZZmylibs}.
     1647\item[\rond] A dialog window for changing various c++ compile and link
     1648options can be displayed by through the menu-bar
     1649\menubar{Special/CxxExecOption}
     1650\end{itemize}
     1651
    15051652
    15061653%%%%%%%%%%%%%%% Section 8 :  command reference
  • trunk/SophyaLib/Manual/sophya.tex

    r3438 r3441  
    122122
    123123We thank also the persons who have helped us by useful suggestions, among others : \\
    124 S. Bargot, S. Du, S. Plasczczynski, C. Renault and D. Yvon.
     124S. Bargot, S. Plasczczynski, C. Renault and D. Yvon.
    125125
    126126\subsection{SOPHYA modules}
Note: See TracChangeset for help on using the changeset viewer.