nucm-logo

NUCM-2.0 Documentation
Interface: Collection: nc_add


[Versioning | Collection | Query]

[nc_add | nc_remove | nc_rename | nc_replaceversion | nc_copy]

Signature

int  nc_add(const char*  path,
            const char*  p_cwd,
	    const char*  prefix_target,
            const char*  t_cwd)

Functionality

Adds the artifact determined by the parameters path and p_cwd to the collection determined by the path prefix_target and t_cwd. The collection has to which the artifact is added has to be initiated. Three types of additions are possible: The initial version of the artifact that is created is 1.

Return Values

0: everything went ok
-1: an error occurred

NdbErrno Codes

NdbOk :everything went ok
NdbUnknown :the path does not represent a NUCM artifact
NdbLonely : no collection present in the workspace to which the artifact can be added
NdbNotInit: the collection to which to add the artifact is not initiated
NdbExist : a different artifact with the same name already exists in the workspace
NdbConnect :the server is down or not reachable
NdbComm :a communication error occurred
NdbProtocol:a failure occurred in the NUCM protocol
NdbNotAvail:service is not available

Example

Assuming a repository is filled with projects, each project being a member of the nucm_root collection. Furthermore, an empty workspace has been created earlier:
   /home/bigtime/andre/workspace
To create a new project "my_project", the following code fragment can be used:
   #include "nc.h"
   
   nc_open("//serl.cs.colorado.edu:1234/nucm_root",
	   "",
	   "/home/bigtime/andre/workspace",
	   "");
   nc_initiatechange("nucm_root",
		     "/home/bigtime/andre/workspace");
   mkdir("/home/bigtime/andre/workspace/nucm_root/my_project,
	 0644);
   nc_add("my_project",
	  "/home/bigtime/andre/workspace/nucm_root",
	  "/home/bigtime/andre/workspace/nucm_root",
	  "");
   nc_commitchangeandreplace("nucm_root",
	                     "/home/bigtime/andre/workspace");
   nc_close("/home/bigtime/andre/workspace/nucm_root",
	    "");
The workspace is now empty again. To populate the newly created project with for example the existing files ".login" and ".cshrc" from "/home/bigtime/andre", the following code fragment can be used:
   #include "nc.h"
   
   char  newversion[MAX_VERSION_LENGTH + 1];

   nc_open("//serl.cs.colorado.edu:1234/nucm_root/my_project",
	   "",
	   "/home/bigtime/andre/workspace",
	   "");
   nc_initiatechange("my_project",
		     "/home/bigtime/andre/workspace");
   nc_add(".login",
	  "/home/bigtime/andre",
	  "my_project",
	  "/home/bigtime/andre/workspace");
   nc_add(".cshrc",
	  "/home/bigtime/andre",
	  "my_project",
	  "/home/bigtime/andre/workspace");
   nc_commitchange("my_project",
	           "/home/bigtime/andre/workspace",
		   &newversion);
A new version of "my_project" has been created with ".login" and ".cshrc" as its members. The workspace now looks like:
   /home/bigtime/andre/workspace/my_project/.login
					    .cshrc
Assuming the first code fragment above has been used to create a new project "his_project" as well, but that the project is still empty. To populate "his_project" with the same artifacts ".login" and ".cshrc" from "my_project" the following code fragment can be used:
   #include "nc.h"

   char  newversion[MAX_VERSION_LENGTH + 1];

   nc_open("//serl.cs.colorado.edu:1234/nucm_root/his_project",
	   ""
	   "/home/bigtime/andre/workspace",
	   "");
   nc_initiatechange("his_project",
		     "/home/bigtime/andre/workspace");
   nc_add(".login",
	  "/home/bigtime/andre/workspace/my_project",
	  "/home/bigtime/andre/workspace/his_project",
	  "");
   nc_add("//serl.cs.colorado.edu:1234/nucm_root/my_project/.cshrc",
	  "",
	  "/home/bigtime/andre/workspace/his_project",
          "");
   nc_commitchange("his_project",
	           "/home/bigtime/andre/workspace",
		   &newversion);
The first nc_add illustrates an import from one workspace into another, the second nc_add illustrates a mount as it directly references an artifact in a repository. The workspace now looks as follows:
   /home/bigtime/andre/workspace/my_project/.login
					    .cshrc
				/his_project/.login
					     .cshrc
Both ".login" artifacts and both ".cshrc" artifacts represent the same respective artifact.

[Top | Quick Index] [Concepts | Interface]

SERL <serl.cs.colorado.edu>