SheafSystem  0.0.0.0
sheaves_read.cc
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
19 
20 #include "SheafSystem/assert_contract.h"
21 
22 #ifdef _WIN32
23 #include "SheafSystem/io.h"
24 #endif
25 
26 #include "SheafSystem/std_iostream.h"
27 #include "SheafSystem/namespace_poset.h"
28 #include "SheafSystem/storage_agent.h"
29 
30 
31 
32 using namespace sheaf;
33 
34 string filename;
35 
36 int
37 main(int argc, char** argv)
38 {
39 
40  if (argc > 1)
41  {
42  // test for existence of file
43  // if the filename is not valid, then exit 0 with warning message.
44 
45  if (access(argv[1],0) == 0)
46  {
47  filename = argv[1];
48  }
49  else
50  {
51  cout << "warning: no such filename " << argv[1] << "\n";
52  exit(0);
53  }
54  }
55  else
56  {
57  cerr << "usage: sheaves_read sheaf_file [enable_error_report]\n";
58  exit(0);
59  }
60 
61  bool lenable_error_report = (argc > 2);
62 
64 
66 
67  // Make the default namespace
68 
69  namespace_poset ns("test");
70 
71  // Read the namespace from the file;
72  // need write access in order to read it.
73 
75  storage_agent sa(filename, sheaf_file::READ_ONLY, false, lenable_error_report);
76  sa.put_member_record_buffer_ub(15);
77 
78  sa.read_entire(ns);
79 
80  // Output a text version to stdout
81 
82  cout << ns << endl;
83 
84  return 0;
85 }
The default name space; a poset which contains other posets as members.
virtual void get_read_write_access(bool xrelease_read_only_access=false)
Get read write access to the state associated with this. If release_read_only_access is requested...
static void initialize_prototypes()
Initialize all the prototypes needed by various factory methods,.
Namespace for the sheaves component of the sheaf system.
Agent responsible for importing and exporting posets from an external name space which resides on dis...
Definition: storage_agent.h:74